/** * Gets an array of ImagesHasProduct 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 Images has previously been saved, it will retrieve * related ImagesHasProducts from storage. If this Images 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 ImagesHasProduct[] * @throws PropelException */ public function getImagesHasProducts($criteria = null, PropelPDO $con = null) { if ($criteria === null) { $criteria = new Criteria(ImagesPeer::DATABASE_NAME); } elseif ($criteria instanceof Criteria) { $criteria = clone $criteria; } if ($this->collImagesHasProducts === null) { if ($this->isNew()) { $this->collImagesHasProducts = array(); } else { $criteria->add(ImagesHasProductPeer::IMAGES_ID, $this->id); ImagesHasProductPeer::addSelectColumns($criteria); $this->collImagesHasProducts = ImagesHasProductPeer::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(ImagesHasProductPeer::IMAGES_ID, $this->id); ImagesHasProductPeer::addSelectColumns($criteria); if (!isset($this->lastImagesHasProductCriteria) || !$this->lastImagesHasProductCriteria->equals($criteria)) { $this->collImagesHasProducts = ImagesHasProductPeer::doSelect($criteria, $con); } } } $this->lastImagesHasProductCriteria = $criteria; return $this->collImagesHasProducts; }
/** * Retrieve object using using composite pkey values. * @param int $images_id * @param int $product_id * @param PropelPDO $con * @return ImagesHasProduct */ public static function retrieveByPK($images_id, $product_id, PropelPDO $con = null) { $key = serialize(array((string) $images_id, (string) $product_id)); if (null !== ($obj = ImagesHasProductPeer::getInstanceFromPool($key))) { return $obj; } if ($con === null) { $con = Propel::getConnection(ImagesHasProductPeer::DATABASE_NAME, Propel::CONNECTION_READ); } $criteria = new Criteria(ImagesHasProductPeer::DATABASE_NAME); $criteria->add(ImagesHasProductPeer::IMAGES_ID, $images_id); $criteria->add(ImagesHasProductPeer::PRODUCT_ID, $product_id); $v = ImagesHasProductPeer::doSelect($criteria, $con); return !empty($v) ? $v[0] : null; }