/**
  * Lood document by its identifier.
  *
  * @param string $id
  * @return object|null
  */
 public function loadById($id)
 {
     $result = $this->_collection->findOne(array('_id' => new \MongoId($id)));
     if ($result !== null) {
         return $this->_uow->getOrCreateDocument($this->_documentName, $result);
     }
     return null;
 }
예제 #2
0
 /**
  * Lood document by its identifier.
  *
  * @param string $id
  * @return object|null
  */
 public function loadById($id)
 {
     $result = $this->_collection->findOne(array('_id' => $this->_class->getDatabaseIdentifierValue($id)));
     if ($result !== null) {
         return $this->_uow->getOrCreateDocument($this->_documentName, $result);
     }
     return null;
 }
 /**
  * Lood document by its identifier.
  *
  * @param string $id
  * @return object|null
  */
 public function loadById($id)
 {
     $result = $this->_collection->findOne(array('_id' => $this->_class->getDatabaseIdentifierValue($id)));
     if ($result !== null) {
         $document = $this->_uow->getOrCreateDocument($this->_documentName, $result);
         $this->_uow->registerManaged($document, $this->_class->getPHPIdentifierValue($result['_id']), $result);
         return $document;
     }
     return null;
 }
예제 #4
0
 /**
  * Checks whether the given managed document exists in the database.
  *
  * @param object $document
  * @return boolean TRUE if the document exists in the database, FALSE otherwise.
  */
 public function exists($document)
 {
     $id = $this->class->getIdentifierObject($document);
     return (bool) $this->collection->findOne(array(array('_id' => $id)), array('_id'));
 }