protected function addRemoveInstanceFromPool(&$script)
    {
        $table = $this->getTable();
        $script .= "
    /**
     * 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 " . $this->getObjectClassname() . " object or a primary key value.
     *
     * @return void
     * @throws PropelException - if the value is invalid.
     */
    public static function removeInstanceFromPool(\$value)
    {";
        $script .= "
        if (Propel::isInstancePoolingEnabled() && \$value !== null) {";
        $pks = $table->getPrimaryKey();

        $script .= "
            if (is_object(\$value) && \$value instanceof " . $this->getObjectClassname() . ") {";

        $php = array();
        foreach ($pks as $pk) {
            $php[] = '$value->get' . $pk->getPhpName() . '()';
        }
        $script .= "
                \$key = " . $this->getInstancePoolKeySnippet($php) . ";";

        $script .= "
            } elseif (" . (count($pks) > 1 ? "is_array(\$value) && count(\$value) === " . count($pks) : "is_scalar(\$value)") . ") {
                // assume we've been passed a primary key";

        if (count($pks) > 1) {
            $php = array();
            for ($i = 0; $i < count($pks); $i++) {
                $php[] = "\$value[$i]";
            }
        } else {
            $php = '$value';
        }
        $script .= "
                \$key = " . $this->getInstancePoolKeySnippet($php) . ";";
        $script .= "
            } else {
                \$e = new PropelException(\"Invalid value passed to removeInstanceFromPool().  Expected primary key or " . $this->getObjectClassname() . " object; got \" . (is_object(\$value) ? get_class(\$value) . ' object.' : var_export(\$value,true)));
                throw \$e;
            }

            unset(" . $this->getPeerClassname() . "::\$instances[\$key]);
        }
    } // removeInstanceFromPool()
";
    }