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