我正在使用mysql存储过程运行查询:
$AddProf_qr = mysql_query("call AddStudent('$d_Pass', '$d_Titl', '$d_Firs', '$d_Midd', '$d_Last', '$d_Addr', '$d_City', '$d_Stat', '$d_County', '$d_Zipc', $d_Gend, '$d_Birh', '$d_Phom', '$d_Phoh', '$d_Phoo', '$d_Email', '$d_Webs', '$d_Natn', '$d_Profsn', '$d_Compny', '$d_Desig', $d_ProfAcc)", $this->c_remote) or die ("first call" . mysql_error($this->c_remote));我应该只从调用中得到一个结果:@@IDENTITY =a number;
$AP_result = mysql_fetch_array($AddProf_qr);
$CurrentSID = $AP_result['@@IDENTITY'];它工作得很好。但是,当我在此之后运行另一个mysql更新查询时,它给出了一个错误消息:
错误: 2014 (CR_COMMANDS_OUT_OF_SYNC)消息:命令不同步;您现在无法运行此命令
我尝试插入以下内容:
mysql_free_result($AddProf_qr);但仍然是一样的。
MySQL调用执行得很好,脚本的其余部分也可以正常运行,上面的注释被注释掉了。但它们不是同时运行的。我最好的猜测是,调用正在做一些把事情搞糟的事情。
发布于 2010-02-23 08:01:08
发布于 2011-08-19 19:54:31
@DMin是的,这是可行的,但你迟早会使服务器崩溃。只要算算一下,一次对一个页面的请求就会使数据库有3*个过程!你好好想想看!
更新解决方案:
$aCategory = array();
$it=0;
$res = $mysqli->multi_query( "call ListCategory();" );
if( $res ) {
do {
if ($result = $mysqli->store_result()) {
while( $row = $result->fetch_row() ) {
$aCategory[$it] =$row;
$it= $it + 1;
}
$result->close();
}
} while( $mysqli->next_result() );
}
foreach($aCategory as $row){
echo . $row[0] . " - " . $row[1] . "<br />";
} 我只想补充一下,你已经准备好调用下一个例程了。
PS:这样的话我就不能使用
echo $aCategory['category_id'] ;
//or
echo $aCategory->category_id;
//just
echo $aCategory[0] 发布于 2010-02-23 08:02:11
查看这里:http://us3.php.net/manual/en/function.mysql-query.php在评论中,一个人声称他是通过将连接标志设置为MYSQL_MULTI_RESULTS (131072)来使其工作的。
但是使用mysqli会更好……
https://stackoverflow.com/questions/2315127
复制相似问题