最大的網站源碼資源下載站,
返回單個數據:
1.1:創建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 ;
1.2: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/>";
}
p.s.:以上代碼執行通過環境 php 5.x.x + mysql 5.x.x
新聞熱點
疑難解答