public function query($collectionName, $options = [])
    {
        $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName;

        $token = $this->log(
            'find',
            array_merge(
                [
                    'ns' => $databaseName . '.' . $collectionName,
                    'filter' => $this->document,
                ],
                $options
            ),
            __METHOD__
        );

        $readConcern = $this->getReadConcern();
        if ($readConcern !== null) {
            $options['readConcern'] = $readConcern;
        }

        try {
            $this->beginProfile($token, __METHOD__);

            $query = new \MongoDB\Driver\Query($this->document, $options);
            $this->db->open();
            $cursor = $this->db->manager->executeQuery($databaseName . '.' . $collectionName, $query, $this->getReadPreference());
            $cursor->setTypeMap($this->db->typeMap);

            $this->endProfile($token, __METHOD__);
        } catch (RuntimeException $e) {
            $this->endProfile($token, __METHOD__);
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $cursor;
    }
public function query($collectionName, $options = [])
    {
        $databaseName = $this->databaseName === null ? $this->db->defaultDatabaseName : $this->databaseName;

        $token = $this->log(
            'find',
            array_merge(
                [
                    'ns' => $databaseName . '.' . $collectionName,
                    'filter' => $this->document,
                ],
                $options
            ),
            __METHOD__
        );

        $readConcern = $this->getReadConcern();
        if ($readConcern !== null) {
            $options['readConcern'] = $readConcern;
        }

        try {
            $this->beginProfile($token, __METHOD__);

            $query = new \MongoDB\Driver\Query($this->document, $options);
            $this->db->open();
            $cursor = $this->db->manager->executeQuery($databaseName . '.' . $collectionName, $query, $this->getReadPreference());
            $cursor->setTypeMap($this->db->typeMap);

            $this->endProfile($token, __METHOD__);
        } catch (RuntimeException $e) {
            $this->endProfile($token, __METHOD__);
            throw new Exception($e->getMessage(), $e->getCode(), $e);
        }

        return $cursor;
    }
public function query ( $ collectionName , $ options = [ ] ) { $ databaseName = $ this -> databaseName === null ? $ this -> db -> defaultDatabaseName : $ this -> databaseName ; $ token = $ this -> log ( 'find' , array_merge ( [ 'ns' => $ databaseName . '.' . $ collectionName , 'filter' => $ this -> document , ] , $ options ) , __METHOD__ ) ; $ readConcern = $ this -> getReadConcern ( ) ; if ( $ readConcern !== null ) { $ options [ 'readConcern' ] = $ readConcern ; } try { $ this -> beginProfile ( $ token , __METHOD__ ) ; $ query = new \ MongoDB \ Driver \ Query ( $ this -> document , $ options ) ; $ this -> db -> open ( ) ; $ cursor = $ this -> db -> manager -> executeQuery ( $ databaseName . '.' . $ collectionName , $ query , $ this -> getReadPreference ( ) ) ; $ cursor -> setTypeMap ( $ this -> db -> typeMap ) ; $ this -> endProfile ( $ token , __METHOD__ ) ; } catch ( RuntimeException $ e ) { $ this -> endProfile ( $ token , __METHOD__ ) ; throw new Exception ( $ e -> getMessage ( ) , $ e -> getCode ( ) , $ e ) ; } return $ cursor ; }
Executes this command as a mongo query
@param string $collectionName collection name
@param array $options query options.
@return \MongoDB\Driver\Cursor result cursor.
@throws Exception on failure
Executes this command as a mongo query