views:

146

answers:

1

Here's what I'm trying to do ...

Im using Flash to call an AMFPHP service that queries my database and returns the result resource. Before returning the result to the Flash movie I need to edit some of the values in the result resource.

How can i iterate through the rows of the result, change some values and 'repackage' the resource to return to Flash?

I have thought of -

$sql = sprintf("SELECT file_name FROM ....");
$result = mysql_query($sql);
while($row=mysql_fetch_array($result)){ 
    $row['file_name'] = performFunctionOn($row['file_name']);
}
$row = 0;
if(!mysql_data_seek($result,$row))continue;
return $result

I am trying to change the filename that is stored in the database and trying to avoid sending a long string back to Flash which i realise is the simple way to do this.

many thanks Stephen

+1  A: 

If you want to replace all selected values with a literal constant, you can do the following:

$sql = sprintf("SELECT 'INeedToChangeThis' FROM ....");
$result = mysql_query($sql);
return $result

If you want to change your data on the fly, you'll probably need to derive a custom class from mysqli_stmt and override mysqli_stmt::fetch so that is updates the referenced variable after calling parent fetch.

Here's a nice tutorial on how to derive a custom class from mysqli_stmt.

Quassnoi
Hi, actually I want to retrieve the file_name from the database and then perform a function which will alter the file_name. so can I do - $sql = sprintf("SELECT" myFunction(file_name) FROM ... if so - great.thanks
undefined
thanks, can you describe this further please... I have dug around in the amfphp folder to see where i can intercept the variable and looked at the manual for mysqli_stmt. How would I go about doing what you suggest.
undefined
See updated post.
Quassnoi