Calling and using the data of a stored procedure works fine, but when I want to make another query afterwards (regardless if stored procedure or normal select) it doesn't work and shows the error message "Commands out of sync; you can't run this command now"
- Code: Select all
class actions_test {
function handle(&$params){
$app =& Dataface_Application::getInstance(); // reference to Dataface_Application object
$res = mysql_query("call storedProcedure(Null, Null, Null, Null, Null, Null)", $app->db());
if (!$res ) trigger_error(mysql_error($app->db()));
$data = array();
while($data[] = mysql_fetch_assoc($res)) { }
... //Output the data
$res = mysql_query("call storedProcedure(Null, Null, Null, Null, Null, Null)", $app->db());
if (!$res ) trigger_error(mysql_error($app->db()));
$data = array();
while($data[] = mysql_fetch_assoc($res)) { }
}
}
That's because the stored procedure return in fact two result sets, but according to http://us3.php.net/manual/en/function.mysql-query.php
"mysql_query() sends a unique query (multiple queries are not supported) ..."
And you have to receive/free all the data, before requesting new via a query. So that mess it up.
mysql_free_result($res) doesn't work, it does only fetch/clear all the rows of the given result, but not multiple results.
One suggested solution is to switch to mysqli (i for improved

According to http://dev.mysql.com/doc/refman/5.0/en/ ... ption.html you can enable multiple-statement support with mysql_set_server_option() and then use mysql_next_result() to get the next result. That would be the solution, but I get the fatal error "Call to undefined function mysql_set_server_option()"
What went wrong? Why isn't there this function? Can I install it somehow? How can I solve this problem otherwise?
I work with
* Apache/2.2.17 (Win32) mod_ssl/2.2.17 OpenSSL/0.9.8o PHP/5.3.4 mod_perl/2.0.4 Perl/v5.10.1
* MySQL-Client-Version: mysqlnd 5.0.7-dev - 091210 - $Revision: 304625 $
* PHP Extension: mysql