当前位置: 移动技术网 > IT编程>开发语言>PHP > php如何执行非缓冲查询API

php如何执行非缓冲查询API

2017年12月12日  | 移动技术网IT编程  | 我要评论

泰兴中等专业学校,刘丹车祸现场尸体,爱彩网主页

对于php的缓冲模式查询大家都知道,下面列举的例子是如何执行非缓冲查询api。

非缓冲查询方法一: 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();
?>

非缓冲查询方法二: 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;
  }
}
?>

非缓冲查询方法三: 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;
  }
}
?>

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持移动技术网。

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网