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

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

Execute the operation.
См. также: Executable::execute()
public execute ( MongoDB\Driver\Server $server ) : object | null
$server MongoDB\Driver\Server
Результат object | null
    public function execute(Server $server)
    {
        $cursor = $server->executeCommand($this->databaseName, $this->createCommand($server));
        $result = current($cursor->toArray());
        if (!isset($result->value)) {
            return null;
        }
        /* Prior to 3.0, findAndModify returns an empty document instead of null
         * when an upsert is performed and the pre-modified document was
         * requested.
         */
        if ($this->options['upsert'] && !$this->options['new'] && isset($result->lastErrorObject->updatedExisting) && !$result->lastErrorObject->updatedExisting) {
            return null;
        }
        if (!is_object($result->value)) {
            throw new UnexpectedValueException('findAndModify command did not return a "value" document');
        }
        return $result->value;
    }