Doctrine\ODM\MongoDB\DocumentManager::flush PHP Method

flush() public method

This effectively synchronizes the in-memory state of managed objects with the database.
public flush ( object $document = null, array $options = [] )
$document object
$options array Array of options to be used with batchInsert(), update() and remove()
    public function flush($document = null, array $options = array())
    {
        if (null !== $document && !is_object($document) && !is_array($document)) {
            throw new \InvalidArgumentException(gettype($document));
        }
        $this->errorIfClosed();
        $this->unitOfWork->commit($document, $options);
    }

Usage Example

Example #1
0
 public function create($username, $password, $roles)
 {
     $user = new Document\User();
     $user->setUsername($username)->setPassword($password)->setRoles($roles);
     $this->manager->persist($user);
     $this->manager->flush();
 }
All Usage Examples Of Doctrine\ODM\MongoDB\DocumentManager::flush