/**  
  * 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;
     }
 }
Esempio n. 2
0
 /**
  * Gets an array of History objects which contain a foreign key that references this object.
  *
  * If this collection has already been initialized with an identical Criteria, it returns the collection.
  * Otherwise if this User has previously been saved, it will retrieve
  * related Historys from storage. If this User is new, it will return
  * an empty collection or the current collection, the criteria is ignored on a new object.
  *
  * @param      PropelPDO $con
  * @param      Criteria $criteria
  * @return     array History[]
  * @throws     PropelException
  */
 public function getHistorys($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(UserPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collHistorys === null) {
         if ($this->isNew()) {
             $this->collHistorys = array();
         } else {
             $criteria->add(HistoryPeer::USER_ID, $this->id);
             HistoryPeer::addSelectColumns($criteria);
             $this->collHistorys = HistoryPeer::doSelect($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 the collection.
             $criteria->add(HistoryPeer::USER_ID, $this->id);
             HistoryPeer::addSelectColumns($criteria);
             if (!isset($this->lastHistoryCriteria) || !$this->lastHistoryCriteria->equals($criteria)) {
                 $this->collHistorys = HistoryPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastHistoryCriteria = $criteria;
     return $this->collHistorys;
 }
 /**
 * 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;
 }
 /**
  * If this collection has already been initialized with
  * an identical criteria, it returns the collection.
  * Otherwise if this Production has previously
  * been saved, it will retrieve related Historys from storage.
  * If this Production is new, it will return
  * an empty collection or the current collection, the criteria
  * is ignored on a new object.
  *
  * @param      Connection $con
  * @param      Criteria $criteria
  * @throws     PropelException
  */
 public function getHistorys($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());
             HistoryPeer::addSelectColumns($criteria);
             $this->collHistorys = HistoryPeer::doSelect($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 the collection.
             $criteria->add(HistoryPeer::PRODUCTION_ID, $this->getProductionId());
             HistoryPeer::addSelectColumns($criteria);
             if (!isset($this->lastHistoryCriteria) || !$this->lastHistoryCriteria->equals($criteria)) {
                 $this->collHistorys = HistoryPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastHistoryCriteria = $criteria;
     return $this->collHistorys;
 }
Esempio n. 5
0
 /**
  * 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;
 }