public function deleteOldReservationOtherMembers() { $r_id = $this->getObject()->getId(); if (!is_null($r_id) && !empty($r_id)) { $c = new Criteria(); $c->add(ReservationOtherMembersPeer::RESERVATION_ID, $r_id); $o_members = ReservationOtherMembersPeer::doSelect($c); if (!is_null($o_members)) { foreach ($o_members as $member) { $member->delete(); } } } }
/** * Gets an array of ReservationOtherMembers 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 User has previously been saved, it will retrieve * related ReservationOtherMemberss from storage. If this User 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 ReservationOtherMembers[] * @throws PropelException */ public function getReservationOtherMemberss($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(UserPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collReservationOtherMemberss === null) { if ($this->isNew()) { $this->collReservationOtherMemberss = array(); } else { $criteria->add(ReservationOtherMembersPeer::USER_ID, $this->id); ReservationOtherMembersPeer::addSelectColumns($criteria); $this->collReservationOtherMemberss = ReservationOtherMembersPeer::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(ReservationOtherMembersPeer::USER_ID, $this->id); ReservationOtherMembersPeer::addSelectColumns($criteria); if (!isset($this->lastReservationOtherMembersCriteria) || !$this->lastReservationOtherMembersCriteria->equals($criteria)) { $this->collReservationOtherMemberss = ReservationOtherMembersPeer::doSelect($criteria, $con); } } } $this->lastReservationOtherMembersCriteria = $criteria; return $this->collReservationOtherMemberss; }
/** * 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(ReservationOtherMembersPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(ReservationOtherMembersPeer::DATABASE_NAME); $criteria->add(ReservationOtherMembersPeer::ID, $pks, Criteria::IN); $objs = ReservationOtherMembersPeer::doSelect($criteria, $con); } return $objs; }
public function setDefaultCustomUsers() { $r_id = $this->getObject()->getId(); //print ('Current reservation ID: '.$r_id.'<br/>'); if (!is_null($r_id) && !empty($r_id)) { $c = new Criteria(); $c->add(ReservationOtherMembersPeer::RESERVATION_ID, $r_id); $o_members = ReservationOtherMembersPeer::doSelect($c); //print ('All other members: <br/>'); //print_r($o_members); $values = array(); if (!is_null($o_members)) { foreach ($o_members as $member) { $values[] = $member->getUserId(); } } $this->setDefault('reservation_has_user_list', $values); } }
public function getAllPersons() { $persons = array(); if (!is_null($this->getUser())) { $usergroup = $this->getUsergroup(); if (!is_null($usergroup)) { $users = $usergroup->getMembers(); foreach ($users as $user) { $persons[] = $user; } } else { $persons[] = $this->getUser(); } $c = new Criteria(); $c->add(ReservationOtherMembersPeer::RESERVATION_ID, $this->getId()); $uniquePersonsArray = array(); // Initialize the unique Person ID array foreach ($persons as $p) { $uniquePersonsArray[$p->getId()] = 1; } $other_members = ReservationOtherMembersPeer::doSelect($c); if (!is_null($other_members)) { foreach ($other_members as $member) { if (isset($uniquePersonsArray[$member->getUserId()])) { // Do nothing, the user is already in the list } else { $persons[] = UserPeer::retrieveByPK($member->getUserId()); $uniquePersonsArray[$member->getUserId()] = 1; } } } } else { if (!is_null($this->getCard())) { $persons[] = $this->getCard(); } } return $persons; }