首頁  >  文章  >  後端開發  >  php呼叫mysql預存程序

php呼叫mysql預存程序

WBOY
WBOY原創
2016-07-29 08:36:21977瀏覽

前面轉載了一篇《php呼叫mysql預存程序的文章》經過測試,發現文章中的方法似乎不可行!
呼叫有select語句的預存程序就出現 PROCEDURE p can't return a result set in the given context的錯誤。 google了半天,在mysql官網上找到一些說法,db_mysql的模組不支援預存程序調用,解決方法是用db_mysqli。測試了一下,果然可以了。
用法比較簡單,沒啥好說的,從網上copy一段代碼吧:
/* Connect to a MySQL server */
$link =hostmy_connect( ', /* The host to connect to */
'root', /* The user to connect as */
'root', /*2_oooo); /* The default database to query */
if (!$link) {
printf("Can't connect to My非常🎜>}
/* Send a query to the server */
if ($result = mysqli_query($link, "call se_proc('crm')")))> the query */
while( $row = mysqli_fetch_array($result) ){
echo ($row[0]. "--------- SR.  . $row[1] . "
");
}
/* Destroy the result set and free the memory used for it */ mysqli_close($link);
?>
鬱悶的是費了半天勁搞出來的儲存過程效率居然不如以前- -

以上就介紹了 php呼叫mysql存儲過程,包括了方面的內容,希望對PHP教程有興趣的朋友有幫助。


陳述:
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn