略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: MongoCursor::doQuery

2024-11-12

MongoCursor::doQuery

(PECL mongo >=0.9.0 <1.6.0)

MongoCursor::doQueryExecute the query

说明

protected MongoCursor::doQuery ( void ) : void
Warning

Please do not use me.

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.

更新日志

版本 说明
1.2.11 Emits E_DEPRECATED when used.

范例

Example #1 MongoCursor::doQuery() example

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

<?php

class MyCursor extends MongoCursor {

    protected function 
doQuery() {

        
$this->slaveOkay();

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

?>
add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/mongocursor.doquery.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3