House of Fusion
Search over 2,500 ColdFusion resources here
  
Home of the ColdFusion Community

Mailing Lists
Home /  Groups /  ColdFusion Talk (CF-Talk)

Convert php to cfm

  << Previous Post |  RSS |  Tree View |  Sort Latest First |  Subscribe to this Group Next >> 

Convert php to cfm

Hi, I need to convert php to coldfusion. Would appreciate some help, thanks.... Tom Small 01/10/2012 10:47 AM
This seems like a pretty straightforward conversion. Create the datasource Edward Chanter 01/10/2012 11:00 AM
Wow, and I wonder at times why PHP is so popular... Andrew Scott 01/10/2012 11:02 AM
> Wow, and I wonder at times why PHP is so popular... Phillip Vector 01/10/2012 11:07 AM
> -----Original Message----- Edward Chanter 01/10/2012 11:10 AM
Hi Andrew, thanks for your help and Tom Small 01/10/2012 11:54 AM
Hi Andrew, I am using ColdFusion9 and have downloaded json (serialize and Tom Small 01/11/2012 05:52 AM
Maybe I missed something important earlier in the thread, but why are Raymond Camden 01/11/2012 12:00 PM
Tom... andy matthews 01/11/2012 12:01 PM
ColdFusion 9 comes with its own serialise and de-serialise function of json, Andrew Scott 01/11/2012 12:18 PM
Andrew, to be clear, are you saying Ext doesn't like the _structure_ Raymond Camden 01/11/2012 12:22 PM

01/10/2012 10:47 AM
Author: Tom Small Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349374 Hi, I need to convert php to coldfusion. Would appreciate some help, thanks.... <?php #First we include our credentials file # FileName="connect.php" $hostname = "localhost"; $database = "nimsoftslmdev"; $username = "root"; $password = "xxx"; #And now we connect to the database //connection String //connection String $con = mysql_connect($hostname, $username, $password) or die('Could not connect: ' . mysql_error()); //select database mysql_select_db($database, $con); //Select The database $bool = mysql_select_db($database, $con); if ($bool === False){     print "can't find $database"; } $start = ($_REQUEST["start"] == null)? 0 : $_REQUEST["start"]; $limit = ($_REQUEST["limit"] == null)? 200 : $_REQUEST["limit"];     // Gather all pending requests $query = "SELECT nimid, level, message, source FROM nas_alarms" ; $query .= " ORDER BY level ASC "; $query .= " LIMIT ".$start.",".$limit; $result = mysql_query($query, $con); // Here we do the count $query_c = "SELECT nimid, level, message, source FROM nas_alarms" ; //get total $count_result = mysql_query($query_c, $con); $total = mysql_num_rows($count_result); if (mysql_num_rows($result) > 0){ while($obj = mysql_fetch_object($result))     {         $arr[] = $obj;     } // Now create the json array to be sent to our datastore $myData = array('myInventory' => $arr, 'totalCount' => $total); echo json_encode($myData); return; exit(); } else { // If no requests found, we return nothing $myData = array('myInventory' => '', 'totalCount' => '0'); echo json_encode($myData); return; exit(); } ?>
01/10/2012 11:00 AM
Author: Edward Chanter Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349375 This seems like a pretty straightforward conversion. Create the datasource in the CF admin to point to MySQL and then simply write a <cfquery> with the same basic syntax as is used in the PHP. Specify maxrows=200 and then cfoutput it via json to your datastore. I might be missing something but it seems that simple. ----- Excess quoted text cut - see Original Post for more -----
01/10/2012 11:02 AM
Author: Andrew Scott Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349376 Wow, and I wonder at times why PHP is so popular... Not being a Guru at PHP what you are trying to convert here is very simple, and this is not tested but as close to being right as I can think. <cfquery name="result" datasource="" username="#username#" passwqord="#password#"> SELECT nimid, level, message, source FROM nas_alarms LIMIT #url.start#, #url.limit# </cfquery> Now I have not included the required cfqueryparams, which you should look into as a security measure. Once you have this returned the variable result will hold the query. So when you want the number of records returned you can use result.recordCount as the number of records returned. When you talk about JSon, you dont mention which version of ColdFusion, so you can either use the library from CFlibs to create the JSOn or you can use ColdFusion to create the JSON. Eitherway the amount of code is much simpler than what you have there in the PHP. -- Regards, Andrew Scott WebSite: http://www.andyscott.id.au/ Google+: http://plus.google.com/108193156965451149543 ----- Excess quoted text cut - see Original Post for more -----
01/10/2012 11:07 AM
Author: Phillip Vector Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349377 > Wow, and I wonder at times why PHP is so popular... Because it is cheaper to run it.. Nevermind the fact that you are paying developers allot more (as in, it takes more time) to code in PHP. :) Note the Sarcasm of the first sentence. :)
01/10/2012 11:10 AM
Author: Edward Chanter Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349378 > -----Original Message----- > Wow, and I wonder at times why PHP is so popular... My thought too, this is a great example of why I love CF over PHP :)
01/10/2012 11:54 AM
Author: Tom Small Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349379 Hi Andrew, thanks for your help and advice
01/11/2012 05:52 AM
Author: Tom Small Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349390 Hi Andrew, I am using ColdFusion9 and have downloaded json (serialize and deserialize) from cflibs. Although this may sound naive, can you tell me where to include both files, also how to cfoutput it via json to my datastore  as I am a newbie...
01/11/2012 12:00 PM
Author: Raymond Camden Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349400 Maybe I missed something important earlier in the thread, but why are you downloading JSON libraries? CF9 includes native JSON functions. > > Hi Andrew, I am using ColdFusion9 and have downloaded json (serialize and deserialize) from cflibs. Although this may sound naive, can you tell me where to include both files, also how to cfoutput it via json to my datastore  as I am a newbie...
01/11/2012 12:01 PM
Author: andy matthews Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349401 Tom... If you're using CF8 or above, then you already have JSON functions built in. <cfset myArray = ['andy', 'jaime']> <cfset json = SerializeJSON(myArray)> <cfset newArray = DeserializeJSON(json)> http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_ c-d_43.html#5176845 http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_ in-k_18.html#5177391 http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=functions_ s_03.html#292127 Hi Andrew, I am using ColdFusion9 and have downloaded json (serialize and deserialize) from cflibs. Although this may sound naive, can you tell me where to include both files, also how to cfoutput it via json to my datastore  as I am a newbie...
01/11/2012 12:18 PM
Author: Andrew Scott Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349409 ColdFusion 9 comes with its own serialise and de-serialise function of json, the downside to this is that extJS will not work natively with that format of Json. I think I blogged an example on how you can write your own reader to then convert ColdFusion's JSon by extJS. As for output into the store, this is easily done by using the datastore load or via an ajax call manually. Then when the data is returned the store will do all the hard work for you. Most of what you are asking is Javascript, and there are plenty of examples on sencha.com and their forums to achieve what you are looking for. The downside as I said is ColdFusion 8/9 native functions have a different JSon format and therefore need a reader to convert this on the fly as it is read. If you find yourself getting stuck some more, start with some of the examples and tutorials, and then use ColdFusion to deliver the content. Even if it is a basic grid, with a datastore that automatically loads the data via Ajax. You should not have any problems with this, but if you do then by all means shoot me an email and I will help you out further. --  Regards, Andrew Scott WebSite: http://www.andyscott.id.au/ Google+: http://plus.google.com/108193156965451149543 Hi Andrew, I am using ColdFusion9 and have downloaded json (serialize and deserialize) from cflibs. Although this may sound naive, can you tell me where to include both files, also how to cfoutput it via json to my datastore  as I am a newbie...
01/11/2012 12:22 PM
Author: Raymond Camden Short Link: http://www.houseoffusion.com/groups/cf-talk/thread.cfm/threadid:63628#349410 Andrew, to be clear, are you saying Ext doesn't like the _structure_ of the data, or the format itself? CF9's JSON is valid JSON, so it must be the format. If so - there should be a way to create your CF variable so that when serialized, Ext will like it. For example, I've used jQuery Plugins where if i just serialize a query as is, the result isn't what the plugin wants. I normally then just switch to an array of structs. > > ColdFusion 9 comes with its own serialise and de-serialise function of json, > the downside to this is that extJS will not work natively with that format > of Json. I think I blogged an example on how you can write your own reader > to then convert ColdFusion's JSon by extJS.
<< Previous Thread Today's Threads Next Thread >>

Search cf-talk

July 28, 2014

<<   <   Today   >   >>
Su Mo Tu We Th Fr Sa
     1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29 30 31     

Designer, Developer and mobile workflow conference