php调用mysql存储过程_php教程-查字典教程网
php调用mysql存储过程
php调用mysql存储过程
发布时间:2016-12-29 来源:查字典编辑
摘要:前面转载了一篇《php调用mysql存储过程的文章》经过测试,发现文章中的方法似乎不可行!调用带有select语句的存储过程就出现PROCE...

前面转载了一篇《php调用mysql存储过程的文章》经过测试,发现文章中的方法似乎不可行!

调用带有select语句的存储过程就出现PROCEDUREpcan'treturnaresultsetinthegivencontext的错误。google了半天,在mysql官网上找到一些说法,db_mysql的模块不支持存储过程调用,解决方法是用db_mysqli。测试了一下,果然可以了。

用法比较简单,没啥好说的,从网上copy一段代码吧:

<?php

/*ConnecttoaMySQLserver*/

$link=mysqli_connect(

'localhost',/*Thehosttoconnectto*/

'root',/*Theusertoconnectas*/

'root',/*Thepasswordtouse*/

'db_name');/*Thedefaultdatabasetoquery*/

if(!$link){

printf("Can'tconnecttoMySQLServer.Errorcode:%sn",mysqli_connect_error());

exit;

}

/*Sendaquerytotheserver*/

if($result=mysqli_query($link,"callse_proc('crm')")){

/*Fetchtheresultsofthequery*/

while($row=mysqli_fetch_array($result)){

echo($row[0]."---------SR.".$row[1]."

");

}

/*Destroytheresultsetandfreethememoryusedforit*/

mysqli_free_result($result);

}

/*Closetheconnection*/

mysqli_close($link);

?>

郁闷的是费了半天劲搞出来的存储过程效率居然不如以前--

相关阅读
推荐文章
猜你喜欢
附近的人在看
推荐阅读
拓展阅读
  • 大家都在看
  • 小编推荐
  • 猜你喜欢
  • 最新php教程学习
    热门php教程学习
    编程开发子分类