/** * 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 Cessiomaterial $value A Cessiomaterial object. * @param string $key (optional) key to use for instance map (for performance boost if key was already calculated externally). */ public static function addInstanceToPool(Cessiomaterial $obj, $key = null) { if (Propel::isInstancePoolingEnabled()) { if ($key === null) { $key = (string) $obj->getIdcessiomaterial(); } // if key === null self::$instances[$key] = $obj; } }
public static function update($RMATERIAL, $FCessio, $idS) { $MERGE = array(); $OC = $FCessio->getObject(); $idC = $OC->getCessioId(); $ERROR = array(); $C = new Criteria(); $C->add(self::SITE_ID, $idS); $C->add(self::CESSIO_ID, $idC); $C->add(self::ACTIU, true); foreach ($RMATERIAL as $D => $idM) { if (!MaterialPeer::isLliureFranja($idM, $idS, $OC->getDatacessio(), $OC->getDataRetorn(), '00:00', '24:00', null, $idC)) { $OM = MaterialPeer::retrieveByPK($idM); $ERROR[$idM] = $OM->toString(); } } if (empty($ERROR)) { foreach (self::doSelect($C) as $V) { $V->setActiu(false); $V->save(); $MERGE[$V->getIdcessiomaterial()] = $V; } foreach ($RMATERIAL as $D => $idM) { if (isset($MERGE[$idM])) { $MERGE[$idM]->setActiu(true); $MERGE[$idM]->save(); } else { $OMC = new Cessiomaterial(); $OMC->setMaterialIdmaterial($idM); $OMC->setCessioId($idC); $OMC->setSiteId($idS); $OMC->setActiu(true); $OMC->save(); } } } return $ERROR; }