zoukankan      html  css  js  c++  java
  • php mysqli多个查询的例子

    php中Mysqli多个查询的例子,感兴趣的朋友可以参考下。
    php中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
    **********
    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#
    li,22,female,wenming cun 23#
    hj,30,male,wenming cun 23#
    hj,30,male,wenming cun 23#

  • 相关阅读:
    CF 142B Tprimes
    CF 231A Team
    poj 2001 Shortest Prefixes ——字典树入门
    hdu 1039 Easier Done Than Said?
    poj 2528 Mayor's posters
    hdu 1061 Rightmost Digit
    poj 2503 Babelfish
    CF271 A. Beautiful Year
    poj 2752
    CF271 B. Prime Matrix
  • 原文地址:https://www.cnblogs.com/linuxnotes/p/3313379.html
Copyright © 2011-2022 走看看