コード例 #1
0
ファイル: Thread.php プロジェクト: rayku/rayku
 public function save(PropelPDO $con = null)
 {
     $new = $this->isNew();
     $ret = parent::save($con);
     if ($new) {
         HistoryPeer::createFor($this);
     }
     return $ret;
 }
コード例 #2
0
ファイル: Post.php プロジェクト: rayku/rayku
 /**
  * Updates the lastpost_at field in this post's Thread and saves the post
  */
 public function save(PropelPDO $con = null)
 {
     //Set the ID and lastpost_at to the right values
     $c = new Criteria();
     $c->add(ThreadPeer::ID, $this->getThreadId());
     $c->add(ThreadPeer::LASTPOST_AT, time());
     //Update the thread table
     ThreadPeer::doUpdate($c);
     $new = $this->isNew();
     $ret = parent::save($con);
     if ($new) {
         HistoryPeer::createFor($this);
     }
     return $ret;
 }
コード例 #3
0
 /**  
  * Description                       : Retrieve the users that are working in one production (in the room)
  * 
  * @param String $idProduction       : Id of a production
  * @return                           : A collection of users 
  */
 public function getRoomUsers($idProduction)
 {
     try {
         $criteria = new Criteria();
         $criteria->add(HistoryPeer::PRODUCTION_ID, $idProduction);
         $log = HistoryPeer::doSelect($criteria);
         $users = array();
         foreach ($log as $history) {
             $users[] = $history->getUser();
         }
         return $users;
     } catch (Exception $e) {
         return null;
     }
 }
コード例 #4
0
ファイル: BaseHistory.php プロジェクト: rayku/rayku
 /**
  * Populates the object using an array.
  *
  * This is particularly useful when populating an object from one of the
  * request arrays (e.g. $_POST).  This method goes through the column
  * names, checking to see whether a matching key exists in populated
  * array. If so the setByName() method is called for that column.
  *
  * You can specify the key type of the array by additionally passing one
  * of the class type constants BasePeer::TYPE_PHPNAME, BasePeer::TYPE_STUDLYPHPNAME,
  * BasePeer::TYPE_COLNAME, BasePeer::TYPE_FIELDNAME, BasePeer::TYPE_NUM.
  * The default key type is the column's phpname (e.g. 'AuthorId')
  *
  * @param      array  $arr     An array to populate the object from.
  * @param      string $keyType The type of keys the array uses.
  * @return     void
  */
 public function fromArray($arr, $keyType = BasePeer::TYPE_PHPNAME)
 {
     $keys = HistoryPeer::getFieldNames($keyType);
     if (array_key_exists($keys[0], $arr)) {
         $this->setId($arr[$keys[0]]);
     }
     if (array_key_exists($keys[1], $arr)) {
         $this->setUserId($arr[$keys[1]]);
     }
     if (array_key_exists($keys[2], $arr)) {
         $this->setEntityType($arr[$keys[2]]);
     }
     if (array_key_exists($keys[3], $arr)) {
         $this->setData($arr[$keys[3]]);
     }
     if (array_key_exists($keys[4], $arr)) {
         $this->setCreatedAt($arr[$keys[4]]);
     }
 }
コード例 #5
0
 /**
  * This function performs the validation work for complex object models.
  *
  * In addition to checking the current object, all related objects will
  * also be validated.  If all pass then <code>true</code> is returned; otherwise
  * an aggreagated array of ValidationFailed objects will be returned.
  *
  * @param      array $columns Array of column names to validate.
  * @return     mixed <code>true</code> if all validations pass; array of <code>ValidationFailed</code> objets otherwise.
  */
 protected function doValidate($columns = null)
 {
     if (!$this->alreadyInValidation) {
         $this->alreadyInValidation = true;
         $retval = null;
         $failureMap = array();
         // We call the validate method on the following object(s) if they
         // were passed to this object by their coresponding set
         // method.  This object relates to these object(s) by a
         // foreign key reference.
         if ($this->aUser !== null) {
             if (!$this->aUser->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aUser->getValidationFailures());
             }
         }
         if ($this->aProduction !== null) {
             if (!$this->aProduction->validate($columns)) {
                 $failureMap = array_merge($failureMap, $this->aProduction->getValidationFailures());
             }
         }
         if (($retval = HistoryPeer::doValidate($this, $columns)) !== true) {
             $failureMap = array_merge($failureMap, $retval);
         }
         $this->alreadyInValidation = false;
     }
     return !empty($failureMap) ? $failureMap : true;
 }
コード例 #6
0
 private function fetchForStudent(User $student)
 {
     return HistoryPeer::getFor($student->getId(), $this->limit);
 }
コード例 #7
0
ファイル: BaseUser.php プロジェクト: rayku/rayku
 /**
  * Returns the number of related History objects.
  *
  * @param      Criteria $criteria
  * @param      boolean $distinct
  * @param      PropelPDO $con
  * @return     int Count of related History objects.
  * @throws     PropelException
  */
 public function countHistorys(Criteria $criteria = null, $distinct = false, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
     } else {
         $criteria = clone $criteria;
     }
     if ($distinct) {
         $criteria->setDistinct();
     }
     $count = null;
     if ($this->collHistorys === null) {
         if ($this->isNew()) {
             $count = 0;
         } else {
             $criteria->add(HistoryPeer::USER_ID, $this->id);
             $count = HistoryPeer::doCount($criteria, $con);
         }
     } else {
         // criteria has no effect for a new object
         if (!$this->isNew()) {
             // the following code is to determine if a new query is
             // called for.  If the criteria is the same as the last
             // one, just return count of the collection.
             $criteria->add(HistoryPeer::USER_ID, $this->id);
             if (!isset($this->lastHistoryCriteria) || !$this->lastHistoryCriteria->equals($criteria)) {
                 $count = HistoryPeer::doCount($criteria, $con);
             } else {
                 $count = count($this->collHistorys);
             }
         } else {
             $count = count($this->collHistorys);
         }
     }
     return $count;
 }
コード例 #8
0
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Production is new, it will return
  * an empty collection; or if this Production has previously
  * been saved, it will retrieve related Historys from storage.
  *
  * This method is protected by default in order to keep the public
  * api reasonable.  You can provide public methods for those you
  * actually need in Production.
  */
 public function getHistorysJoinUser($criteria = null, $con = null)
 {
     // include the Peer class
     include_once 'src/model/whiteboard/om/BaseHistoryPeer.php';
     if ($criteria === null) {
         $criteria = new Criteria();
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collHistorys === null) {
         if ($this->isNew()) {
             $this->collHistorys = array();
         } else {
             $criteria->add(HistoryPeer::PRODUCTION_ID, $this->getProductionId());
             $this->collHistorys = HistoryPeer::doSelectJoinUser($criteria, $con);
         }
     } else {
         // the following code is to determine if a new query is
         // called for.  If the criteria is the same as the last
         // one, just return the collection.
         $criteria->add(HistoryPeer::PRODUCTION_ID, $this->getProductionId());
         if (!isset($this->lastHistoryCriteria) || !$this->lastHistoryCriteria->equals($criteria)) {
             $this->collHistorys = HistoryPeer::doSelectJoinUser($criteria, $con);
         }
     }
     $this->lastHistoryCriteria = $criteria;
     return $this->collHistorys;
 }
コード例 #9
0
 /**
 * Retrieve object using using composite pkey values.
 * @param int $user_id
   @param int $production_id
   
 * @param      Connection $con
 * @return     History
 */
 public static function retrieveByPK($user_id, $production_id, $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(self::DATABASE_NAME);
     }
     $criteria = new Criteria();
     $criteria->add(HistoryPeer::USER_ID, $user_id);
     $criteria->add(HistoryPeer::PRODUCTION_ID, $production_id);
     $v = HistoryPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
コード例 #10
0
ファイル: BaseHistoryPeer.php プロジェクト: rayku/rayku
 /**
  * Retrieve multiple objects by pkey.
  *
  * @param      array $pks List of primary keys
  * @param      PropelPDO $con the connection to use
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function retrieveByPKs($pks, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(HistoryPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(HistoryPeer::DATABASE_NAME);
         $criteria->add(HistoryPeer::ID, $pks, Criteria::IN);
         $objs = HistoryPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
コード例 #11
0
ファイル: BaseUserPeer.php プロジェクト: rayku/rayku
 /**
  * Method perform a DELETE on the database, given a User or Criteria object OR a primary key value.
  *
  * @param      mixed $values Criteria or User object or primary key or array of primary keys
  *              which is used to create the DELETE statement
  * @param      PropelPDO $con the connection to use
  * @return     int 	The number of affected rows (if supported by underlying database driver).  This includes CASCADE-related rows
  *				if supported by native driver or if emulated using Propel.
  * @throws     PropelException Any exceptions caught during processing will be
  *		 rethrown wrapped into a PropelException.
  */
 public static function doDelete($values, PropelPDO $con = null)
 {
     if ($con === null) {
         $con = Propel::getConnection(UserPeer::DATABASE_NAME, Propel::CONNECTION_WRITE);
     }
     if ($values instanceof Criteria) {
         // invalidate the cache for all objects of this type, since we have no
         // way of knowing (without running a query) what objects should be invalidated
         // from the cache based on this Criteria.
         UserPeer::clearInstancePool();
         // rename for clarity
         $criteria = clone $values;
     } elseif ($values instanceof User) {
         // invalidate the cache for this single object
         UserPeer::removeInstanceFromPool($values);
         // create criteria based on pk values
         $criteria = $values->buildPkeyCriteria();
     } else {
         // it must be the primary key
         $criteria = new Criteria(self::DATABASE_NAME);
         $criteria->add(UserPeer::ID, (array) $values, Criteria::IN);
         foreach ((array) $values as $singleval) {
             // we can invalidate the cache for this single object
             UserPeer::removeInstanceFromPool($singleval);
         }
     }
     // Set the correct dbName
     $criteria->setDbName(self::DATABASE_NAME);
     $affectedRows = 0;
     // initialize var to track total num of affected rows
     try {
         // use transaction because $criteria could contain info
         // for more than one table or we could emulating ON DELETE CASCADE, etc.
         $con->beginTransaction();
         $affectedRows += BasePeer::doDelete($criteria, $con);
         // invalidate objects in ExpertPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         ExpertPeer::clearInstancePool();
         // invalidate objects in HistoryPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         HistoryPeer::clearInstancePool();
         // invalidate objects in ItemRatingPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         ItemRatingPeer::clearInstancePool();
         // invalidate objects in OfferVoucher1Peer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         OfferVoucher1Peer::clearInstancePool();
         // invalidate objects in PurchaseDetailPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         PurchaseDetailPeer::clearInstancePool();
         // invalidate objects in ShoppingCartPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         ShoppingCartPeer::clearInstancePool();
         // invalidate objects in UserAwardsPeer instance pool, since one or more of them may be deleted by ON DELETE CASCADE rule.
         UserAwardsPeer::clearInstancePool();
         $con->commit();
         return $affectedRows;
     } catch (PropelException $e) {
         $con->rollBack();
         throw $e;
     }
 }