Jquery中文网 www.jquerycn.cn
Jquery中文网 >  脚本编程  >  php  >  正文 php调用存储过程返回结果集的例子

php调用存储过程返回结果集的例子

发布时间:2018-05-09   编辑:www.jquerycn.cn
本文介绍了php编程中调用存储过程,并返回结果集的实现代码,有需要的朋友参考学习下。

php调用存储过程返回结果集,解决can't return a result set in the given context错误的方法。
需要php调用存储过程,返回一个结果集。
关键就是mysql_connect,第四个参数加上1,131072
 

复制代码 代码示例:
$link = mysql_connect("127.0.0.1", "root", "",1,131072) or die("Could not connect: ".mysql_error());

例子,php调用存储过程返回结果集。
 

复制代码 代码示例:

<?php
define('CLIENT_MULTI_RESULTS', 131072);
$link = mysql_connect("127.0.0.1", "root", "",1,CLIENT_MULTI_RESULTS) or die("Could not connect: ".mysql_error());
mysql_select_db("vs") or die("Could not select database");

$result = mysql_query("call get_news_from_class_id(2)") or die("Query failed:" .mysql_error());
while($row = mysql_fetch_array($result, MYSQL_ASSOC))
{
  $line = '<tr><td><a target = _blank href=\''.$row["url"].'\'>'.$row["title"].'('.$row["page_time"].')'.'</a></td></tr>';
  echo $line;
   printf("\n");
}
mysql_free_result($result);

mysql_close($link);
?>

您可能感兴趣的文章:
php调用存储过程返回结果集的例子
php得到mssql的存储过程的输出参数的代码
php存储过程调用举例
php与mssql存储过程的返回值的相关问题
php获取mssql的存储过程的输出参数的方法
mysql存储过程实例教程
asp.net调用存储过程详解
php mysqli类的演示例子
Sql Server获取存储过程返回值的综合例子
使用 .NET的IO(4) Paul_Ni(原作)

关键词: 存储过程  结果集   
[关闭]