存储过程很简单,就两条语句begin
select * from tt1;
select "hello the world!";
end
PHP:$row=mysql_fetch_row($res);
echo $row[0];
//mysql_free_result($res);//****
$row=mysql_fetch_row($res);
echo $row[0];
但上面的PHP代码只能读出第一个结果集,如果取消****那行注释,返回错误:
Warning: mysql_fetch_row(): 2 is not a valid MySQL result resource ......怎样才能把两个结果集都读出来?谢谢。
select * from tt1;
select "hello the world!";
end
PHP:$row=mysql_fetch_row($res);
echo $row[0];
//mysql_free_result($res);//****
$row=mysql_fetch_row($res);
echo $row[0];
但上面的PHP代码只能读出第一个结果集,如果取消****那行注释,返回错误:
Warning: mysql_fetch_row(): 2 is not a valid MySQL result resource ......怎样才能把两个结果集都读出来?谢谢。
while($row = mysql_fetch_row($res)){
var_dump($row);
}
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();
有没有不使用mysqli 的代码?谢谢.
$row=mysql_fetch_array($result);
echo $row[0];
$row=mysql_fetch_row($res);
print_r($row);
mysql_free_result($res);//****
$row=mysql_fetch_row($res);
print_r($row);
//这样不行?
"Warning: mysql_fetch_row(): 2 is not a valid MySQL result resource "