public static function reap($set, $try_to_do_multi = true)
 {
     $items = array();
     if (is_array($set)) {
         if (count($set) >= sfConfig::get('app_reap_single_clients_min')) {
             $items = self::prepareReap($set);
         }
     }
     // test if we should do a multiple client reap
     if ($try_to_do_multi) {
         // the "3" value is a way to short circuit this
         $do_multi = $try_to_do_multi == 3 || time() % sfConfig::get('app_reap_multi_time_mod') == 0;
     }
     if ($do_multi) {
         $criteria = new Criteria();
         $criteria->setLimit(sfConfig::get('app_reap_multi_clients_max'));
         $criteria->addAscendingOrderByColumn(ClientPeer::UPDATED_AT);
         $criteria->add(ClientPeer::UPDATED_AT, time() - sfConfig::get('app_reap_client_age_max'), Criteria::LESS_EQUAL);
         // fixme this should be refined more -- perhaps seeds should be even less likely to be reaped etc?
         $all = ClientPeer::doSelect($criteria);
         $items = array_merge(self::prepareReap($all), $items);
     }
     if (count($items) > sfConfig::get('app_reap_single_kills_min') || $do_multi) {
         if (count($items)) {
             self::doDelete($items);
             // does do delete actually call the delete method on each?
         }
     }
     // todo: deleted items should be removed from set
     return $set;
 }
Example #2
0
 public function getClients()
 {
     $c = new Criteria();
     $c->add(JobClientPeer::JOB_ID, $this->getId());
     $clientIds = array();
     $jc = JobClientPeer::doSelect($c);
     foreach ($jc as $i) {
         $clientIds[] = $i->getClientId();
     }
     $c = new Criteria();
     $c->add(ClientPeer::ID, $clientIds, Criteria::IN);
     return ClientPeer::doSelect($c);
 }
Example #3
0
 public static function getArrayForAutocomplete($q)
 {
     $c = new Criteria();
     $crit0 = $c->getNewCriterion(ClientPeer::NAME, "%" . $q . "%", Criteria::LIKE);
     $crit1 = $c->getNewCriterion(ClientPeer::EMAIL, "%" . $q . "%", Criteria::LIKE);
     $crit0->addOr($crit1);
     $c->add($crit0);
     $c->setLimit(10);
     $names = array();
     $clients = ClientPeer::doSelect($c);
     foreach ($clients as $p) {
         $names[] = array("id" => $p->getId(), "name" => $p->getName(), "email" => $p->getEmail());
     }
     return $names;
 }
Example #4
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(ClientPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $objs = null;
     if (empty($pks)) {
         $objs = array();
     } else {
         $criteria = new Criteria(ClientPeer::DATABASE_NAME);
         $criteria->add(ClientPeer::ID, $pks, Criteria::IN);
         $objs = ClientPeer::doSelect($criteria, $con);
     }
     return $objs;
 }
Example #5
0
 public function executeCoreEval(sfWebRequest $request)
 {
     $this->form = new ReportCoreEvalForm();
     if ($request->isMethod('post')) {
         $this->form->bind($request->getParameter($this->form->getName()), $request->getFiles($this->form->getName()));
         if ($this->form->isValid()) {
             $start_date = $this->form->getValue('start_date');
             $end_date = $this->form->getValue('end_date');
             $this->start_date = strtotime($start_date);
             $this->end_date = strtotime($end_date);
             $c = new Criteria();
             $c->add(ClientPeer::CREATED_AT, $this->start_date, Criteria::GREATER_EQUAL);
             $c->addAnd(ClientPeer::CREATED_AT, $this->end_date, Criteria::LESS_EQUAL);
             $this->clients = ClientPeer::doSelect($c);
             $this->setTemplate('coreEvalReport');
         }
     }
 }
Example #6
0
 public function getTimesheetClients(Criteria $c)
 {
     $c->add(ClientServicePeer::EMPLOYEE_ID, $this->getId());
     return ClientPeer::doSelect($c);
 }
 /**
  * Gets an array of Client 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 sfGuardUserProfile has previously been saved, it will retrieve
  * related Clients from storage. If this sfGuardUserProfile 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 Client[]
  * @throws     PropelException
  */
 public function getClients($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(sfGuardUserProfilePeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collClients === null) {
         if ($this->isNew()) {
             $this->collClients = array();
         } else {
             $criteria->add(ClientPeer::USER_ID, $this->id);
             ClientPeer::addSelectColumns($criteria);
             $this->collClients = ClientPeer::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(ClientPeer::USER_ID, $this->id);
             ClientPeer::addSelectColumns($criteria);
             if (!isset($this->lastClientCriteria) || !$this->lastClientCriteria->equals($criteria)) {
                 $this->collClients = ClientPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastClientCriteria = $criteria;
     return $this->collClients;
 }