PHP中的循环内部存储过程

时间:2022-09-21 00:17:56

when i run the call procedure once it is working fine but if i put it inside for loop I'm getting error :

当我运行调用程序一旦它工作正常,但如果我把它放在循环中我得到错误:

Here is my Code :

这是我的代码:

<?php 
    //mysql_query(mysql, "SET @increment = 10");
    for($i=0;$i<2;$i++) {
        $overall_dissat=mysql_query("call daily_sales('HO Bangalore','2013-07-01','2013-07-30')");
        if($overall_dissat===false) {
            echo mysql_errno().': '.mysql_error();
        }
        while($obj=mysql_fetch_array($overall_dissat)) {
           //print_r($obj);
           echo "<td>".$obj['sat']."</td>";
        }
    }
?>

Here's the error:

这是错误:

2014: Commands out of sync; you can't run this command now

2014年:命令不同步;你现在不能运行这个命令

PHP中的循环内部存储过程

Talking with the Call Procedure in mySql is working fine . but from php ....? How to achieve it..

与mySql中的调用过程交谈正常。但是来自php ....?如何实现它..

1 个解决方案

#1


1  

Your stored procedure returns multiple result sets. A new query can only be issued on a connection after all pending results have been fetched. To process procedure call results you need to use mysqli_next_result() / mysqli_more_results(). See example.

存储过程返回多个结果集。只有在获取所有挂起结果后,才能在连接上发出新查询。要处理过程调用结果,您需要使用mysqli_next_result()/ mysqli_more_results()。见例子。

Stop using mysql_* functions, they're outdated.

停止使用mysql_ *函数,它们已经过时了。

#1


1  

Your stored procedure returns multiple result sets. A new query can only be issued on a connection after all pending results have been fetched. To process procedure call results you need to use mysqli_next_result() / mysqli_more_results(). See example.

存储过程返回多个结果集。只有在获取所有挂起结果后,才能在连接上发出新查询。要处理过程调用结果,您需要使用mysqli_next_result()/ mysqli_more_results()。见例子。

Stop using mysql_* functions, they're outdated.

停止使用mysql_ *函数,它们已经过时了。