當前位置: 首頁>>代碼示例>>PHP>>正文


PHP mysqli_fetch_all函數代碼示例

本文整理匯總了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 />&nbsp;數組下標為{$i}的語句:{$arr_sqls[$i]}執行錯誤<br />&nbsp;錯誤原因:" . mysqli_error($link);
            return false;
        }
    } else {
        $error = '執行失敗!請檢查首條語句是否正確!<br />可能的錯誤原因:' . mysqli_error($link);
        return false;
    }
}
開發者ID:sakuraliu,項目名稱:bbs,代碼行數:30,代碼來源:mysql.inc.php

示例2: getResults

 public function getResults($sSQL)
 {
     $oQuery = mysqli_query($this->_connection, $sSQL);
     if ($oQuery) {
         return mysqli_fetch_all($oQuery, MYSQLI_ASSOC);
     }
     return false;
 }
開發者ID:ghtmh,項目名稱:haushaltsplan,代碼行數:8,代碼來源:database.class.php

示例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 
    }
}
開發者ID:Garik917,項目名稱:magazine,代碼行數:35,代碼來源:main_page.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;
}
開發者ID:arielse,項目名稱:Sunnyspot,代碼行數:7,代碼來源:admin_menu.php

示例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();*/
}
開發者ID:kochevRisto,項目名稱:project,代碼行數:25,代碼來源:ajax-callbacks.php

示例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;
     }
 }
開發者ID:wharin,項目名稱:quantum,代碼行數:30,代碼來源:mysql_i.php

示例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);
}
開發者ID:GuillaumeCa,項目名稱:not-a-website,代碼行數:33,代碼來源:Messages.php

示例8: getAllAssoc

 public function getAllAssoc($sql)
 {
     $queryRes = $this->query($sql);
     $res = mysqli_fetch_all($queryRes, MYSQLI_ASSOC);
     if (!empty($res)) {
         return $res;
     }
 }
開發者ID:19eugen86,項目名稱:schedro.extjs,代碼行數:8,代碼來源:database.class.php

示例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);
}
開發者ID:velsharoon,項目名稱:advanced_scripting_2,代碼行數:8,代碼來源:handler.php

示例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);
}
開發者ID:jukhadar,項目名稱:web-scripting,代碼行數:8,代碼來源:handler.php

示例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;
}
開發者ID:AndraWP,項目名稱:18213003-18213004,代碼行數:8,代碼來源:event-api.php

示例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);
 }
開發者ID:Balfin,項目名稱:tfi,代碼行數:8,代碼來源:Film.php

示例13: sqlQuerySelect

function sqlQuerySelect($sqlQuery)
{
    $connect = sqlConnect();
    $result = mysqli_query($connect, $sqlQuery);
    $data = mysqli_fetch_all($result, MYSQLI_ASSOC);
    mysqli_close($connect);
    return $data;
}
開發者ID:RMMusic,項目名稱:DB_in_Form_PHP,代碼行數:8,代碼來源:functions.php

示例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;
}
開發者ID:hoangdongtien,項目名稱:eprojectmate,代碼行數:8,代碼來源:database.php

示例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;
 }
開發者ID:vosaan,項目名稱:blog.local,代碼行數:8,代碼來源:db_conn.php


注:本文中的mysqli_fetch_all函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。