MongoCursor
在线手册:中文 英文
PHP手册

MongoCursor::doQuery

(No version information available, might only be in SVN)

MongoCursor::doQueryExecute the query.

说明

protected void MongoCursor::doQuery ( void )

This function actually queries the database. All queries and commands go through this function. Thus, this function can be overridden to provide custom query handling.

This handles serializing your query, sending it to the database, receiving a response, and deserializing it. Thus, if you are planning to override this, your code should probably call out to the original to use the existing functionality (see the example below).

参数

此函数没有参数。

返回值

NULL.

错误/异常

Throws MongoConnectionException if it cannot reach the database.

范例

Example #1 MongoCursor::doQuery() example

You could override this function to attempt a query on a slave and, if that fails, try it again on the master.

<?php

class MyCursor extends MongoCursor {

    protected function 
doQuery() {

        
$this->slaveOkay();

        try {
            
MongoCursor::doQuery();
        }
        catch(
MongoCursorException $e) {
            
$this->slaveOkay(false);
            
MongoCursor::doQuery();
        }
    }
}

?>


MongoCursor
在线手册:中文 英文
PHP手册
PHP手册 - N: Execute the query.

用户评论:

nodkz at mail.ru (13-Sep-2011 04:27)

Does not work for MongoDB Native Driver Version 1.1.0 (version may be seen via phpinfo())