protected function getDisciplineList(Criteria $c = null)
 {
     if ($c === null) {
         return EnumItemPeer::doSelect(new Criteria());
     } else {
         return EnumItemPeer::doSelect($c);
     }
 }
 /**
  * Executes query and hydrate this object
  *
  * @param       string $query the query being searched for
  */
 public function query($query, $propelConnection)
 {
     $refQuery = trim($query);
     if (strlen($refQuery) < 3) {
         throw new Exception("Too few characters in the query string");
     } elseif (helperFunctions::isMaliciousString($refQuery)) {
         throw new Exception("Malicious string detected. Are you trying to wreck our system?");
     } else {
         // search for courses
         $c = new Criteria();
         $idCrit = $c->getNewCriterion(CoursePeer::ID, $refQuery . "%", Criteria::LIKE);
         $nameCrit = $c->getNewCriterion(CoursePeer::DESCR, "%" . $refQuery . "%", Criteria::LIKE);
         $idCrit->addOr($nameCrit);
         $c->addAnd($idCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(CoursePeer::ID);
         $this->_courseList = CoursePeer::doselect($c, $propelConnection);
         // search for professors
         $c = new Criteria();
         $firstNameCrit = $c->getNewCriterion(InstructorPeer::FIRST_NAME, "%" . $refQuery . "%", Criteria::LIKE);
         $lastNameCrit = $c->getNewCriterion(InstructorPeer::LAST_NAME, "%" . $refQuery . "%", Criteria::LIKE);
         $firstNameCrit->addOr($lastNameCrit);
         $c->addAnd($firstNameCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(InstructorPeer::LAST_NAME);
         $this->_profList = InstructorPeer::doSelect($c, $propelConnection);
         // search for programs
         $c = new Criteria();
         $descrCrit = $c->getNewCriterion(EnumItemPeer::DESCR, "%" . $refQuery . "%", Criteria::LIKE);
         $parentCrit = $c->getNewCriterion(EnumItemPeer::PARENT_ID, EnumItemPeer::DISCIPLINES_NODE_ID);
         $c->addAnd($parentCrit);
         $c->addAnd($descrCrit);
         $c->setDistinct();
         $c->addAscendingOrderByColumn(EnumItemPeer::DESCR);
         $this->_programList = EnumItemPeer::doSelect($c, $propelConnection);
     }
 }
Example #3
0
 /**
  * Gets an array of EnumItem 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 EnumItem has previously been saved, it will retrieve
  * related EnumItemsRelatedByParentId from storage. If this EnumItem 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 EnumItem[]
  * @throws     PropelException
  */
 public function getEnumItemsRelatedByParentId($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(EnumItemPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collEnumItemsRelatedByParentId === null) {
         if ($this->isNew()) {
             $this->collEnumItemsRelatedByParentId = array();
         } else {
             $criteria->add(EnumItemPeer::PARENT_ID, $this->id);
             EnumItemPeer::addSelectColumns($criteria);
             $this->collEnumItemsRelatedByParentId = EnumItemPeer::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(EnumItemPeer::PARENT_ID, $this->id);
             EnumItemPeer::addSelectColumns($criteria);
             if (!isset($this->lastEnumItemRelatedByParentIdCriteria) || !$this->lastEnumItemRelatedByParentIdCriteria->equals($criteria)) {
                 $this->collEnumItemsRelatedByParentId = EnumItemPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastEnumItemRelatedByParentIdCriteria = $criteria;
     return $this->collEnumItemsRelatedByParentId;
 }
 /**
  * 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(EnumItemPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(EnumItemPeer::DATABASE_NAME);
         $criteria->add(EnumItemPeer::ID, $pks, Criteria::IN);
         $objs = EnumItemPeer::doSelect($criteria, $con);
     }
     return $objs;
 }