Example of multiple queries using phpmysqli

Source: Internet
Author: User
Example of multiple queries using phpmysqli

Examples of Mysqli multiple queries in php. For more information, see.

Mysqli_multi_query (mysqli link, string query) is a process-based msyqli_more_results (mysqli link) that determines whether other result sets are returned. mysqli_next_result (mysqli link) obtain the next result set

Example:

  1. # Connecting to a database
  2. $ Link = mysqli_connect ("localhost", "root", "root ");
  3. # Selecting a database
  4. $ Link-> select_db ("rorely") or die ("cocould not find database ");
  5. # Querying databases
  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. ?>

Results: 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.