mysqli多条查询语句执行出错
<?php
require_once ('connect.php');
$sql="select * from newsreport.news;";
$sql.="select id,username,age from user;";
$mysqli->multi_query($sql);
if($mysqli->multi_query($sql)){
do{
if($res=$mysqli->store_result()){ //use_result()或store_result()得到查询的结果集
$rows[]=$res->fetch_all(MYSQLI_ASSOC);
$res->free();
//$res->free_result();
}
}while($mysqli->more_results()&&$mysqli->next_result());//more_result()检测是否有更多的结果集,next_result()将结果集指针向下移动一位
}else{
echo $mysqli->error;
}
print_r($rows);
$mysqli->close();
?>
结果显示:
Commands out of sync; you can't run this command now