mysqli多个查询
mysqli_multi_query(mysqli link,string query)连续执行多次查询,是基于过程的
msyqli_more_results(mysqli link)主要确定返回的结果集是否有其他的结果集
mysqli_next_result(mysqli link)获取下一个结果集
示例:
<?php
#连接数据库
$link=mysqli_connect("localhost","root","root");
#选择数据库
$link->select_db("rorely") or die("could not find database");
#查询数据库
if($link->multi_query("select * from test;select name ,age ,sex,address from test")){
do{
$result=$link->store_result();
while($row=$result->fetch_row()){
echo "$row[0],$row[1],$row[2],$row[3]<br>";
}
if($link->more_results()) echo "**********<br>";
}while($link->next_result());
}
$link->close();
?>
结果如下:
1,Jane,26,female
3,Tome,21,male
4,Lily,25,female
5,Lucy,25,female
6,Jim,22,male
7,Jim,22,male
8,Jim,22,male
9,Jim,22,male
10,Jim,22,male
11,Jim,22,male
12,Jim,22,male
13,Jniu,22,female
14,Jim,22,male
15,Jim,22,male
18,Jim,22,male
20,Jim,22,male
78,lili,22,female
79,hj,30,male
80,hj,30,male
**********
Jane,26,female,wenming cun 123#
Tome,21,male,wenming cun 32#
Lily,25,female,wenming cun 2#
Lucy,25,female,wenming cun 2#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jniu,22,female,address
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
Jim,22,male,wenmin cun 45#
lili,22,female,wenming cun 23#
hj,30,male,wenming cun 23#
hj,30,male,wenming cun 23#
posted on 2009-07-02 15:56
期待明天 阅读(795)
评论(0) 编辑 收藏 所属分类:
PHP