public function findOne($query = [], array $fields = [], array $options = [])
    {
        // Can't typehint for array since MongoGridFS extends and accepts strings
        if (! is_array($query)) {
            trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_USER_WARNING);
            return;
        }

        $options = ['projection' => TypeConverter::convertProjection($fields)] + $options;
        try {
            $document = $this->collection->findOne(TypeConverter::fromLegacy($query), $options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e);
        }

        if ($document !== null) {
            $document = TypeConverter::toLegacy($document);
        }

        return $document;
    }
public function findOne($query = [], array $fields = [], array $options = [])
    {
        // Can't typehint for array since MongoGridFS extends and accepts strings
        if (! is_array($query)) {
            trigger_error(sprintf('MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given', gettype($query)), E_USER_WARNING);
            return;
        }

        $options = ['projection' => TypeConverter::convertProjection($fields)] + $options;
        try {
            $document = $this->collection->findOne(TypeConverter::fromLegacy($query), $options);
        } catch (\MongoDB\Driver\Exception\Exception $e) {
            throw ExceptionConverter::toLegacy($e);
        }

        if ($document !== null) {
            $document = TypeConverter::toLegacy($document);
        }

        return $document;
    }
public function findOne ( $ query = [ ] , array $ fields = [ ] , array $ options = [ ] ) { // Can't typehint for array since MongoGridFS extends and accepts strings if ( ! is_array ( $ query ) ) { trigger_error ( sprintf ( 'MongoCollection::findOne(): expects parameter 1 to be an array or object, %s given' , gettype ( $ query ) ) , E_USER_WARNING ) ; return ; } $ options = [ 'projection' => TypeConverter :: convertProjection ( $ fields ) ] + $ options ; try { $ document = $ this -> collection -> findOne ( TypeConverter :: fromLegacy ( $ query ) , $ options ) ; } catch ( \ MongoDB \ Driver \ Exception \ Exception $ e ) { throw ExceptionConverter :: toLegacy ( $ e ) ; } if ( $ document !== null ) { $ document = TypeConverter :: toLegacy ( $ document ) ; } return $ document ; }
Querys this collection, returning a single element

@link http://www.php.net/manual/en/mongocollection.findone.php
@param array $query The fields for which to search.
@param array $fields Fields of the results to return.
@param array $options
@return array|null
Querys this collection returning a single element