/** * Returns the number of related EventReservation objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related EventReservation objects. * @throws PropelException */ public function countEventReservations(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(EventPeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collEventReservations === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(EventReservationPeer::EVENT_ID, $this->id); $count = EventReservationPeer::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(EventReservationPeer::EVENT_ID, $this->id); if (!isset($this->lastEventReservationCriteria) || !$this->lastEventReservationCriteria->equals($criteria)) { $count = EventReservationPeer::doCount($criteria, $con); } else { $count = count($this->collEventReservations); } } else { $count = count($this->collEventReservations); } } return $count; }
public function executeInstrumentNotication(sfWebRequest $request) { $c = new Criteria(); $c->add(PersonRolePeer::PERSON_ID, $this->getUser()->getId()); $c->addJoin(PersonRolePeer::ROLE_ID, RoleNotificationPeer::ROLE_ID); $personNotification = RoleNotificationPeer::doSelect($c); $this->mid = 0; foreach ($personNotification as $key => $value) { $this->mid = $value->getMid(); $this->notification = $value->getNotification(); //5. person add if ($this->mid == 5 && ($this->notification == 2 || $this->notification == 3)) { $c = new Criteria(); $c->addDescendingOrderByColumn(PersonPeer::ID); $c->setLimit(5); $this->newperson = PersonPeer::doSelect($c); } } $this->host = $request->getHost(); $this->memberId = $this->getUser()->getMemberId(); //$query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request "; //$query .="WHERE pilot_request.accepted = 1 AND pilot_request.processed = 1 AND pilot_request.member_id = ".$this->memberId; //$con = Propel::getConnection(); //$stmt = $con->prepare($query); //$stmt->execute(); /*if($rs = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int)$rs[0]; }else{ $count = 0; }*/ $c = new Criteria(); $c->add(PilotRequestPeer::ACCEPTED, 1); $c->add(PilotRequestPeer::PROCESSED, 1); $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId); $this->totalAccepted = PilotRequestPeer::doCount($c); /* $this->memberId = $this->getUser()->getMemberId(); $query = "SELECT COUNT(pilot_request.accepted) FROM pilot_request "; $query .="WHERE pilot_request.accepted = 0 AND pilot_request.member_id = $this->memberId"; $con = Propel::getConnection(); $stmt = $con->prepare($query); $stmt->execute(); if($rs = $stmt->fetch(PDO::FETCH_NUM)) { $count = (int)$rs[0]; }else{ $count = 0; }*/ $c = new Criteria(); $c->add(PilotRequestPeer::ACCEPTED, 0); $c->add(PilotRequestPeer::MEMBER_ID, $this->memberId); $this->totaldeclined = PilotRequestPeer::doCount($c); $c = new Criteria(); $c->add(MissionLegPeer::PILOT_ID, $this->getUser()->getPilotId()); $c->add(MissionLegPeer::CANCEL_MISSION_LEG, 0); $this->totalMissionCancellation = MissionLegPeer::doCount($c); //total signup events count $pilot_id = $this->getUser()->getPilotId(); if ($pilot_id) { $pilot = PilotPeer::retrieveByPK($pilot_id); $member_id = $pilot->getMemberId(); $date = date('Y-m-d'); $c = new Criteria(); $c->add(EventReservationPeer::MEMBER_ID, $member_id, Criteria::EQUAL); $c->addJoin(EventPeer::ID, EventReservationPeer::EVENT_ID); $c->add(EventPeer::EVENT_DATE, $date, Criteria::GREATER_EQUAL); $this->totalSignupEvents = EventReservationPeer::doCount($c); } // }