Phalcon\Db\Adapter\MongoDB\Operation\Find::execute PHP Метод

execute() публичный Метод

Execute the operation.
См. также: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : MongoDB\Driver\Cursor
$server MongoDB\Driver\Server
Результат MongoDB\Driver\Cursor
    public function execute(Server $server)
    {
        $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
        $cursor = $server->executeQuery($this->databaseName . '.' . $this->collectionName, $this->createQuery(), $readPreference);
        if (isset($this->options['typeMap'])) {
            $cursor->setTypeMap($this->options['typeMap']);
        }
        return $cursor;
    }

Usage Example

Пример #1
0
 /**
  * Finds documents matching the query.
  *
  * @see Find::__construct() for supported options
  * @see http://docs.mongodb.org/manual/core/read-operations-introduction/
  *
  * @param array|object $filter Query by which to filter documents
  * @param array        $options Additional options
  *
  * @return Cursor
  */
 public function find($filter = [], array $options = [])
 {
     if (!isset($options['readConcern'])) {
         $options['readConcern'] = $this->readConcern;
     }
     if (!isset($options['readPreference'])) {
         $options['readPreference'] = $this->readPreference;
     }
     if (!isset($options['typeMap'])) {
         $options['typeMap'] = $this->typeMap;
     }
     $operation = new Find($this->databaseName, $this->collectionName, $filter, $options);
     $server = $this->manager->selectServer($options['readPreference']);
     return $operation->execute($server);
 }