예제 #1
0
 /**
  * Adds an object to the instance pool.
  *
  * Propel keeps cached copies of objects in an instance pool when they are retrieved
  * from the database.  In some cases -- especially when you override doSelect*()
  * methods in your stub classes -- you may need to explicitly add objects
  * to the cache in order to ensure that the same objects are always returned by doSelect*()
  * and retrieveByPK*() calls.
  *
  * @param DocumentData $obj A DocumentData object.
  * @param      string $key (optional) key to use for instance map (for performance boost if key was already calculated externally).
  */
 public static function addInstanceToPool($obj, $key = null)
 {
     if (Propel::isInstancePoolingEnabled()) {
         if ($key === null) {
             $key = (string) $obj->getHash();
         }
         // if key === null
         DocumentDataPeer::$instances[$key] = $obj;
     }
 }
예제 #2
0
 /**
  * Filter the query by a related DocumentData object
  *
  * @param   DocumentData|PropelObjectCollection $documentData The related object(s) to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 DocumentQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByDocumentData($documentData, $comparison = null)
 {
     if ($documentData instanceof DocumentData) {
         return $this->addUsingAlias(DocumentPeer::HASH, $documentData->getHash(), $comparison);
     } elseif ($documentData instanceof PropelObjectCollection) {
         if (null === $comparison) {
             $comparison = Criteria::IN;
         }
         return $this->addUsingAlias(DocumentPeer::HASH, $documentData->toKeyValue('PrimaryKey', 'Hash'), $comparison);
     } else {
         throw new PropelException('filterByDocumentData() only accepts arguments of type DocumentData or PropelCollection');
     }
 }
예제 #3
0
 public function setData($mData)
 {
     if (is_resource($mData)) {
         $mData = stream_get_contents($mData);
     }
     $sHash = sha1($mData);
     $sPreviousHash = $this->getHash();
     if ($sHash === $sPreviousHash) {
         return;
     }
     $oOldDocumentData = $this->getDocumentData();
     if ($oOldDocumentData && $oOldDocumentData->countDocuments() <= 1) {
         // Only remaining document is the one to be updated
         $oOldDocumentData->delete();
     }
     $oDocumentData = DocumentDataQuery::create()->findPk($sHash);
     if ($oDocumentData === null) {
         $oDocumentData = new DocumentData();
         $oDocumentData->setHash($sHash);
         $oDocumentData->setDataSize(strlen($mData));
         $oDocumentData->setData($mData);
     }
     $this->setDocumentData($oDocumentData);
     return $this;
 }
예제 #4
0
 /**
  * Filter the query by a related DocumentData object
  *
  * @param   DocumentData|PropelObjectCollection $documentData  the related object to use as filter
  * @param     string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL
  *
  * @return                 UserQuery The current query, for fluid interface
  * @throws PropelException - if the provided filter is invalid.
  */
 public function filterByDocumentDataRelatedByUpdatedBy($documentData, $comparison = null)
 {
     if ($documentData instanceof DocumentData) {
         return $this->addUsingAlias(UserPeer::ID, $documentData->getUpdatedBy(), $comparison);
     } elseif ($documentData instanceof PropelObjectCollection) {
         return $this->useDocumentDataRelatedByUpdatedByQuery()->filterByPrimaryKeys($documentData->getPrimaryKeys())->endUse();
     } else {
         throw new PropelException('filterByDocumentDataRelatedByUpdatedBy() only accepts arguments of type DocumentData or PropelCollection');
     }
 }
예제 #5
0
 /**
  * Resets all references to other model objects or collections of model objects.
  *
  * This method is a user-space workaround for PHP's inability to garbage collect
  * objects with circular references (even in PHP 5.3). This is currently necessary
  * when using Propel in certain daemon or large-volume/high-memory operations.
  *
  * @param boolean $deep Whether to also clear the references on all referrer objects.
  */
 public function clearAllReferences($deep = false)
 {
     if ($deep && !$this->alreadyInClearAllReferencesDeep) {
         $this->alreadyInClearAllReferencesDeep = true;
         if ($this->aLanguage instanceof Persistent) {
             $this->aLanguage->clearAllReferences($deep);
         }
         if ($this->aUserRelatedByOwnerId instanceof Persistent) {
             $this->aUserRelatedByOwnerId->clearAllReferences($deep);
         }
         if ($this->aDocumentType instanceof Persistent) {
             $this->aDocumentType->clearAllReferences($deep);
         }
         if ($this->aDocumentCategory instanceof Persistent) {
             $this->aDocumentCategory->clearAllReferences($deep);
         }
         if ($this->aDocumentData instanceof Persistent) {
             $this->aDocumentData->clearAllReferences($deep);
         }
         if ($this->aUserRelatedByCreatedBy instanceof Persistent) {
             $this->aUserRelatedByCreatedBy->clearAllReferences($deep);
         }
         if ($this->aUserRelatedByUpdatedBy instanceof Persistent) {
             $this->aUserRelatedByUpdatedBy->clearAllReferences($deep);
         }
         $this->alreadyInClearAllReferencesDeep = false;
     }
     // if ($deep)
     $this->aLanguage = null;
     $this->aUserRelatedByOwnerId = null;
     $this->aDocumentType = null;
     $this->aDocumentCategory = null;
     $this->aDocumentData = null;
     $this->aUserRelatedByCreatedBy = null;
     $this->aUserRelatedByUpdatedBy = null;
 }
예제 #6
0
 /**
  * Exclude object from result
  *
  * @param   DocumentData $documentData Object to remove from the list of results
  *
  * @return DocumentDataQuery The current query, for fluid interface
  */
 public function prune($documentData = null)
 {
     if ($documentData) {
         $this->addUsingAlias(DocumentDataPeer::HASH, $documentData->getHash(), Criteria::NOT_EQUAL);
     }
     return $this;
 }