PHP mysqli Examples of multiple queries

Source: Internet
Author: User

PHP mysqli A number of query examples, interested friends can refer to the next.

Mysqli_multi_query (mysqli link,string query) executes multiple queries consecutively, is a process-based msyqli_more_results (mysqli link) Primarily determines whether the returned result set has additional result sets Mysqli_next_result (mysqli link) Gets the next result set

Example:

    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. ?>
Copy Code

The results are as follows: 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#

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    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.