コード例 #1
0
 /**
  * Retrieve object using using composite pkey values.
  * @param      int $element_series_id
  * @param      int $product_id
  * @param      PropelPDO $con
  * @return     ElementSeriesHasProduct
  */
 public static function retrieveByPK($element_series_id, $product_id, PropelPDO $con = null)
 {
     $key = serialize(array((string) $element_series_id, (string) $product_id));
     if (null !== ($obj = ElementSeriesHasProductPeer::getInstanceFromPool($key))) {
         return $obj;
     }
     if ($con === null) {
         $con = Propel::getConnection(ElementSeriesHasProductPeer::DATABASE_NAME, Propel::CONNECTION_READ);
     }
     $criteria = new Criteria(ElementSeriesHasProductPeer::DATABASE_NAME);
     $criteria->add(ElementSeriesHasProductPeer::ELEMENT_SERIES_ID, $element_series_id);
     $criteria->add(ElementSeriesHasProductPeer::PRODUCT_ID, $product_id);
     $v = ElementSeriesHasProductPeer::doSelect($criteria, $con);
     return !empty($v) ? $v[0] : null;
 }
コード例 #2
0
 /**
  * Gets an array of ElementSeriesHasProduct 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 ElementSeries has previously been saved, it will retrieve
  * related ElementSeriesHasProducts from storage. If this ElementSeries 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 ElementSeriesHasProduct[]
  * @throws     PropelException
  */
 public function getElementSeriesHasProducts($criteria = null, PropelPDO $con = null)
 {
     if ($criteria === null) {
         $criteria = new Criteria(ElementSeriesPeer::DATABASE_NAME);
     } elseif ($criteria instanceof Criteria) {
         $criteria = clone $criteria;
     }
     if ($this->collElementSeriesHasProducts === null) {
         if ($this->isNew()) {
             $this->collElementSeriesHasProducts = array();
         } else {
             $criteria->add(ElementSeriesHasProductPeer::ELEMENT_SERIES_ID, $this->id);
             ElementSeriesHasProductPeer::addSelectColumns($criteria);
             $this->collElementSeriesHasProducts = ElementSeriesHasProductPeer::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(ElementSeriesHasProductPeer::ELEMENT_SERIES_ID, $this->id);
             ElementSeriesHasProductPeer::addSelectColumns($criteria);
             if (!isset($this->lastElementSeriesHasProductCriteria) || !$this->lastElementSeriesHasProductCriteria->equals($criteria)) {
                 $this->collElementSeriesHasProducts = ElementSeriesHasProductPeer::doSelect($criteria, $con);
             }
         }
     }
     $this->lastElementSeriesHasProductCriteria = $criteria;
     return $this->collElementSeriesHasProducts;
 }