|
返回单个数据:
创建MySQL存储过程:
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`proc_test` $$
CREATE PROCEDURE `test`.`proc_test` (out a int)
BEGIN
select count(*) into a from tblname;
END $$
DELIMITER ;
PHP调用:
$db-〉query(“CALL test.proc_test(@a)“);
$res = $db-〉query(“select @a“);
$row = $res-〉fetch_array();
echo $row[’@a’];
返回多个数据:
2.1:创建MySQL存储过程:
DELIMITER $$
DROP PROCEDURE IF EXISTS `test`.`proc_test` $$
CREATE PROCEDURE `test`.`proc_test` ()
BEGIN
select * from tbl_name;
END $$
DELIMITER ;
2.2:PHP调用:
$res=$db-〉query(“CALL test.proc_test()“);
while ($arr=$res-〉fetch_array())
{
echo $arr[“Field“] .“〈br/〉“;
} |
|