Php executes the non-buffer query API and php executes the buffer API.

Source: Internet
Author: User

Php executes the non-buffer query API and php executes the buffer API.

For queries in the buffer mode of PHP, we all know that the example below is how to execute the non-buffer query API.

Method 1:Mysqli

<?php$mysqli = new mysqli("localhost", "my_user", "my_password", "world");$uresult = $mysqli->query("SELECT Name FROM City", MYSQLI_USE_RESULT);if ($uresult) {  while ($row = $uresult->fetch_assoc()) {    echo $row['Name'] . PHP_EOL;  }}$uresult->close();?>

Method 2:Pdo_mysql

<?php$pdo = new PDO("mysql:host=localhost;dbname=world", 'my_user', 'my_pass');$pdo->setAttribute(PDO::MYSQL_ATTR_USE_BUFFERED_QUERY, false);$uresult = $pdo->query("SELECT Name FROM City");if ($uresult) {  while ($row = $uresult->fetch(PDO::FETCH_ASSOC)) {    echo $row['Name'] . PHP_EOL;  }}?>

Method 3: mysql

<?php$conn = mysql_connect("localhost", "my_user", "my_pass");$db  = mysql_select_db("world");$uresult = mysql_unbuffered_query("SELECT Name FROM City");if ($uresult) {  while ($row = mysql_fetch_assoc($uresult)) {    echo $row['Name'] . PHP_EOL;  }}?>

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

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.