本文整理汇总了PHP中mysqli_result::data_seek方法的典型用法代码示例。如果您正苦于以下问题:PHP mysqli_result::data_seek方法的具体用法?PHP mysqli_result::data_seek怎么用?PHP mysqli_result::data_seek使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mysqli_result
的用法示例。
在下文中一共展示了mysqli_result::data_seek方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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];
}
示例2: seek
/**
* Seek the arbitrary pointer in table
*
* @param integer $offset The field offset. Must be between zero and the total number of rows minus one
*
* @return boolean
*/
public function seek($offset)
{
if ($this->offsetExists($offset) and $this->_result->data_seek($offset)) {
// Set the current row to the offset
$this->_current_row = $this->_internal_row = $offset;
return TRUE;
}
return FALSE;
}
示例3: result
/**
* @param mysqli_result $query_id
* @param int $row
* @return bool
*/
public function result($query_id, $row = 0)
{
if ($query_id && $query_id->num_rows) {
$query_id->data_seek($row);
$result = $query_id->fetch_row();
return $result[0];
}
return false;
}
示例4: toRow
/**
* Moves the cursor to the selected row
*
* @param int $num The number of the row to move the cursor to
* @return static
* @throws ResultSetException If the row does not exist
*/
public function toRow($num)
{
if (!$this->hasRow($num)) {
throw new ResultSetException('The row does not exist.');
}
$this->current_row = $num;
$this->result->data_seek($num);
$this->fetched = $this->result->fetch_row();
return $this;
}
示例5: rewind
/**
* Rewind
*
*/
public function rewind()
{
$this->currentComplete = false;
$this->position = 0;
if ($this->resource instanceof \mysqli_stmt) {
//$this->resource->reset();
} else {
$this->resource->data_seek(0);
// works for both mysqli_result & mysqli_stmt
}
}
示例6: rewind
/**
* Rewind
*/
public function rewind()
{
if ($this->position !== 0) {
if ($this->isBuffered === false) {
throw new Exception\RuntimeException('Unbuffered results cannot be rewound for multiple iterations');
}
}
$this->resource->data_seek(0); // works for both mysqli_result & mysqli_stmt
$this->currentComplete = false;
$this->position = 0;
}
示例7: data_seek
/**
* Navigate to a certain row in the result set
*
* @param integer $intIndex The row index
*
* @throws \OutOfBoundsException If $intIndex is out of bounds
*/
protected function data_seek($intIndex)
{
if ($intIndex < 0) {
throw new \OutOfBoundsException("Invalid index {$intIndex} (must be >= 0)");
}
$intTotal = $this->num_rows();
if ($intTotal <= 0) {
return;
// see #6319
}
if ($intIndex >= $intTotal) {
throw new \OutOfBoundsException("Invalid index {$intIndex} (only {$intTotal} rows in the result set)");
}
$this->resResult->data_seek($intIndex);
}
示例8: fetchLastRow
public function fetchLastRow()
{
$this->result->data_seek($this->getNumRows() - 1);
return $this->result->fetch_row();
}
示例9: rewind
/**
* @param \mysqli_result $result
* @return mixed
*/
public function rewind($result)
{
return $result->num_rows > 0 ? $result->data_seek(0) : false;
}
示例10: 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;
}
示例11: printf
<?php
require_once "connect.inc";
$tmp = NULL;
$link = NULL;
require 'table.inc';
if (!($mysqli = new mysqli($host, $user, $passwd, $db, $port, $socket))) {
printf("[001] Cannot connect to the server using host=%s, user=%s, passwd=***, dbname=%s, port=%s, socket=%s\n", $host, $user, $db, $port, $socket);
}
$res = new mysqli_result($mysqli);
if (NULL !== ($tmp = @$res->data_seek(0))) {
printf("[002] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (!($res = $mysqli->query('SELECT * FROM test ORDER BY id LIMIT 4', MYSQLI_STORE_RESULT))) {
printf("[003] [%d] %s\n", mysqli_errno($link), mysqli_error($link));
}
if (NULL !== ($tmp = @$res->data_seek())) {
printf("[004] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (NULL !== ($tmp = @$res->data_seek($link))) {
printf("[005] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (NULL !== ($tmp = @$res->data_seek($link, $link))) {
printf("[006] Expecting NULL/NULL, got %s/%s\n", gettype($tmp), $tmp);
}
if (true !== ($tmp = $res->data_seek(3))) {
printf("[007] Expecting boolean/true, got %s/%s\n", gettype($tmp), $tmp);
}
$row = $res->fetch_assoc();
if (4 != $row['id']) {
printf("[008] Expecting record 4/d, got record %s/%s\n", $row['id'], $row['label']);
示例12: seek
public function seek($row)
{
if (is_object($this->handle)) {
return $this->handle->data_seek($row);
}
}
示例13: data_seek
/**
* @param mysqli_result $result
* @param int $offset
* @return mixed
*/
public function data_seek($result, $offset)
{
return $result->data_seek($offset);
}
示例14: mysqlDataSeek
/**
* @param mysqli_result|ResultWrapper $res
* @param int $row
* @return bool
*/
protected function mysqlDataSeek($res, $row)
{
return $res->data_seek($row);
}
示例15: 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:
//.........这里部分代码省略.........