当前位置: 首页>>代码示例>>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;未经允许,请勿转载。