問(wèn)題描述
我正在使用 mysql 存儲(chǔ)過(guò)程運(yùn)行查詢(xún):
I am running a query with a mysql stored procedure :
$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));
我應(yīng)該從通話中得到一個(gè)結(jié)果:@@IDENTITY = 一個(gè)數(shù)字;
I am supposed to get just one result from the call : @@IDENTITY = a number;
$AP_result = mysql_fetch_array($AddProf_qr);
$CurrentSID = $AP_result['@@IDENTITY'];
效果很好.但是當(dāng)我在此之后立即運(yùn)行另一個(gè) mysql 更新查詢(xún)時(shí),它給出了一個(gè)錯(cuò)誤:
which works fine. but when i run another mysql update query right after this, it gives an error saying :
錯(cuò)誤:2014 (CR_COMMANDS_OUT_OF_SYNC)消息:命令不同步;你現(xiàn)在不能運(yùn)行這個(gè)命令
Error: 2014 (CR_COMMANDS_OUT_OF_SYNC) Message: Commands out of sync; you can't run this command now
我試過(guò)插入:
mysql_free_result($AddProf_qr);
但還是一樣.
MySQL 調(diào)用也能正常執(zhí)行腳本的其余部分運(yùn)行沒(méi)有問(wèn)題,上面被注釋掉了.但它們不會(huì)同時(shí)運(yùn)行.我最好的猜測(cè)是,這個(gè)電話正在做一些把事情搞砸的事情.
The MySQL call executes fine also the rest of the script runs without issues the above is commented out. but they don't run at the same time. My best guess is, the call is doing something that's messing this up.
推薦答案
您的存儲(chǔ)過(guò)程正在返回多個(gè)結(jié)果集.請(qǐng)參閱這篇文章
Your stored procedure is returning multiple resultsets. See this post
解決方案?
- 使用mysqli_multi_query
- 停止使用古老的 mysql 庫(kù) - mysqli 中的 i 代表改進(jìn)" - 有充分的理由.
這篇關(guān)于存儲(chǔ)過(guò)程導(dǎo)致“命令不同步"在下一個(gè)查詢(xún)的文章就介紹到這了,希望我們推薦的答案對(duì)大家有所幫助,也希望大家多多支持html5模板網(wǎng)!