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.

> -----Original Message-----
> From: Tom Small [mailto:t...@re-base.net]
> Sent: 10 January 2012 15:47
> To: cf-talk
> Subject: Convert php to cfm
> 
> 
> 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();
> 
> }
> 
> ?>
> 
> ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
> ~~~~~~~~~~~|
> Order the Adobe Coldfusion Anthology now!
> http://www.amazon.com/Adobe-Coldfusion-
> Anthology/dp/1430272155/?tag=houseoffusion
> Archive: http://www.houseoffusion.com/groups/cf-
> talk/message.cfm/messageid:349374
> Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
> Unsubscribe: http://www.houseoffusion.com/groups/cf-
> talk/unsubscribe.cfm


~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:349375
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm

Reply via email to