/** * 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 you may need to explicitly add objects * to the cache in order to ensure that the same objects are always returned by find*() * and findPk*() calls. * * @param $obj A 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 (null === $key) { $key = ; } // if key === null self::$instances[$key] = $obj; } } /** * Removes an object from 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 doDelete * methods in your stub classes -- you may need to explicitly remove objects * from the cache in order to prevent returning objects that no longer exist. * * @param mixed $value A object or a primary key value. */ public static function removeInstanceFromPool($value) { if (Propel::isInstancePoolingEnabled() && null !== $value) { if (\is_object($value) && $value instanceof ) { $key = ; } elseif (\is_array($value) && count($value) === ) { // assume we've been passed a primary key"; $key = ; } elseif ($value instanceof Criteria) { self::$instances = []; return; } else { $e = new PropelException("Invalid value passed to removeInstanceFromPool(). Expected primary key or object; got " . (\is_object($value) ? \get_class($value) . ' object.' : var_export($value, true))); throw $e; } unset(self::$instances[$key]); } }