调用存储过程失败!出现如下错误:PROCEDURE ipbx.qu_ery can't return a result set in the given context,
ipbx是数据库,
qu_ery是自己写的存储过程的名字;
原因:连接数据库的方式不正确。
导致报错的连接方式:
<?php
if(!mysql_real_connect(&mysql,"localhost","root","123456","ipbx",0,NULL,0))
{
printf("mysql_real_connect() failed!/n");
mysql_close(&mysql);
return 0;
}
正确的连接方式:
<?php
if(!mysql_real_connect(&mysql,"localhost","root","123456","ipbx",0,NULL,CLIENT_MULTI_STATEMENTS))
{
printf("mysql_real_connect() failed!/n");
mysql_close(&mysql);
return 0;
}
修改一下连接数据库的方式的参数就OK了!
FROM: http://blog.csdn.net/huichengongzi/article/details/5571346
你修改一下 system/database/drivers/mysql/mysql_driver.php function db_connect() { define("CLIENT_MULTI_RESULTS",131072);//Enable/disable multi-results define("CLIENT_MULTI_STATEMENTS",65536);//Enable/disable multi-statement support return @mysql_connect($this->hostname, $this->username, $this->password, TRUE,CLIENT_MULTI_STATEMENTS); }
FROM: http://ellislab.com/forums/viewthread/71141#476251
To retrieve multiple resultsets from the stored procs, you should use a client which supports multiple queries.
If you use PHP
, use MySQLi
extension and call the procedure using mysqli_multi_query
.
MySQL
extension is only able to retrieve the first recordset returned by the proc. To be able to use ti, you should set CLIENT_MULTI_RESULTS
(decimal 131072
) in the parameter $client_flags
tomysql_connect
codeigniter 调用存储过程出错 关键就是两点 1)define('CLIENT_MULTI_RESULTS', 131072); 2)$link = mysql_connect("127.0.0.1", "root", "",1,CLIENT_MULTI_RESULTS) or die("Could not connect: ".mysql_error());