Three ways to implement non-buffered query API in PHP

墨辰丷
Release: 2023-03-29 09:42:02
Original
1687 people have browsed it

This article mainly introduces three kinds of PHP non-buffered query APIs. Non-buffered queries are suitable for large data query. How PHP performs non-buffered queries. Interested friends can refer to 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

##

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

##
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

Copy after login

Summary: The above is the entire content of this article, I hope it will be helpful to everyone's study.

Related recommendations:

Detailed graphic and text explanation of PHP two-dimensional array deduplication algorithm


php Detailed explanation of the three methods of obtaining POST data
##Think

php

Remove the index in the URL.php

The above is the detailed content of Three ways to implement non-buffered query API in PHP. For more information, please follow other related articles on the PHP Chinese website!

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
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!