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


PHP mysqli_result::fetch_assoc方法代碼示例

本文整理匯總了PHP中mysqli_result::fetch_assoc方法的典型用法代碼示例。如果您正苦於以下問題:PHP mysqli_result::fetch_assoc方法的具體用法?PHP mysqli_result::fetch_assoc怎麽用?PHP mysqli_result::fetch_assoc使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在mysqli_result的用法示例。


在下文中一共展示了mysqli_result::fetch_assoc方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: fetch

 /**
  * @param mysqli_result $mysqli_result
  * @param bool $single
  * @return array|bool|null
  */
 public function fetch($mysqli_result, $single)
 {
     $this->_('fields', array());
     foreach ($mysqli_result->fetch_fields() as $field) {
         $this->_('fields')[$field->name] = $this->rules[$this->types[$field->type]];
     }
     switch (true) {
         case !$mysqli_result:
             return null;
         case $single && $mysqli_result->num_rows == 0:
             $result = false;
             break;
         case $single:
             $result = $this->cast($mysqli_result->fetch_assoc());
             break;
         case $mysqli_result->num_rows == 0:
             $result = array();
             break;
         default:
             $result = array();
             while ($row = $mysqli_result->fetch_assoc()) {
                 $result[] = $this->cast($row);
             }
     }
     $mysqli_result->free();
     return $result;
 }
開發者ID:enderteszla,項目名稱:phpframework-etc,代碼行數:32,代碼來源:Result.php

示例2: fetch

 /**
  * @return array|null
  */
 public function fetch()
 {
     if (is_bool($this->result)) {
         return $this->result;
     }
     return $this->result->fetch_assoc();
 }
開發者ID:onedaylabs,項目名稱:onedaylabs.com,代碼行數:10,代碼來源:MysqliStatement.php

示例3: fetch_accoc

 public function fetch_accoc()
 {
     while ($row = $this->resource_id->fetch_assoc()) {
         $this->result_array[] = $row;
     }
     return $this->result_array;
 }
開發者ID:popovdenis,項目名稱:lessons-1,代碼行數:7,代碼來源:DB.php

示例4: nextRecord

 public function nextRecord()
 {
     if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
         return $data;
     } else {
         return false;
     }
 }
開發者ID:congaaids,項目名稱:silverstripe-framework,代碼行數:8,代碼來源:MySQLQuery.php

示例5: fetchAll

 function fetchAll()
 {
     $data = array();
     while ($record = $this->result->fetch_assoc()) {
         $data[] = $record;
     }
     return $data;
 }
開發者ID:nosun,項目名稱:swoole,代碼行數:8,代碼來源:MysqliResult.php

示例6: fetch

 /**
  * @param Entity $entity
  * @return EntityManagerMysqli
  */
 protected function fetch(\mysqli_result $result, Entity $entity = null)
 {
     while ($data = $result->fetch_assoc()) {
         $this->add($entity->getClone()->serialize($data));
     }
     return $this;
 }
開發者ID:monokit,項目名稱:monokit,代碼行數:11,代碼來源:EntityManagerMysqli.php

示例7: currentHHVM

 /**
  * Returns the current row of a result set under HHVM
  * The problem was fetch_object creates new instance of a given class,
  * and attaches resulted key/value pairs after the class was constructed.
  *
  * @return  mixed
  */
 private function currentHHVM()
 {
     if ($this->_as_object === TRUE or is_string($this->_as_object)) {
         if ($this->_reflect_class === NULL) {
             // Create reflection class of given classname or stdClass
             $this->_reflect_class = new ReflectionClass(is_string($this->_as_object) ? $this->_as_object : 'stdClass');
         }
         // Support ORM with loaded, when the class has __set and __construct if its ORM
         if ($this->_reflect_class->hasMethod('__set') === TRUE && $this->_reflect_class->hasMethod('__construct') === TRUE) {
             // Get row as associated array
             $row = $this->_result->fetch_assoc();
             // Get new instance without constructing it
             $object = $this->_reflect_class->newInstanceWithoutConstructor();
             foreach ($row as $column => $value) {
                 // Trigger the class setter
                 $object->__set($column, $value);
             }
             // Construct the class with no parameters
             $object->__construct(NULL);
             return $object;
         } elseif (is_string($this->_as_object)) {
             // Return an object of given class name
             return $this->_result->fetch_object($this->_as_object, (array) $this->_object_params);
         } else {
             // Return an stdClass
             return $this->_result->fetch_object();
         }
     }
     // Get row as associated array
     return $this->_result->fetch_assoc();
 }
開發者ID:MenZil-Team,項目名稱:cms,代碼行數:38,代碼來源:Result.php

示例8: loadFromMysqliResult

 /**
  * Load from mysqli result
  *
  * @return bool
  */
 protected function loadFromMysqliResult()
 {
     $this->currentData = null;
     if (($data = $this->resource->fetch_assoc()) === null) {
         return false;
     }
     $this->position++;
     $this->currentData = $data;
     $this->currentComplete = true;
     $this->nextComplete = true;
     $this->position++;
     return true;
 }
開發者ID:musicsnap,項目名稱:Yaf.Global.Library,代碼行數:18,代碼來源:Result.php

示例9: loadDefaultData

function loadDefaultData($totalCount, mysqli_result $result)
{
    if ($totalCount == 0) {
        echo "暫無資訊";
        return;
    } else {
        if ($totalCount > 0) {
            $cnt = 0;
            while ($row = $result->fetch_assoc()) {
                if ($cnt < DEFAULT_SHOW) {
                    $list_id = $row["info_id"];
                    echo "<div class=\"list\">";
                    echo "<a href=\"" . $row["origin_link"] . "\" class=\"nav_list\" data-id={$list_id} onclick=\"count({$list_id})\">";
                    echo "<p class=\"caption\">";
                    echo $row["caption"];
                    echo "</p>";
                    echo "<p class=\"subhead\">";
                    echo $row["subhead"];
                    echo "</p>";
                    echo "<div class=\"footer\">";
                    echo "<span class=\"text_des\">";
                    echo $row["origin"];
                    echo "</span>";
                    echo "&nbsp";
                    echo "&nbsp";
                    echo "<span class=\"num_des\">";
                    echo substr($row["publish_date"], 5, 5);
                    echo "</span>";
                    echo "&nbsp";
                    echo "&nbsp";
                    echo "<div class=\"like\">";
                    echo "<img src=\"../images/grayheart.png\" class=\"icon\">";
                    echo "<span class=\"info_like\">";
                    echo showFavNum($row["fav"]);
                    echo "</span>";
                    echo "</div>";
                    echo "</div>";
                    echo "<img src=\"" . $row["pic_link"] . "\" class=\"show_pic\">";
                    echo "</a>";
                    echo "</div>";
                    echo "<hr/>";
                    $cnt++;
                } else {
                    break;
                    return;
                }
            }
        }
    }
}
開發者ID:pinkpoppy,項目名稱:fx,代碼行數:50,代碼來源:infomation.php

示例10: rowGenerator

 /**
  * @param \mysqli_result $result
  * @param $returnMode
  * @return \Generator
  */
 public function rowGenerator(\mysqli_result $result, $returnMode)
 {
     switch ($returnMode) {
         case self::RETURN_TYPE_ASSOC:
             (yield $result->fetch_assoc());
             break;
         case self::RETURN_TYPE_NUM:
             (yield $result->fetch_array(MYSQLI_NUM));
             break;
         case self::RETURN_TYPE_BOTH:
             (yield $result->fetch_array(MYSQLI_BOTH));
             break;
         case self::RETURN_TYPE_MYSQLI_ROW:
             (yield $result->fetch_row());
             break;
         case self::RETURN_TYPE_OBJ:
             (yield $result->fetch_object());
             break;
         default:
             (yield $result->fetch_assoc());
             break;
     }
 }
開發者ID:chilimatic,項目名稱:database-component,代碼行數:28,代碼來源:MySQLiConnectionAdapter.php

示例11: loadDefaultData

function loadDefaultData($totalCount, mysqli_result $result)
{
    if ($totalCount == 0) {
        return;
    } else {
        if ($totalCount > 0) {
            $cnt = 0;
            while ($row = $result->fetch_assoc()) {
                if ($cnt < DEFAULT_SHOW) {
                    $list_id = $row["info_id"];
                    echo "<div class=\"list\">";
                    echo "<a href=\"" . $row["origin_link"] . "\" class=\"e_wine_list\" data-id={$list_id} onclick=\"count({$list_id})\">";
                    echo "<p class=\"wine_caption\">";
                    echo $row["caption"];
                    echo "</p>";
                    echo "<p class='wine_subhead'>";
                    echo $row['subhead'];
                    echo "</p>";
                    echo "<div class=\"wine_footer\">";
                    echo "<span class=\"wine_orgin\">";
                    echo $row["origin"];
                    echo "</span>";
                    echo "&nbsp";
                    echo "&nbsp";
                    echo "<span class=\"wine_price\">";
                    echo $row["publish_date"];
                    echo "</span>";
                    echo "&nbsp";
                    echo "&nbsp";
                    echo "<div class=\"wine_fav\">";
                    echo "<img src=\"../images/grayheart.png\" class=\"icon\">";
                    echo "<span class=\"wine_fav_num\">";
                    echo showFavNum($row["fav"]);
                    echo "</span>";
                    echo "</div>";
                    echo "</div>";
                    echo "<img src=\"" . $row["pic_link"] . "\" class=\"wine_show_pic\">";
                    echo "</a>";
                    echo "</div>";
                    echo "<hr/>";
                    $cnt++;
                } else {
                    break;
                    return;
                }
            }
        }
    }
}
開發者ID:pinkpoppy,項目名稱:fx,代碼行數:49,代碼來源:ebusiness.php

示例12: loadMore

function loadMore($page, mysqli_result $result)
{
    $pos = 0;
    $cnt = 0;
    $arry = array();
    while ($row = $result->fetch_assoc()) {
        if ($pos != $page * DEFAULT_SHOW) {
            $pos++;
            continue;
        } else {
            if ($cnt < DEFAULT_SHOW) {
                array_push($arry, $row);
                $cnt++;
            } else {
                break;
                return;
            }
        }
    }
    return json_encode($arry, JSON_UNESCAPED_UNICODE);
}
開發者ID:pinkpoppy,項目名稱:fx,代碼行數:21,代碼來源:loadMoreInfomation.php

示例13: one

 /**
  * @inheritdoc
  */
 public function one()
 {
     return $this->result->fetch_assoc();
 }
開發者ID:miknatr,項目名稱:dbster,代碼行數:7,代碼來源:AdapterMysqliResult.php

示例14: fetch_assoc

 /**
  * @param mysqli_result $query_id
  * @return array|bool
  */
 public function fetch_assoc($query_id)
 {
     return $query_id ? $query_id->fetch_assoc() : false;
 }
開發者ID:tipsun91,項目名稱:punbb-mod,代碼行數:8,代碼來源:common_db.php

示例15: loadDefaultComments

function loadDefaultComments($totalCount, mysqli_result $res)
{
    if ($totalCount == 0) {
        return;
    } else {
        $cnt = 0;
        while ($row = $res->fetch_assoc()) {
            if ($cnt < DEFAULT_SHOW) {
                echo "<div class=\"conts\">";
                echo "<div class=\"user_bar\">";
                echo "<div class=\"user_info\">";
                echo "<img src=\"" . $row["head_pic"] . "\">";
                echo "<p class=\"uname\">";
                echo $row["nickname"];
                echo "</p>";
                echo "<p class=\"date_time\">";
                echo $row["create_time"];
                echo "</p>";
                echo "</div>";
                echo "</div>";
                echo "<div class=\"comment_info\">";
                echo "<p class=\"comment_cont\">";
                echo $row["comment_cont"];
                echo "</p>";
                echo "</div>";
                echo "</div>";
                echo "<hr/>";
                $cnt++;
            } else {
                break;
                return;
            }
        }
    }
}
開發者ID:pinkpoppy,項目名稱:fx,代碼行數:35,代碼來源:activityDetail.php


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