php mysqli多個查詢的例子

來源:互聯網
上載者:User

php中Mysqli多個查詢的例子,感興趣的朋友可以參考下。

mysqli_multi_query(mysqli link,string query) 連續執行多次查詢,是基於過程的msyqli_more_results(mysqli link) 主要確定返回的結果集是否有其他的結果集mysqli_next_result(mysqli link) 擷取下一個結果集

舉例:

  1. #串連資料庫
  2. $link=mysqli_connect("localhost","root","root");
  3. #選擇資料庫
  4. $link->select_db("rorely") or die("could not find database");
  5. #查詢資料庫
  6. if($link->multi_query("select * from test;select name ,age ,sex,address from test")){
  7. do{
  8. $result=$link->store_result();
  9. while($row=$result->fetch_row()){
  10. echo "$row[0],$row[1],$row[2],$row[3]
    ";
  11. }
  12. if($link->more_results()) echo "**********
    ";
  13. }while($link->next_result());
  14. }
  15. $link->close();
  16. ?>
複製代碼

結果如下:1,Jane,26,female3,Tome,21,male4,Lily,25,female5,Lucy,25,female6,Jim,22,male7,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#

  • 聯繫我們

    該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

    如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.