php调用mysql存储过程返回多个结果集的处理
返回一个结果全世界都知道怎么处理,关键是返回多个结果集就不好办了,下面有一解决办法
存储过程代码
DELIMITER $$;
DROP PROCEDURE IF EXISTS `test`.`sp_test`$$
CREATE PROCEDURE `test`.`sp_test` ()
BEGIN
select * from `user`.`user` limit 0, 50;
select count(0) as `count` from `user`.`user`;
END$$
DELIMITER ;$$
php 代码
$rows = array ();
$db = new mysqli('127.0.0.1','root','123456','user');
if (mysqli_connect_errno()){
$this->message('Can not connect to MySQL server');
}
$db->query("SET NAMES UTF8");
if($db->real_query("call sp_test()")){
do{
if($result = $db->store_result()){
while ($row = $result->fetch_assoc()){
array_push($rows, $row);
}
$result->close();
}
}while($db->next_result());
}
$db->close();
相关文档:
安裝MySQL-Server
$ sudo apt-get install mysql-server
安裝Apache HTTP Server
$ sudo apt-get install apache2
安裝PHP for Apache HTTP Server
$ sudo apt-get install php5
安裝MySQL for Apache HTTP Server
$ sudo apt-get install libapache2-mod-auth-mysql
$ sudo apt-get ......
俺今天这么激动又想写文章的原因是MySQL5.1的发布带来了设计超强动力数据库的强有力的武器,任何MySQL的DBA都应该尽快学习并使用它。俺觉得如果能很好滴使用这个5.1版带来的新特性,DBA可以使自己管理的VLDB(不知道什么是VLDB?告诉你,是好大好大的数据库的意思,Very Large DB)或数据仓库奇迹般的获得巨大的性能提升。 ......
(PHP 4 >= 4.0.4)
功能说明:Check for numeric character(s)
Description
bool ctype_digit ( string text)
Returns TRUE if every character in text is a decimal digit, FALSE otherwise.
例子 1. A ctype_digit() example
<?php $strings = array('1820.20', '10002', 'wsl!12'); foreach ($strings ......
编写关于 PHP 的系列文章让我更加深刻地了解了 PHP 开发人员的世界。我和许多 PHP 程序员交谈过,最令我惊奇的是只有很少的人使用 IDE。大多数程序员使用文本编辑器,比如 Microsoft® Windows® 上的记事本、Emacs 或者 Vim。
我提到的这些文本编辑器(以及我没提到)都是很不错的 —— 我不想讨论 ......
1.echo();2.print();3.die();4.printf();5.sprintf();6.print_r;7.var_dump();
1.echo()
输出多个字符串,可以多个参数,不需要圆括号,无返回值。
2.print()
只能输出一样东西,需要圆括号,有返回值,执行失败是返回flase.
3.die()
输出内容,停止程序。*多用于数据库的链接时,检验是否出错。
4.printf()
prin ......