/** * Gets an array of ZoneHasRoom 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 Zone has previously been saved, it will retrieve * related ZoneHasRooms from storage. If this Zone 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 ZoneHasRoom[] * @throws PropelException */ public function getZoneHasRooms($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ZonePeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collZoneHasRooms === null) { if ($this->isNew()) { $this->collZoneHasRooms = array(); } else { $criteria->add(ZoneHasRoomPeer::ZONE_ID, $this->id); ZoneHasRoomPeer::addSelectColumns($criteria); $this->collZoneHasRooms = ZoneHasRoomPeer::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(ZoneHasRoomPeer::ZONE_ID, $this->id); ZoneHasRoomPeer::addSelectColumns($criteria); if (!isset($this->lastZoneHasRoomCriteria) || !$this->lastZoneHasRoomCriteria->equals($criteria)) { $this->collZoneHasRooms = ZoneHasRoomPeer::doSelect($criteria, $con); } } } $this->lastZoneHasRoomCriteria = $criteria; return $this->collZoneHasRooms; }
/** * Retrieve object using using composite pkey values. * @param int $zone_id @param int $room_id * @param PropelPDO $con * @return ZoneHasRoom */ public static function retrieveByPK($zone_id, $room_id, PropelPDO $con = null) { $key = serialize(array((string) $zone_id, (string) $room_id)); if (null !== ($obj = ZoneHasRoomPeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(ZoneHasRoomPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(ZoneHasRoomPeer::DATABASE_NAME); $criteria->add(ZoneHasRoomPeer::ZONE_ID, $zone_id); $criteria->add(ZoneHasRoomPeer::ROOM_ID, $room_id); $v = ZoneHasRoomPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }