本文整理汇总了PHP中mysqli_fetch_all函数的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_fetch_all函数的具体用法?PHP mysqli_fetch_all怎么用?PHP mysqli_fetch_all使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了mysqli_fetch_all函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute_multi
function execute_multi($link, $arr_sqls, &$error)
{
$sqls = implode(';', $arr_sqls) . ';';
if (mysqli_multi_query($link, $sqls)) {
$data = array();
$i = 0;
//计数
do {
if ($result = mysqli_store_result($link)) {
$data[$i] = mysqli_fetch_all($result);
mysqli_free_result($result);
} else {
$data[$i] = null;
}
$i++;
if (!mysqli_more_results($link)) {
break;
}
} while (mysqli_next_result($link));
if ($i == count($arr_sqls)) {
return $data;
} else {
$error = "sql语句执行失败:<br /> 数组下标为{$i}的语句:{$arr_sqls[$i]}执行错误<br /> 错误原因:" . mysqli_error($link);
return false;
}
} else {
$error = '执行失败!请检查首条语句是否正确!<br />可能的错误原因:' . mysqli_error($link);
return false;
}
}
示例2: getResults
public function getResults($sSQL)
{
$oQuery = mysqli_query($this->_connection, $sSQL);
if ($oQuery) {
return mysqli_fetch_all($oQuery, MYSQLI_ASSOC);
}
return false;
}
示例3: show_brand_goods
function show_brand_goods()
{
$brand = $_GET['brand'];
$link = mysqli_connect("localhost", "magUser", "Mag_user", "magazine");
if (!$link) {
echo "Ведутся технические работы";
die;
}
$res = mysqli_query($link, "SELECT * FROM `t_products` WHERE `brand`= '{$brand}'");
$main_brand = mysqli_fetch_all($res, MYSQLI_ASSOC);
foreach ($main_brand as $key => $val) {
?>
<article class="oneGood">
<a class="imgGood" href="#">
<img src="images/oneGood.png" alt="">
</a>
<p class="priceGood">
<?php
echo $main_brand[$key]['price'];
?>
</p>
<p class="descGood">
<a href="http://shop/cart.php?id=<?php
echo $main_brand[$key]['id'];
?>
"><?php
echo $main_brand[$key]['name'];
?>
</a>
</p>
</article>
<?php
}
}
示例4: getCabinInclusions
function getCabinInclusions($link, $id)
{
$query = "SELECT inclID, inclusionName, tblCabins_cabinID\n\t\tFROM tblInclusions, tblCabinInc\n\t\tWHERE tblInclusions.inclID = tblCabinInc.tblInclusions_InclID\n\t\tAND tblCabinInc.tblCabins_cabinID = {$id}";
$result = mysqli_query($link, $query);
$inclusions = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $inclusions;
}
示例5: book
function book()
{
global $database;
$check_in = $_POST['checkIn'];
$check_out = $_POST['checkOut'];
$room_id = $_POST['roomId'];
$sql = "SELECT * FROM bookings WHERE room_id = {$room_id} AND ( '{$check_in}' BETWEEN arrival AND departure ) OR ( '{$check_out}' BETWEEN arrival AND departure )";
$result = $database->query($sql);
$result = mysqli_fetch_all($result);
if (!empty($result)) {
$data = array('success' => false, 'message' => 'The room is already booked');
echo json_encode($data);
} else {
$sql = "INSERT INTO bookings(room_id,arrival,departure)";
$sql .= "VALUES({$room_id},'{$check_in}','{$check_out}')";
$database->query($sql);
$data = array('success' => true, 'message' => 'You booked the room');
echo json_encode($data);
}
die;
/*print_r( $result );
die();*/
}
示例6: query
public function query($sql)
{
$resource = mysqli_query($this->link, $sql);
if ($resource != false) {
if ($resource !== true && get_class($resource) == 'mysqli_result') {
$data = array();
if (function_exists('mysqli_fetch_all')) {
$data = mysqli_fetch_all($resource, MYSQLI_ASSOC);
} else {
$i = 0;
while ($result = mysqli_fetch_assoc($resource)) {
$data[$i] = $result;
$i++;
}
}
$query = new stdClass();
$query->row = isset($data[0]) ? $data[0] : array();
$query->rows = $data;
$query->num_rows = mysqli_num_rows($resource);
mysqli_free_result($resource);
unset($data);
return $query;
} else {
return true;
}
} else {
trigger_error('Error: ' . mysqli_error($this->link) . '<br />Error No: ' . mysqli_errno($this->link) . '<br />' . $sql);
exit;
}
}
示例7: updateList
function updateList($user, $nbmessages)
{
$sql = "SELECT COUNT(*) FROM message";
$result = mysqli_query(db(), $sql);
$result = mysqli_fetch_all($result)[0][0];
$DATA = ["new" => false, "message" => ""];
if ($nbmessages < $result) {
if ($nbmessages != 0) {
$nbnew = $result - $nbmessages;
$sql = "SELECT * FROM message ORDER BY date DESC LIMIT {$nbnew}";
$result = mysqli_query(db(), $sql);
$messages = mysqli_fetch_all($result, MYSQLI_ASSOC);
$taille = count($messages);
$message = $messages;
for ($i = 1; $i < $taille - 1; $i++) {
$messages[$i] = $message[$taille - $i];
}
} else {
$sql = "SELECT * FROM message";
$result = mysqli_query(db(), $sql);
$messages = mysqli_fetch_all($result, MYSQLI_ASSOC);
}
foreach ($messages as $row) {
if ($row['user'] == $user) {
$DATA['message'] .= "<div class='sent'><p class='content' title='{$row['date']}'>{$row['msg']}</p><div class='icon'>me</div></div>";
} else {
$DATA['message'] .= "<div class='received'><div class='icon'>anonym</div><p class='content' title='{$row['date']}'>{$row['msg']}</p></div>";
$DATA['new'] = true;
}
}
}
echo json_encode($DATA);
}
示例8: getAllAssoc
public function getAllAssoc($sql)
{
$queryRes = $this->query($sql);
$res = mysqli_fetch_all($queryRes, MYSQLI_ASSOC);
if (!empty($res)) {
return $res;
}
}
示例9: findCarEngines
function findCarEngines($model)
{
global $db;
$query = 'SELECT * FROM car_engines WHERE model_id = ' . $model;
$result = mysqli_query($db, $query);
$engines = mysqli_fetch_all($result);
echo json_encode($engines);
}
示例10: findCarEngines
function findCarEngines($makeId, $modelId)
{
global $connection;
$query = "SELECT * FROM engines WHERE make=" . $makeId . " AND model=" . $modelId;
$result = mysqli_query($connection, $query);
$engines = mysqli_fetch_all($result);
echo json_encode($engines);
}
示例11: get_datakader_by_nim
function get_datakader_by_nim($nimkader)
{
$info = array();
include 'connectdb.php';
$result = mysqli_query($con, 'SELECT tabel_data_kader.NIM, Nama_Mahasiswa, Organisasi, Posisi, Acara FROM tabel_mahasiswa, tabel_data_kader WHERE tabel_data_kader.NIM = ' . $nimkader . ' AND tabel_mahasiswa.NIM = ' . $nimkader);
$info = mysqli_fetch_all($result, MYSQL_ASSOC);
return $info;
}
示例12: getList
public function getList($limit = 0, $offset = 0)
{
$sql = 'select * from films';
$limit ? $sql = $sql . ' limit ' . intval($limit) : '';
$limit && $offset ? $sql = $sql . ' offset ' . intval($limit) : '';
$result = $this->query($sql);
return mysqli_fetch_all($result, MYSQLI_ASSOC);
}
示例13: sqlQuerySelect
function sqlQuerySelect($sqlQuery)
{
$connect = sqlConnect();
$result = mysqli_query($connect, $sqlQuery);
$data = mysqli_fetch_all($result, MYSQLI_ASSOC);
mysqli_close($connect);
return $data;
}
示例14: db_select
function db_select($select_query)
{
global $conn;
$result = mysqli_query($conn, $select_query);
$assoc = mysqli_fetch_all($result, MYSQL_ASSOC);
//mysqli_free_result($result);
return $assoc;
}
示例15: allPosts
public static function allPosts()
{
$sql = "SELECT * FROM %s";
$query = sprintf($sql, self::$table);
$result = mysqli_query(self::connect(), $query);
$allPostsArr = mysqli_fetch_all($result, MYSQLI_ASSOC);
return $allPostsArr;
}