xueqiang
2016-08-30 09:43
public function fetch_more_sql($table1, $table2)
{
$sql = "SELECT * FROM ".$table1." LIMIT 1; SELECT * FROM ".$table2." LIMIT 1";
if(mysqli_multi_query($this ->db_connect(), $sql))
{
do{
//存储第一个结果集
if($result = mysqli_store_result($this ->db_connect() ))
{
while($row = mysqli_fetch_row($result)){
foreach ($row as $key => $value) {
echo $key;
}
}
mysqli_free_result($result);
}
} while( mysqli_next_result( $this ->db_connect()) && mysqli_more_results($this ->db_connect()) );
}
// print_r($rows);
}
入过我没看过的话,你用的一次只能执行一次SQL语句但是你执行了2条。$sql = "SELECT * FROM ".$table1." LIMIT 1; SELECT * FROM ".$table2." LIMIT 1";
,第二不要动态拼装SQL语句,慎防SQL注入,和自己拼写错误,应该用预处理语句,然后绑定参数试试
Duang~MySQLi扩展库来袭
28646 学习 · 181 问题
相似问题