public function lastError($db, $cb, $params = [], $conn = null)
    {
        $e = explode('.', $db, 2);
        $params['getlasterror'] = 1;
        $cb = CallbackWrapper::wrap($cb);
        try {
            $this->request(
                self::OP_QUERY,
                pack('V', 0) . $e[0] . '.$cmd' . "\x00"
                . pack('VV', 0, -1) . bson_encode($params),
                true,
                $conn,
                function ($conn, $reqId = null) use ($db, $cb) {
                    if (!$conn) {
                        !$cb || $cb(['$err' => 'Connection error.']);
                        return;
                    }
                    $conn->requests[$reqId] = [$db, $cb, true];
                }
            );
        } catch (\MongoException $e) {
            Daemon::log('MongoClient exception: ' . $e->getMessage() . ': ' . $e->getTraceAsString());
            if ($cb !== null) {
                $cb(['$err' => $e->getMessage()]);
            }
        }
    }
public function lastError($db, $cb, $params = [], $conn = null)
    {
        $e = explode('.', $db, 2);
        $params['getlasterror'] = 1;
        $cb = CallbackWrapper::wrap($cb);
        try {
            $this->request(
                self::OP_QUERY,
                pack('V', 0) . $e[0] . '.$cmd' . "\x00"
                . pack('VV', 0, -1) . bson_encode($params),
                true,
                $conn,
                function ($conn, $reqId = null) use ($db, $cb) {
                    if (!$conn) {
                        !$cb || $cb(['$err' => 'Connection error.']);
                        return;
                    }
                    $conn->requests[$reqId] = [$db, $cb, true];
                }
            );
        } catch (\MongoException $e) {
            Daemon::log('MongoClient exception: ' . $e->getMessage() . ': ' . $e->getTraceAsString());
            if ($cb !== null) {
                $cb(['$err' => $e->getMessage()]);
            }
        }
    }
public function lastError ( $ db , $ cb , $ params = [ ] , $ conn = null ) { $ e = explode ( '.' , $ db , 2 ) ; $ params [ 'getlasterror' ] = 1 ; $ cb = CallbackWrapper :: wrap ( $ cb ) ; try { $ this -> request ( self :: OP_QUERY , pack ( 'V' , 0 ) . $ e [ 0 ] . '.$cmd' . "\x00" . pack ( 'VV' , 0 , - 1 ) . bson_encode ( $ params ) , true , $ conn , function ( $ conn , $ reqId = null ) use ( $ db , $ cb ) { if ( ! $ conn ) { ! $ cb || $ cb ( [ '$err' => 'Connection error.' ] ) ; return ; } $ conn -> requests [ $ reqId ] = [ $ db , $ cb , true ] ; } ) ; } catch ( \ MongoException $ e ) { Daemon :: log ( 'MongoClient exception: ' . $ e -> getMessage ( ) . ': ' . $ e -> getTraceAsString ( ) ) ; if ( $ cb !== null ) { $ cb ( [ '$err' => $ e -> getMessage ( ) ] ) ; } } }
Gets last error
@param  string $db Dbname
@param  callable $cb Callback called when response received
@param  array $params Parameters.
@param  Connection $conn Connection. Optional
@callback $cb ( )
@return void
Gets last error