在PHP调用存储过程返回结果集的时候,会提示:can't return a result set in the given context;解决can't return a result set in the given context的方法。
来源:http://code.haohailuo.com/article-325.html
<?php
define('CLIENT_MULTI_RESULTS', 131072);
$link = mysql_connect("127.0.0.1", "root", "123",1,CLIENT_MULTI_RESULTS) or die("Could not connect: ".mysql_error());
mysql_select_db("test") or die("Could not select database");
$sql = "create procedure select_data()
begin
select * from user;
end;";
mysql_query($sql);
$result = mysql_query("call test.select_data()") or die("Query failed:" .mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$line = '<tr><td><a target = _blank href=\''.$row["name"].'\'>'.$row["name"].'('.$row["pwd"].')'.'</a></td></t
r>';
echo $line;
printf("\n");
}
?>
define('CLIENT_MULTI_RESULTS', 131072);
$link = mysql_connect("127.0.0.1", "root", "123",1,CLIENT_MULTI_RESULTS) or die("Could not connect: ".mysql_error());
mysql_select_db("test") or die("Could not select database");
$sql = "create procedure select_data()
begin
select * from user;
end;";
mysql_query($sql);
$result = mysql_query("call test.select_data()") or die("Query failed:" .mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
$line = '<tr><td><a target = _blank href=\''.$row["name"].'\'>'.$row["name"].'('.$row["pwd"].')'.'</a></td></t
r>';
echo $line;
printf("\n");
}
?>
来源:http://code.haohailuo.com/article-325.html
作者:jackxiang@向东博客 专注WEB应用 构架之美 --- 构架之美,在于尽态极妍 | 应用之美,在于药到病除
地址:http://jackxiang.com/post/3974/
版权所有。转载时必须以链接形式注明作者和原始出处及本声明!
评论列表