本文整理汇总了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;
}
示例2: fetch
/**
* Извлечение данных
*
* @return array|null
*/
protected function fetch()
{
if (!$this->isValidResult()) {
return null;
}
return $this->query_result->fetch_array($this->fetch_type);
}
示例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;
}
示例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];
}
示例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];
}
示例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;
}
}
示例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;
}
}
示例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;
}
示例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;
}
示例10: arow
function arow(&$data)
{
$data = $this->result->fetch_array(MYSQLI_ASSOC);
return !empty($data);
}
示例11: fetch_array
public function fetch_array(mysqli_result $r)
{
//return mysql_fetch_array($r);
return $r->fetch_array();
}
示例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);
}
示例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:
//.........这里部分代码省略.........
示例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);
}
示例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];
}