public static function getUserRides() { $u_id = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', '-1', 'subscriber'); if ($u_id) { $c = new Criteria(); $c->add(UserRidesPeer::USER_ID, $u_id); $c->addAscendingOrderByColumn(UserRidesPeer::DESCRIPTION); $rs = UserRidesPeer::doSelect($c); return $rs; } else { return null; } }
/** * Gets an array of UserRides 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 Rides has previously been saved, it will retrieve * related UserRidess from storage. If this Rides 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 UserRides[] * @throws PropelException */ public function getUserRidess($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(RidesPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collUserRidess === null) { if ($this->isNew()) { $this->collUserRidess = array(); } else { $criteria->add(UserRidesPeer::RIDE_ID, $this->ride_key); UserRidesPeer::addSelectColumns($criteria); $this->collUserRidess = UserRidesPeer::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(UserRidesPeer::RIDE_ID, $this->ride_key); UserRidesPeer::addSelectColumns($criteria); if (!isset($this->lastUserRidesCriteria) || !$this->lastUserRidesCriteria->equals($criteria)) { $this->collUserRidess = UserRidesPeer::doSelect($criteria, $con); } } } $this->lastUserRidesCriteria = $criteria; return $this->collUserRidess; }
/** * 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(UserRidesPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(UserRidesPeer::DATABASE_NAME); $criteria->add(UserRidesPeer::USER_RIDE_ID, $pks, Criteria::IN); $objs = UserRidesPeer::doSelect($criteria, $con); } return $objs; }
public function executeDelete() { $userId = sfContext::getInstance()->getUser()->getAttribute('subscriber_id', null, 'subscriber'); $rId = $this->getRequestParameter('rideid'); $this->rideid = $rId; sfContext::getInstance()->getLogger()->info('@@@@@@@@@@@@@@@Deleeting ride ' . $this->rideid); if ($this->getRequest()->getMethod() == sfRequest::POST) { //delete user maps $c = new Criteria(); $c->add(UserRideMapPeer::USER_RIDE_ID, $rId); $mapPoints = UserRideMapPeer::doSelect($c); if ($mapPoints) { foreach ($mapPoints as $p) { $p->delete(); } } //delete user_stat and equipment $c = new Criteria(); $c->add(UserStatsPeer::USER_ID, $userId); $c->add(UserStatsPeer::RIDE_KEY, $rId); $s = UserStatsPeer::doSelectJoinAll($c); foreach ($s as $stat) { foreach ($stat->getUserStatEquips() as $equip) { $equip->delete(); } $stat->delete(); } //now delete userride $c = new Criteria(); $c->add(UserRidesPeer::USER_ID, $userId); $c->add(UserRidesPeer::USER_RIDE_ID, $rId); $rides = UserRidesPeer::doSelect($c); foreach ($rides as $r) { $r->delete(); } return $this->redirect('userrides/index'); } }