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


PHP mysqli_result::fetch_array方法代码示例

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


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

示例1: result

 public function result($a_type = null)
 {
     if (!$this->m_result or !$this->m_result instanceof mysqli_result) {
         return $this->m_result;
     }
     $r = array();
     do {
         $row = false;
         switch ($a_type) {
             default:
             case ZDatabase::RESULT_TYPE_NUM:
                 $row = $this->m_result->fetch_array(MYSQLI_NUM);
                 break;
             case ZDatabase::RESULT_TYPE_ASSOC:
                 $row = $this->m_result->fetch_array(MYSQLI_ASSOC);
                 break;
             case ZDatabase::RESULT_TYPE_BOTH:
                 $row = $this->m_result->fetch_array(MYSQLI_BOTH);
                 break;
             case ZDatabase::RESULT_TYPE_OBJECT:
                 $row = $this->m_result->fetch_object();
                 break;
             case ZDatabase::RESULT_TYPE_RAW:
                 return $this->m_result;
         }
         if (!$row) {
             break;
         }
         $r[] = $row;
     } while (1);
     return $r;
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:32,代码来源:mysqlidatabaseadapter.php

示例2: fetch

 /**
  * Извлечение данных
  *
  * @return array|null
  */
 protected function fetch()
 {
     if (!$this->isValidResult()) {
         return null;
     }
     return $this->query_result->fetch_array($this->fetch_type);
 }
开发者ID:white-bear,项目名称:php-db-layer,代码行数:12,代码来源:MysqliResult.php

示例3: result

 public function result($a_type = null, $a_arg = null)
 {
     if (!$this->m_result) {
         return $this->m_result;
     }
     if ($this->m_result->num_rows() === false) {
         return false;
     }
     $r = array();
     do {
         $row = false;
         switch ($a_type) {
             default:
             case Zoombi_Database::RESULT_TYPE_NUM:
                 $row = $this->m_result->fetch_array(MYSQLI_NUM);
                 break;
             case Zoombi_Database::RESULT_TYPE_ASSOC:
                 $row = $this->m_result->fetch_array(MYSQLI_ASSOC);
                 break;
             case Zoombi_Database::RESULT_TYPE_BOTH:
                 $row = $this->m_result->fetch_array(MYSQLI_BOTH);
                 break;
             case Zoombi_Database::RESULT_TYPE_OBJECT:
                 $row = func_num_args() > 1 ? $this->m_result->fetch_object(func_get_arg(1)) : $this->m_result->fetch_object();
                 break;
             case Zoombi_Database::RESULT_TYPE_RAW:
                 return $this->m_result;
         }
         if (!$row) {
             break;
         }
         $r[] = $row;
     } while (1);
     return $r;
 }
开发者ID:BGCX261,项目名称:zoombi-svn-to-git,代码行数:35,代码来源:mysqli.php

示例4: query_result

 /**
  * Get result data.
  * @param int The row number from the result that's being retrieved. Row numbers start at 0.
  * @param int The offset of the field being retrieved.
  * @return array|false The contents of one cell from a MySQL result set on success, or false on failure.
  */
 public function query_result($row, $field = 0)
 {
     if (0 == $this->result->num_rows) {
         return false;
     }
     $this->result->data_seek($row);
     $datarow = $this->result->fetch_array();
     return $datarow[$field];
 }
开发者ID:mpeshev,项目名称:wp-db-driver,代码行数:15,代码来源:mysqli.php

示例5: current

 /**
  * @see \Iterator::current()
  *
  * @return mixed
  * @throws \OutOfRangeException
  */
 public function current()
 {
     // Seems overkill to define our own OutOfRangeException. Use default in this case
     if ($this->_pointer > $this->_numberOfRows - 1) {
         throw new \OutOfRangeException('Attempting to access a row that is outside of the number of rows in this result.');
     }
     $pointer = $this->_pointer;
     if (!array_key_exists($this->_pointer, $this->_mysqlResult)) {
         $this->_mysqlResult[$this->_pointer] = $this->_result->fetch_array(\MYSQLI_ASSOC);
         $this->_pointer++;
         $this->_moveToNextRow = true;
         $this->_processedRows++;
         // Free up results when there is no more row to process
         if ($this->_processedRows === $this->_numberOfRows) {
             $this->_result->free();
         }
     }
     return $this->_mysqlResult[$pointer];
 }
开发者ID:jayzeng,项目名称:dao,代码行数:25,代码来源:Result.php

示例6: get_record

 /**
  * Obtenemos un elemento del resultado.
  * @param int $type Tipo de retorno de los valores.
  * @param int|array $cast Cast a aplicar a los elementos.
  * @return mixed
  * @author Ignacio Daniel Rostagno <ignaciorostagno@vijona.com.ar>
  */
 public function get_record($type = Database_Query::FETCH_ASSOC, $cast = NULL)
 {
     // $this->next();
     switch ($type) {
         case Database_Query::FETCH_NUM:
             // Obtenemos el arreglo.
             $resultado = $this->query->fetch_array(MYSQLI_NUM);
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_array($resultado)) {
                 return $resultado;
             }
             // Expandimos listado de cast.
             $cast = $this->expand_cast_list($cast, count($resultado));
             // Realizamos el cast.
             $c = count($resultado);
             for ($i = 0; $i < $c; $i++) {
                 $resultado[$i] = $this->cast_field($resultado[$i], $cast[$i]);
             }
             return $resultado;
         case Database_Query::FETCH_OBJ:
             // Obtenemos el objeto.
             $object = $this->query->fetch_object();
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_object($object)) {
                 return $object;
             }
             // Expandimos la lista de cast.
             $cast = $this->expand_cast_list($cast, array_keys(get_object_vars($object)));
             // Realizamos el cast.
             foreach ($cast as $k => $v) {
                 $object->{$k} = $this->cast_field($object->{$k}, $v);
             }
             return $object;
         case Database_Query::FETCH_ASSOC:
         default:
             // Obtenemos el arreglo.
             $resultado = $this->query->fetch_array(MYSQLI_ASSOC);
             // Evitamos cast de consultas erroneas o vacias.
             if (!is_array($resultado)) {
                 return $resultado;
             }
             // Expandimos la lista de cast.
             $cast = $this->expand_cast_list($cast, array_keys($resultado));
             // Realizamos el cast.
             foreach ($cast as $k => $v) {
                 $resultado[$k] = $this->cast_field($resultado[$k], $v);
             }
             return $resultado;
     }
 }
开发者ID:4bs4,项目名称:marifa,代码行数:57,代码来源:query.php

示例7: 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

示例8: fetch

 public function fetch()
 {
     if (!$this->_cursor) {
         return null;
     }
     $res = array();
     if (method_exists('mysqli_result', 'fetch_all')) {
         $res = $this->_cursor->fetch_all(MYSQL_ASSOC);
     } else {
         while ($tmp = $this->_cursor->fetch_array(MYSQL_ASSOC)) {
             $res[] = $tmp;
         }
     }
     return $res;
 }
开发者ID:ravikathaitarm01,项目名称:fluenz1,代码行数:15,代码来源:MySqli.php

示例9: next

 /**
  * Implementation of the next() method.
  *
  * @return array|null The next row in the resultset or null if there are no
  * more results.
  */
 public function next()
 {
     if (is_null($this->_result)) {
         $this->rewind();
     }
     if ($this->_result) {
         $row = $this->_result->fetch_array(MYSQLI_BOTH);
         if (!$row) {
             $this->_eof = true;
         } else {
             $this->_eof = false;
             if (is_null($this->_index)) {
                 $this->_index = 0;
             } else {
                 ++$this->_index;
             }
             $this->_current = $row;
         }
     }
     return $this->_current;
 }
开发者ID:lerre,项目名称:framework,代码行数:27,代码来源:Result.php

示例10: arow

 function arow(&$data)
 {
     $data = $this->result->fetch_array(MYSQLI_ASSOC);
     return !empty($data);
 }
开发者ID:laiello,项目名称:pkgmanager,代码行数:5,代码来源:mysqli_result.class.php

示例11: fetch_array

 public function fetch_array(mysqli_result $r)
 {
     //return mysql_fetch_array($r);
     return $r->fetch_array();
 }
开发者ID:stefda,项目名称:pocketsail,代码行数:5,代码来源:CL_MySQL.back.php

示例12: fetch_array

 /**
  * @param mysqli_result $result
  * @param int $mode
  * @return mixed
  */
 public function fetch_array($result, $mode = self::RESULT_NUM)
 {
     return $result->fetch_array($mode);
 }
开发者ID:Lazary,项目名称:webasyst,代码行数:9,代码来源:waDbMysqliAdapter.class.php

示例13: getAll

 /**
  * Returns the values of all rows.
  * CAUTION: resets the result pointer.
  * 
  * {@internal Mind the performance: not ifs in while loop}}
  * 
  * @param  int      $resulttype  A DB_Result::FETCH::% constant
  * @param  boolean  $map         Add mapping for roles   
  * @return array
  */
 function getAll($resulttype = DB::FETCH_ORDERED)
 {
     if ($resulttype == DB::FETCH_VALUE) {
         return $this->getColumn();
     }
     $key_field = $this->getFieldIndex('result:key');
     $rows = array();
     $this->native->data_seek(0);
     $opt = $resulttype & ~0xff;
     if (isset($key_field)) {
         switch ($resulttype & 0xff) {
             case DB::FETCH_ORDERED:
                 while ($row = $this->native->fetch_row()) {
                     $rows[$row[$key_field]] = $row;
                 }
                 break;
             case DB::FETCH_ASSOC:
                 while ($row = $this->native->fetch_assoc()) {
                     $rows[$row['result:key']] = $row;
                 }
                 break;
             case DB::FETCH_FULLARRAY:
                 while ($row = $this->native->fetch_array()) {
                     $rows[$row[$key_field]] = $row;
                 }
                 break;
             case DB::FETCH_OBJECT:
                 while ($row = $this->native->fetch_object()) {
                     $rows[$row->{'result:key'}] = $row;
                 }
                 break;
             default:
                 while ($row = $this->fetchRow($resulttype)) {
                     $rows[] = $row;
                 }
                 if (!empty($rows)) {
                     $rows = array_combine($this->getColumn($key_field), $rows);
                 }
                 break;
         }
     } else {
         switch ($resulttype & 0xff) {
             case DB::FETCH_ORDERED:
                 if (function_exists('mysqli_fetch_all')) {
                     $rows = $this->native->fetch_all(MYSQLI_NUM);
                 } else {
                     while ($row = $this->native->fetch_row()) {
                         $rows[] = $row;
                     }
                 }
                 break;
             case DB::FETCH_ASSOC:
                 if (function_exists('mysqli_fetch_all')) {
                     $rows = $this->native->fetch_all(MYSQLI_ASSOC);
                 } else {
                     while ($row = $this->native->fetch_assoc()) {
                         $rows[] = $row;
                     }
                 }
                 break;
             case DB::FETCH_OBJECT:
                 while ($row = $this->native->fetch_object()) {
                     $rows[] = $row;
                 }
                 break;
             case DB::FETCH_FULLARRAY:
                 if (function_exists('mysqli_fetch_all')) {
                     $rows = $this->native->fetch_all(MYSQLI_BOTH);
                 } else {
                     while ($row = $this->native->fetch_array()) {
                         $rows[] = $row;
                     }
                 }
                 break;
             case DB::FETCH_PERTABLE:
                 while ($row = $this->fetchPerTable($opt)) {
                     $rows[] = $row;
                 }
                 break;
             case DB::FETCH_VALUE:
                 while ($row = $this->fetchValue(0, $opt)) {
                     $rows[] = $row;
                 }
                 break;
             case DB::FETCH_RECORD:
                 while ($row = $this->fetchRecord($opt)) {
                     $rows[] = $row;
                 }
                 break;
             case DB::FETCH_ROLES:
//.........这里部分代码省略.........
开发者ID:jasny,项目名称:Q,代码行数:101,代码来源:Result.php

示例14: fetchArray

 /**
  * Returns array with numerical and string keys of the current row or null if no more rows are in the result
  * @param integer $type type of returned array
  * @return array|null
  */
 public function fetchArray($type = self::BOTH)
 {
     return $this->dbResult->fetch_array($type);
 }
开发者ID:prepare4battle,项目名称:Ilch-2.0,代码行数:9,代码来源:Result.php

示例15: fetchColumn

 /**
  * @param integer $column
  * @throws Recipe_Exception_Sql
  * @return mixed
  */
 public function fetchColumn($column = 0)
 {
     $data = $this->result->fetch_array(MYSQLI_NUM);
     return $data[$column];
 }
开发者ID:enriquesomolinos,项目名称:Bengine,代码行数:10,代码来源:MySQLi.php


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