/** * Resets all references to other model objects or collections of model objects. * * This method is a user-space workaround for PHP's inability to garbage collect * objects with circular references (even in PHP 5.3). This is currently necessary * when using Propel in certain daemon or large-volume/high-memory operations. * * @param boolean $deep Whether to also clear the references on all referrer objects. */ public function clearAllReferences($deep = false) { if ($deep && !$this->alreadyInClearAllReferencesDeep) { $this->alreadyInClearAllReferencesDeep = true; if ($this->aProduct instanceof Persistent) { $this->aProduct->clearAllReferences($deep); } $this->alreadyInClearAllReferencesDeep = false; } // if ($deep) $this->aProduct = null; }
/** * Filter the query by a related Product object * * @param Product|PropelObjectCollection $product The related object(s) to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return ProductSurveyQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { if ($product instanceof Product) { return $this->addUsingAlias(ProductSurveyPeer::PRODUCT_ID, $product->getId(), $comparison); } elseif ($product instanceof PropelObjectCollection) { if (null === $comparison) { $comparison = Criteria::IN; } return $this->addUsingAlias(ProductSurveyPeer::PRODUCT_ID, $product->toKeyValue('PrimaryKey', 'Id'), $comparison); } else { throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); } }
/** * Filter the query by a related Product object * * @param Product|PropelObjectCollection $product the related object to use as filter * @param string $comparison Operator to use for the column comparison, defaults to Criteria::EQUAL * * @return PrincipalQuery The current query, for fluid interface * @throws PropelException - if the provided filter is invalid. */ public function filterByProduct($product, $comparison = null) { if ($product instanceof Product) { return $this->addUsingAlias(PrincipalPeer::ID, $product->getPrincipalId(), $comparison); } elseif ($product instanceof PropelObjectCollection) { return $this->useProductQuery()->filterByPrimaryKeys($product->getPrimaryKeys())->endUse(); } else { throw new PropelException('filterByProduct() only accepts arguments of type Product or PropelCollection'); } }
/** * @param Product $product The product object to add. */ protected function doAddProduct($product) { $this->collProducts[] = $product; $product->setPrincipal($this); }
/** * Exclude object from result * * @param Product $product Object to remove from the list of results * * @return ProductQuery The current query, for fluid interface */ public function prune($product = null) { if ($product) { $this->addUsingAlias(ProductPeer::ID, $product->getId(), Criteria::NOT_EQUAL); } return $this; }
/** * Adds an object to the instance pool. * * Propel keeps cached copies of objects in an instance pool when they are retrieved * from the database. In some cases -- especially when you override doSelect*() * methods in your stub classes -- you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by doSelect*() * and retrieveByPK*() calls. * * @param Product $obj A Product object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool($obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getId(); } // if key === null ProductPeer::$instances[$key] = $obj; } }
/** * Exchange the rank of the object with the one passed as argument, and saves both objects * * @param Product $object * @param PropelPDO $con optional connection * * @return Product the current object * * @throws Exception if the database cannot execute the two updates */ public function swapWith($object, PropelPDO $con = null) { if ($con === null) { $con = Propel::getConnection(ProductPeer::DATABASE_NAME); } $con->beginTransaction(); try { $oldRank = $this->getSortableRank(); $newRank = $object->getSortableRank(); $this->setSortableRank($newRank); $this->save($con); $object->setSortableRank($oldRank); $object->save($con); $con->commit(); return $this; } catch (Exception $e) { $con->rollback(); throw $e; } }