当前位置: 首页>>代码示例>>PHP>>正文


PHP resource::fetch_assoc方法代码示例

本文整理汇总了PHP中resource::fetch_assoc方法的典型用法代码示例。如果您正苦于以下问题:PHP resource::fetch_assoc方法的具体用法?PHP resource::fetch_assoc怎么用?PHP resource::fetch_assoc使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在resource的用法示例。


在下文中一共展示了resource::fetch_assoc方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getNextRow

 /**
  * Internal method to fetch the next row from the result set
  *
  * @return array|null
  */
 protected function getNextRow()
 {
     # If the result resource is invalid then don't bother trying to fetch
     if (!$this->result) {
         return;
     }
     switch ($this->mode) {
         case "mysql":
             $row = $this->result->fetch_assoc();
             break;
         case "postgres":
         case "redshift":
             $row = pg_fetch_assoc($this->result);
             break;
         case "odbc":
             $row = odbc_fetch_array($this->result, $this->position + 1);
             break;
         case "sqlite":
             $row = $this->result->fetchArray(SQLITE3_ASSOC);
             break;
         case "mssql":
             $row = mssql_fetch_assoc($this->result);
             break;
     }
     # If the fetch fails then there are no rows left to retrieve
     if (!$row) {
         return;
     }
     $this->position++;
     return $row;
 }
开发者ID:ian-Tr,项目名称:le-huard,代码行数:36,代码来源:Result.php

示例2: nextRecord

 /**
  * {@inheritdoc}
  */
 public function nextRecord()
 {
     if (is_object($this->handle) && ($data = $this->handle->fetch_assoc())) {
         return $data;
     } else {
         return false;
     }
 }
开发者ID:jakedaleweb,项目名称:AtomCodeChallenge,代码行数:11,代码来源:MySQLQuery.php

示例3: nextRecord

 /**
  * Get the nextRecord from the query.
  * @param string $result_type
  * @return resource 
  */
 public function nextRecord($result_type = "both")
 {
     if (!$this->query_id) {
         $this->halt("next_record() called with no pending query.");
         return false;
     }
     if ($this->db_type == "mysqli") {
         switch ($result_type) {
             case "assoc":
                 $this->record = $this->query_id->fetch_assoc();
                 break;
             case "num":
                 $this->record = $this->query_id->fetch_fetch_row();
                 break;
             case "both":
                 $this->record = $this->query_id->fetch_array();
                 break;
         }
     } else {
         if ($this->db_type == "mysql") {
             switch ($result_type) {
                 case "assoc":
                     $this->record = mysql_fetch_assoc($this->query_id);
                     break;
                 case "num":
                     $this->record = mysql_fetch_row($this->query_id);
                     break;
                 case "both":
                     $this->record = mysql_fetch_array($this->query_id);
                     break;
             }
         }
     }
     if ($this->db_type == "mysqli") {
         $this->errno = $this->link_id->errno;
         $this->error = $this->link_id->error;
     } else {
         if ($this->db_type == "mysql") {
             $this->errno = mysql_errno($this->link_id);
             $this->error = mysql_error($this->link_id);
         }
     }
     $status = is_array($this->record);
     if (!$status && $this->auto_free) {
         $this->freeResult();
     }
     return $status;
 }
开发者ID:thefkboss,项目名称:openTracker,代码行数:53,代码来源:DB.php

示例4:

 /**
  * Fetch a result row as an associative array.
  *
  * @param resource $query
  *   The result resource that is being evaluated. This result comes from a call to mysql_query().
  * @return array
  *   Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
  */
 function fetch_assoc($query)
 {
     if ($query instanceof mysqli_result) {
         return $query->fetch_assoc();
     }
     return FALSE;
 }
开发者ID:GavinLai,项目名称:SimMatch,代码行数:15,代码来源:class.DbMysqli.php

示例5: fetch_assoc

 /**
  * Gets an associative array from a SQL result (as returned by Database::query).
  * This method is equivalent to calling Database::fetch_array() with 'ASSOC' value for the optional second parameter.
  * @param resource $result	The result from a call to sql_query (e.g. Database::query).
  * @return array			Returns an associative array that corresponds to the fetched row and moves the internal data pointer ahead.
  */
 public static function fetch_assoc($result)
 {
     return $result->fetch_assoc();
 }
开发者ID:annickvdp,项目名称:Chamilo1.9.10,代码行数:10,代码来源:database.mysqli.lib.php

示例6: fetchData

 /**
  * Fetches a record from the database using the given result resource.
  *
  * @param resource $resultCursor The result resource returned by executeStatement() or executeTextStatement().
  * @param int $type The type the returned data should have. Use the static *_FETCH_MODE constants.
  *
  * @return string[] The associative result array. Returns false if no row was found.
  *
  * @author Christian Achatz
  * @version
  * Version 0.1, 09.03.2010<br />
  * Version 0.2, 30.07.2010 (Changed return value to false if no row was found, in order to follow the interface definition)<br />
  * Version 0.3, 08.08.2010 (Added optional second parameter) <br />
  */
 public function fetchData($resultCursor, $type = self::ASSOC_FETCH_MODE)
 {
     if ($resultCursor == null) {
         return false;
     }
     if ($type === self::ASSOC_FETCH_MODE) {
         $return = $resultCursor->fetch_assoc();
     } elseif ($type === self::OBJECT_FETCH_MODE) {
         $return = $resultCursor->fetch_object();
     } else {
         $return = $resultCursor->fetch_row();
     }
     if ($return === null) {
         return false;
     }
     return $return;
 }
开发者ID:GeneralCrime,项目名称:code,代码行数:31,代码来源:MySQLiHandler.php

示例7: _fetch

 /**
  * Fetch an array from a database result set
  * 
  * @param resource $res
  * @return array
  */
 protected function _fetch($res)
 {
     return $res->fetch_assoc();
     // $res->fetch_assoc();
 }
开发者ID:djeraseit,项目名称:quickbooks-php,代码行数:11,代码来源:Mysqli.php

示例8: nextRow

 /**
  * Return reference to next row in result set.
  * @param mysqli_result|resource|PDOStatement $result
  * @return array
  */
 public function nextRow($result)
 {
     return $result->fetch_assoc();
 }
开发者ID:manishkhanchandani,项目名称:mkgxy,代码行数:9,代码来源:LudoDBMySqlI.php

示例9: fetchAll

 /**
  * 针对query和execute的结果,进行数组话输出
  *
  * 仅对select查询有效
  *
  * @param resource $result
  *
  * @return array
  */
 public function fetchAll($result)
 {
     $ret = array();
     while ($row = $result->fetch_assoc()) {
         $ret[] = $row;
     }
     return $ret;
 }
开发者ID:lanma121,项目名称:superPrize,代码行数:17,代码来源:DBIns.php

示例10: setResult

 /**
  * The result set setter
  * 
  * @access public
  * @param resource $rs A valid MySQLi result resource identifier
  */
 public function setResult($rs = false)
 {
     // A result identifier is a must have
     if (empty($rs)) {
         return false;
     }
     // Get multiple result sets from the MySQL query result if we can
     $recordSet = array();
     while ($row = $rs->fetch_assoc()) {
         $recordSet[] = $row;
     }
     // Add the record sets into the result set
     $this->_resultSet[] = $recordSet;
 }
开发者ID:fniftaly,项目名称:Java-Selenium,代码行数:20,代码来源:Queryresult.php

示例11: fetch

 /**
  * Devolvemos el array con los datos de la consulta
  * @param string $field Campo objetivo.
  * @param string $default Valor a retornar si el campo no existe o está vacío.
  * @return array|string Todos los campos o sólo uno
  */
 public function fetch($field = null, $default = null)
 {
     $this->result = $this->data->fetch_assoc();
     if ($field !== null) {
         return isset($this->result[$field]) ? $this->result[$field] : $default;
     } else {
         return $this->result;
     }
 }
开发者ID:areslepra,项目名称:Framework,代码行数:15,代码来源:class.littledb.php


注:本文中的resource::fetch_assoc方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。