本文整理汇总了PHP中mysqli_result::fetch_row方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result::fetch_row方法的具体用法?PHP mysqli_result::fetch_row怎么用?PHP mysqli_result::fetch_row使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_result
的用法示例。
在下文中一共展示了mysqli_result::fetch_row方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: toNextRow
/**
* Moves the cursor to the next row
*
* @return static $this
* @throws ResultSetException If the next row does not exist
*/
public function toNextRow()
{
if (!$this->hasNextRow()) {
throw new ResultSetException('The next row does not exist.');
}
if ($this->current_row === null) {
$this->current_row = 0;
} else {
$this->current_row++;
}
$this->fetched = $this->result->fetch_row();
return $this;
}
示例2: 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;
}
}
示例3: fetchRow
/**
* @param \mysqli_result $result
* @return array|null
*/
public function fetchRow($result)
{
return $result->fetch_row();
}
示例4: fetch_row
/**
* @param mysqli_result $query_id
* @return array|bool
*/
public function fetch_row($query_id)
{
return $query_id ? $query_id->fetch_row() : false;
}
示例5: fetchLastRow
public function fetchLastRow()
{
$this->result->data_seek($this->getNumRows() - 1);
return $this->result->fetch_row();
}
示例6: createArray
/**
* Purpose: Creates an associative array to be used with the HtmlForm
* class' methods that populate lists.
* @param mysqli_result $qryResults The query result record set. The
* result should consist of two columns: the first column will contain
* an ID, and second will contain corresponding text.
* @return array Associative array, where the array index comes from
* the qryResults' first column, and the array value comes from the
* qryResults' second column.
*/
public static function createArray($qryResults)
{
// Create an empty result array
$result = array();
// Loop through all rows in the result set
while ($row = $qryResults->fetch_row()) {
// Set an entry in the result set with the index as the first
// column in the result set, and the value as the second column
$result[$row[0]] = $row[1];
}
// Return the result array
return $result;
}
示例7: 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:
//.........这里部分代码省略.........
示例8: fetch_row
public function fetch_row()
{
return $this->resource_id->fetch_row();
}
示例9: getRowArrays
/**
* Get all fields of all records in one single non-associative array
* It's basically all values available concatened in a single array
* @param mysqli_result $result
* @return array empty array if no result
*/
public function getRowArrays(mysqli_result $result = null)
{
$arrayFromResultSet = array();
if ($result != null) {
while ($row = $result->fetch_row()) {
foreach ($row as $value) {
$arrayFromResultSet[] = stripcslashes($value);
}
}
}
return $arrayFromResultSet;
}
示例10: enum
/**
* Returns the next available row as an enumerated array
* while ($row = $result->enum()) { echo $row[0]; }
* @return array
*/
public function enum()
{
return $this->result->fetch_row();
}
示例11: fetch_row
/**
* Fetch the current row as enumerated array
*
* @return array The row as array
*/
protected function fetch_row()
{
return $this->resResult->fetch_row();
}
示例12: result
/**
* @param $res mysqli_result
* @return mixed
*/
public static function result(mysqli_result $res)
{
$row = $res->fetch_row();
return $row[0];
}
示例13: dbResult
/**
* Returns the contents of one cell from a MySQL result set
*
* @param mysqli_result $recordSet The recordset to operate on
* @param int $row row to get data from
* @param mixed $field field to return
* @return mixed (depends on field content)
*/
public function dbResult($recordSet, $row, $field = 0)
{
if ($this->_verbose) {
$this->_errorlog("\n*** Inside database->dbResult ***");
if (empty($recordSet)) {
$this->_errorlog("\n*** Passed recordset isn't valid ***");
} else {
$this->_errorlog("\n*** Everything looks good ***");
}
$this->_errorlog("\n*** Leaving database->dbResult ***");
}
$retval = '';
if ($recordSet->data_seek($row)) {
if (is_numeric($field)) {
$field = intval($field, 10);
$row = $recordSet->fetch_row();
} else {
$row = $recordSet->fetch_assoc();
}
if ($row !== null && isset($row[$field])) {
$retval = $row[$field];
}
}
return $retval;
}
示例14: _fetchFieldList
/**
* Fetch an array of single field results
*
*
* @param mysqli_result $result The result object. A result set identifier returned by the select() function
* @param integer $key The index to use
* @return array A sequential array of returned rows.
*/
protected function _fetchFieldList($result, $key = 0)
{
$array = array();
while ($row = $result->fetch_row()) {
$array[] = $row[(int) $key];
}
$result->free();
return $array;
}
示例15:
<?php
require_once "connect.inc";
$mysql = new my_mysqli($host, $user, $passwd, $db, $port, $socket);
$mysql->real_query("SELECT 'foo' FROM test_062_table_1");
$myresult = new mysqli_result($mysql);
$row = $myresult->fetch_row();
$myresult->close();
$mysql->close();
var_dump($row);
print "done!";