MongoCommandCursor::rewind

(PECL mongo >=1.5.0)

MongoCommandCursor::rewindExecutes the command and resets the cursor to the start of the result set

说明

public MongoCommandCursor::rewind ( void ) : array

If the cursor has already started iteration, the command will be re-executed.

参数

此函数没有参数。

返回值

The raw server result document.

错误/异常

Throws MongoConnectionException if it cannot reach the database and MongoCursorTimeoutException if the timeout is exceeded.

Throws MongoCursorException if the cursor was created with MongoCommandCursor::createFromDocument() and has already started iteration. Such cursors cannot be iterated multiple times, as they lack the original command necessary for re-execution.

范例

Example #1 MongoCommandCursor::rewind()

<?php
$rawResult 
$commandCursor->rewind();

// Command cursor is now reset to the start of the result set

var_dump($rawResult);
?>

以上例程的输出类似于:

array(2) {
  ["cursor"]=>
  array(3) {
    ["id"]=>
    object(MongoInt64)#5 (1) {
      ["value"]=>
      string(12) "310050110216"
    }
    ["ns"]=>
    string(9) "demo.test"
    ["firstBatch"]=>
    array(1) {
      [0]=>
      array(2) {
        ["_id"]=>
        object(MongoId)#6 (1) {
          ["$id"]=>
          string(24) "52f5691544670a8077b0dc51"
        }
        ["value"]=>
        string(2) "42"
      }
    }
  }
  ["ok"]=>
  float(1)
}

参见

相关文章
php cubrid mysql 兼容性函数 move the result set cursor to the specified field offsetphp ibm db2 函数 returns the data type of the indicated column in a result setphp ibm db2 函数 returns a result set listing the stored procedures registered in a databasephp 多字节字符串 函数 set start point of next regular expression matchphp postgresql 函数 submits a command to the server and waits for the result with the ability to pass parameters separately from the sql command textphp sqlite 函数 executes a result less query against a given databasephp mongocommandcursor create a new command cursorphp mongocommandcursor create a new command cursor from an existing command response documentphp mongocommandcursor returns the current result s index within the result setphp mongocommandcursor advances the cursor to the next resultphp mongocommandcursor executes the command and resets the cursor to the start of the result setphp mongocommandcursor set the read preference for this commandphp mongocommandcursor checks if the cursor is reading a valid resultphp mongocursor returns the cursor to the beginning of the result setphp mysqli result returns the next field in the result setphp mysqli result returns an array of objects representing the fields in a result setphp mysqli stmt seeks to an arbitrary row in statement result setphp sqlite3result returns the number of columns in the result setphp sqlite3result resets the result set back to the first rowphp sqlite3stmt executes a prepared statement and returns a result set object
关注编程学问公众号