《PHP学习:php如何执行非缓冲查询API》要点:
本文介绍了PHP学习:php如何执行非缓冲查询API,希望对您有用。如果有疑问,可以联系我们。
PHP实例对于PHP的缓冲模式查询大家都知道,下面列举的例子是如何执行非缓冲查询API.
PHP实例非缓冲查询方法一: mysqli
PHP实例
<?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();
?>
PHP实例非缓冲查询方法二: pdo_mysql
PHP实例
<?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;
}
}
?>
PHP实例非缓冲查询方法三: mysql
PHP实例
<?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;
}
}
?>
PHP实例以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持维易PHP.
转载请注明本页网址:
http://www.vephp.com/jiaocheng/5095.html