示例#1
0
 /**
  * Search companions
  * CODE: companion_index
  */
 public function executeIndex(sfWebRequest $request)
 {
     # security
     if (!$this->getUser()->hasCredential(array('Administrator', 'Staff', 'Pilot', 'Coordinator', 'Volunteer'), false)) {
         $this->getUser()->setFlash("warning", 'You don\'t have permission to access this url ' . $request->getReferer());
         $this->redirect('dashboard/index');
     }
     $this->companion_list = CompanionPeer::doSelect(new Criteria());
     # for navigation menu
     sfContext::getInstance()->getConfiguration()->loadHelpers('Partial');
     slot('nav_menu', array('mission_coord', ''));
     # filter
     $this->processFilter($request);
     if ($request->isMethod('post') || $request->getParameter('page')) {
         $this->pager = CompanionPeer::getPager($this->max, $this->page, $this->firstname, $this->lastname, $this->name, $this->relationship);
         $this->companions = $this->pager->getResults();
     }
     $this->getUser()->addRecentItem('Companions', 'companions', 'companions/index');
 }
示例#2
0
 /**
  * Gets an array of Companion 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 Person has previously been saved, it will retrieve
  * related Companions from storage. If this Person 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 Companion[]
  * @throws     PropelException
  */
 public function getCompanions($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(PersonPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collCompanions === null) {
         if ($this->isNew()) {
             $this->collCompanions = array();
         } else {
             $criteria->add(CompanionPeer::PERSON_ID, $this->id);
             CompanionPeer::addSelectColumns($criteria);
             $this->collCompanions = CompanionPeer::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(CompanionPeer::PERSON_ID, $this->id);
             CompanionPeer::addSelectColumns($criteria);
             if (!isset($this->lastCompanionCriteria) || !$this->lastCompanionCriteria->equals($criteria)) {
                 $this->collCompanions = CompanionPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastCompanionCriteria = $criteria;
     return $this->collCompanions;
 }
示例#3
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(CompanionPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(CompanionPeer::DATABASE_NAME);
         $criteria->add(CompanionPeer::ID, $pks, Criteria::IN);
         $objs = CompanionPeer::doSelect($criteria, $con);
     }
     return $objs;
 }