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

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

Execute the operation.
См. также: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : array | object
$server MongoDB\Driver\Server
Результат array | object Command result document
    public function execute(Server $server)
    {
        $cursor = $server->executeCommand($this->databaseName, $this->createCommand());
        if (isset($this->options['typeMap'])) {
            $cursor->setTypeMap($this->options['typeMap']);
        }
        return current($cursor->toArray());
    }

Usage Example

Пример #1
0
 /**
  * Create a new collection explicitly.
  *
  * @see CreateCollection::__construct() for supported options
  *
  * @param string $collectionName
  * @param array  $options
  *
  * @return array|object Command result document
  */
 public function createCollection($collectionName, array $options = [])
 {
     if (!isset($options['typeMap'])) {
         $options['typeMap'] = $this->typeMap;
     }
     $operation = new CreateCollection($this->databaseName, $collectionName, $options);
     $server = $this->manager->selectServer(new ReadPreference(ReadPreference::RP_PRIMARY));
     return $operation->execute($server);
 }