print_r($mysqli_result)
<?php
header("content-type:text/html;charset=utf-8");
$mysqli = @new mysqli('localhost', 'root', '', 'test');
if ($mysqli->connect_errno) {
die("CONNECT ERROR : " . $mysqli->connect_error);
}
$mysqli->set_charset('utf8');
$sql = "SELECT id,username,age FROM user";
$mysqli_result = $mysqli->query($sql);
print_r($mysqli_result);
?>
$mysqli_result->num_rows
$mysqli_result->fetch_all()
<?php
header("content-type:text/html;charset=utf-8");
$mysqli = @new mysqli('localhost', 'root', '', 'test');
if ($mysqli->connect_errno) {
die("CONNECT ERROR : " . $mysqli->connect_error);
}
$mysqli->set_charset('utf8');
$sql = "SELECT id,username,age FROM user";
$mysqli_result = $mysqli->query($sql);
if ($mysqli_result && $mysqli_result->num_rows > 0) {
echo $mysqli_result->num_rows;
echo "<hr/>";
$rows = $mysqli_result->fetch_all();
print_r($rows);
}
?>
$mysqli_result->fetch_all(MYSQLI_NUM)
$rows = $mysqli_result->fetch_all(MYSQLI_NUM);
print_r($rows);
$mysqli_result->fetch_all(MYSQLI_ASSOC)
$mysqli_result->fetch_all(MYSQLI_BOTH)
$mysqli_result->fetch_row()
if ($mysqli_result && $mysqli_result->num_rows > 0) {
$rows = $mysqli_result->fetch_row();
print_r($rows);
}
$mysqli_result->fetch_assoc()
$mysqli_result->fetch_array(MYSQLI_ASSOC)
$mysqli_result->fetch_object()
$mysqli_result->data_seek(1)
if ($mysqli_result && $mysqli_result->num_rows > 0) {
$mysqli_result->data_seek(1);
$row = $mysqli_result->fetch_assoc();
print_r($row);
}
讀取
while ($row = $mysqli_result->fetch_assoc()) {
print_r($row);
echo "<hr/>";
//$rows[]=$row;
}
釋放結(jié)果集
$mysqli_result->close();
$mysqli_result->free();
$mysqli_result->free_result();
<?php
header("content-type:text/html;charset=utf-8");
$mysqli = @new mysqli('localhost', 'root', '', 'test');
if ($mysqli->connect_errno) {
die("CONNECT ERROR : " . $mysqli->connect_error);
}
$mysqli->set_charset('utf8');
$sql = "SELECT id,username,age FROM user";
$mysqli_result = $mysqli->query($sql);
if ($mysqli_result && $mysqli_result->num_rows > 0) {
while ($row = $mysqli_result->fetch_assoc()) {
print_r($row);
echo "<hr/>";
//$rows[]=$row;
}
//釋放結(jié)果集
$mysqli_result->close();
//$mysqli_result->free();
//$mysqli_result->free_result();
} else {
echo "查詢錯誤或者結(jié)果集中沒有記錄";
}
$mysqli->close();
?>
最后編輯于 :
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請聯(lián)系作者