Phalcon\Db\Adapter\MongoDB\Operation\DatabaseCommand::execute PHP Méthode

execute() public méthode

Execute the operation.
See also: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : integer
$server MongoDB\Driver\Server
Résultat integer
    public function execute(Server $server)
    {
        $readPreference = isset($this->options['readPreference']) ? $this->options['readPreference'] : null;
        $cursor = $server->executeCommand($this->databaseName, $this->command, $readPreference);
        if (isset($this->options['typeMap'])) {
            $cursor->setTypeMap($this->options['typeMap']);
        }
        return $cursor;
    }

Usage Example

Exemple #1
0
 /**
  * Execute a command on this database.
  *
  * @see DatabaseCommand::__construct() for supported options
  *
  * @param array|object $command Command document
  * @param array        $options Options for command execution
  *
  * @return Cursor
  * @throws InvalidArgumentException
  */
 public function command($command, array $options = [])
 {
     if (!isset($options['readPreference'])) {
         $options['readPreference'] = $this->readPreference;
     }
     if (!isset($options['typeMap'])) {
         $options['typeMap'] = $this->typeMap;
     }
     $operation = new DatabaseCommand($this->databaseName, $command, $options);
     $server = $this->manager->selectServer($options['readPreference']);
     return $operation->execute($server);
 }
DatabaseCommand