php调用mysql存储过程

2015-01-24信息快讯网
前面转载了一篇《php调用mysql存储过程的文章》经过测试,发现文章中的方法似乎不可行!

调用带有select语句的存储过程就出现 PROCEDURE p can't return a result set in the given context的错误。google了半天,在mysql官网上找到一些说法,db_mysql的模块不支持存储过程调用,解决方法是用db_mysqli。测试了一下,果然可以了。

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


<?php
/* Connect to a MySQL server */
$link = mysqli_connect(
'localhost', /* The host to connect to */
'root', /* The user to connect as */
'root', /* The password to use */
'db_name'); /* The default database to query */
if (!$link) {
printf("Can't connect to MySQL Server. Errorcode: %s\n", mysqli_connect_error());
exit;
}
/* Send a query to the server */
if ($result = mysqli_query($link, "call se_proc('crm')")) {
/* Fetch the results of 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_free_result($result);
}
/* Close the connection */
mysqli_close($link);
?>

郁闷的是费了半天劲搞出来的存储过程效率居然不如以前- -
PHP类(Class)入门教程第1/2页
php download.php实现代码 跳转到下载文件(response.redirect)
php 文件夹删除、php清除缓存程序
php 正则匹配函数体
PHP has encountered an Access Violation at 7C94BD02解决方法
php与php MySQL 之间的关系
PHP源码之 ext/mysql扩展部分
phpmyadmin MySQL 加密配置方法
php mysql Errcode: 28 终极解决方法
mysql 性能的检查和优化方法
php fckeditor 调用的函数
php 数组的创建、调用和更新实现代码
在JavaScript中调用php程序
隐性调用php程序的方法
PHP MSSQL 存储过程的方法
php xml-rpc远程调用
用PHP调用Oracle存储过程的方法
PHP调用MySQL的存储过程的实现代码
PHP+.htaccess实现全站静态HTML文件GZIP压缩传输(一)
mysql中存储过程、函数的一些问题
让PHP支持页面回退的两种方法[转]
浅析PHP水印技术
用PHP的ob_start();控制您的浏览器cache!
谈谈PHP的输入输出流
修改了一个很不错的php验证码(支持中文)
mysql 的 like 问题,超强毕杀记!!!
MySQL相关说明
mysql_fetch_assoc和mysql_fetch_row的功能加起来就是mysql_fetch_array
关于mysql 字段的那个点为是定界符
PHP中通过ADODB库实现调用Access数据库之修正版本 原创
PHP中通过ADO调用Access数据库的方法测试不通过
怎样在PHP中通过ADO调用Asscess数据库和COM程序
用PHP调用数据库的存贮过程!
利用php来自动调用不同服务器上的flash
PHP怎样调用MSSQL的存储过程
用PHP调用Oracle存储过程
©2014-2024 dbsqp.com