I want to convert cold fusion script into php. I dont know cold fusion can anyone help me ?
Here is the script.
<cfcomponent>
<cffunction name="getRs_random_agent" access="public" returntype="query" output="no">
<cfset var randomAgent = "">
<cfquery name="randomAgentRowNumber" datasource="JumpStart">
SELECT floor(rand(now()) * (SELECT COUNT(*) FROM staff WHERE type_id = 1)) AS RowNumber;
</cfquery>
<cfquery name="randomAgent" datasource="JumpStart">
SELECT staff.first_name, staff.last_name, staff_photos.small_photo, staff_photos.`description`
FROM staff, staff_photos
WHERE staff.type_id = 1 AND staff.primary_photo_id = staff_photos.photo_id LIMIT #randomAgentRowNumber.rownumber#, 1
</cfquery>
<cfreturn randomAgent>
</cffunction>
<cffunction name="getRs_random_model" access="public" returntype="query" output="no">
<cfset var randomModel = "">
<cfquery name="randomModelRowNumber" datasource="JumpStart">
SELECT floor(rand(now()) * (SELECT COUNT(*) FROM staff WHERE type_id = 2)) AS RowNumber;
</cfquery>
<cfquery name="randomModel" datasource="JumpStart">
SELECT staff.first_name, staff.specialty, staff.jump_height,staff.jump_style, staff_photos.medium_photo, staff_photos.`description`
FROM staff, staff_photos
WHERE staff.type_id = 2 AND staff.primary_photo_id = staff_photos.photo_id LIMIT #randomModelRowNumber.rownumber#, 1
</cfquery>
<cfreturn randomModel>
</cffunction>
</cfcomponent>
Cold fusion to PHP
Page 1 of 12 Replies - 1628 Views - Last Post: 24 February 2010 - 07:40 AM
Replies To: Cold fusion to PHP
#2
Re: Cold fusion to PHP
Posted 15 February 2010 - 02:24 PM
We don't do your homework for you. The information you posted is very basic ColdFusion. It may be worth it to learn the bare essentials of ColdFusion and convert it yourself.
#3
Re: Cold fusion to PHP
Posted 24 February 2010 - 07:40 AM
Indeed. However, to that I'll add this: the code snippet you posted is something called a Coldfusion component. It's a server component object that contain functions that define component methods. To make matters worse for you, those three component methods defined access your MySQL database to retrieve info and deliver it back to the calling code as a coldfusion query structure.
While I know you can access databases and use the generated query product in PHP, I'm not at all sure that PHP has an analog to Coldfusion component objects, functions and methods. The code you have there is fairly up to date and appears, by my cursory glance, to be well-formed CF code. Easy to read and maintain and pretty straightforward with what it's doing. Why on earth would you even want to push it into PHP? For the cost? It can't be for the ease of maintenance or future expandability because CF is superior on both counts.
I wish you luck on whatever you're doing there and as xheartonfire43x said, this forum doesn't exist to do your work for you...but really, you might want to reconsider why you'd even be wanting to rewrite an app from CF to PHP. I can only imagine it'd be an unholy mess to try and do so your motivating reasons for doing so must be compelling indeed to even want to attempt it.
While I know you can access databases and use the generated query product in PHP, I'm not at all sure that PHP has an analog to Coldfusion component objects, functions and methods. The code you have there is fairly up to date and appears, by my cursory glance, to be well-formed CF code. Easy to read and maintain and pretty straightforward with what it's doing. Why on earth would you even want to push it into PHP? For the cost? It can't be for the ease of maintenance or future expandability because CF is superior on both counts.
I wish you luck on whatever you're doing there and as xheartonfire43x said, this forum doesn't exist to do your work for you...but really, you might want to reconsider why you'd even be wanting to rewrite an app from CF to PHP. I can only imagine it'd be an unholy mess to try and do so your motivating reasons for doing so must be compelling indeed to even want to attempt it.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote




|