/** * Returns the number of related ZoneHasRoom objects. * * @param Criteria $criteria * @param boolean $distinct * @param PropelPDO $con * @return int Count of related ZoneHasRoom objects. * @throws PropelException */ public function countZoneHasRooms(Criteria $criteria = null, $distinct = false, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ZonePeer::DATABASE_NAME); } else { $criteria = clone $criteria; } if ($distinct) { $criteria->setDistinct(); } $count = null; if ($this->collZoneHasRooms === null) { if ($this->isNew()) { $count = 0; } else { $criteria->add(ZoneHasRoomPeer::ZONE_ID, $this->id); $count = ZoneHasRoomPeer::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(ZoneHasRoomPeer::ZONE_ID, $this->id); if (!isset($this->lastZoneHasRoomCriteria) || !$this->lastZoneHasRoomCriteria->equals($criteria)) { $count = ZoneHasRoomPeer::doCount($criteria, $con); } else { $count = count($this->collZoneHasRooms); } } else { $count = count($this->collZoneHasRooms); } } return $count; }
public function hasDirectRoom($room) { if (is_null($room)) { return false; } $c = new Criteria(); $c->add(ZoneHasRoomPeer::ZONE_ID, $this->getId(), Criteria::EQUAL); $c->addAnd(ZoneHasRoomPeer::ROOM_ID, $room->getId(), Criteria::EQUAL); return ZoneHasRoomPeer::doCount($c) > 0; }