Home > Backend Development > PHP Tutorial > If you are the one php php how to perform non-buffered query API

If you are the one php php how to perform non-buffered query API

WBOY
Release: 2016-07-27 16:56:24
Original
1648 people have browsed it

Everyone knows about PHP’s buffered mode query. The example listed below is how to execute the non-buffered query API.

Non-buffered query method one: mysqli

<&#63;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();
?>

Copy after login

Non-buffered query method two: pdo_mysql

<&#63;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;
  }
}
?>

Copy after login

Non-buffered query method three: mysql

<&#63;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;
  }
}
&#63;>

Copy after login

The above is the entire content of this article, hope It will be helpful to everyone's study, and I hope everyone will support this site.

The above introduces how to perform non-buffering query API in If You Are the One PHP, including the content of If You Are the One PHP. I hope it will be helpful to friends who are interested in PHP tutorials.

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template