getDatabase(); if($table->getPackage()) { $package = $table->getPackage(); } else { $package = $targetPackage; } echo '<' . '?' . 'php'; $basePeerClass = ClassTools::getBasePeer($table); $basePeerClassname = ClassTools::classname($basePeerClass); ?> require_once ''; // The object class -- needed for instanceof checks in this class. // actual class may be a subclass -- as returned by getPhpName() ?>Peer::getOMClass() include_once 'getPhpName()) ?>'; getForeignKeys() as $fk) { $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $tblFKPackage = ($tblFK->getPackage() ? $tblFK->getPackage() : $package); if (!$tblFK->isForReferenceOnly()) { ?> include_once 'getPhpName()) ?>'; include_once 'getPhpName() . 'Peer') ?>'; isForReferenceOnly() } // foreach ?> /** * Base static class for performing query and update operations on the 'getName() ?>' table. * * getDescription() ?> * * This class was autogenerated by Propel on: * * [] * * @package */ abstract class getPhpName() ?>Peer { isAlias()) { ?> /** the default database name for this class */ const DATABASE_NAME = "getDatabase()->getName() ?>"; /** the table name for this class */ const TABLE_NAME = "getName() ?>"; getColumns() as $col) { ?> /** the column name for the getName()) ?> field */ const = "getName() . '.' . strtoupper($col->getName()) ?>"; isAlias()) */ ?> /** number of columns for this peer */ public static $numColumns = getNumColumns() ?>; /** number of lazy load columns for this peer */ public static $numLazyLoadColumns = getNumLazyLoadColumns() ?>; /** A class that can be returned by this peer. */ const CLASS_DEFAULT = "getPhpName() ?>"; /** The PHP to DB Name Mapping */ private static $phpNameMap = null; /** * @return MapBuilder the map builder for this peer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getMapBuilder() { include_once 'getPhpName() . 'MapBuilder') ?>'; return ::getMapBuilder(getPhpName() ?>MapBuilder::CLASS_NAME); } /** * Gets a map (hash) of PHP names to DB column names. * * @return array The PHP to DB name map for this peer * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @todo Consider having template build the array rather than doing it at runtime. */ public static function getPhpNameMap() { if (self::$phpNameMap === null) { $map = getPhpName() ?>Peer::getTableMap(); $columns = $map->getColumns(); $nameMap = array(); foreach ($columns as $column) { $nameMap[$column->getPhpName()] = $column->getColumnName(); } self::$phpNameMap = $nameMap; } return self::$phpNameMap; } isAlias()) { if ($table->getChildrenColumn()) { $col = $table->getChildrenColumn(); $tfc = $table->getPhpName(); $cfc = $col->getPhpName(); if ($col->isEnumeratedClasses()) { if ($col->isPrimitiveNumeric()) $quote = ""; else $quote = '"'; foreach ($col->getChildren() as $child) { ?> /** A key representing a particular subclass */ const CLASSKEY_getKey()) ?> = getKey() . $quote ?>; /** A class that can be returned by this peer. */ const CLASSNAME_getKey()) ?> = "getClassName() ?>"; isenumerated...() */ } /* if table->getchildrencolumn() */ ?> /** * Convenience method which changes table.column to alias.column. * * Using this method you can maintain SQL abstraction while using column aliases. * * $c->addAlias("alias1", TablePeer::TABLE_NAME); * $c->addJoin(TablePeer::alias("alias1", TablePeer::PRIMARY_KEY_COLUMN), TablePeer::PRIMARY_KEY_COLUMN); * * @param string $alias The alias for the current table. * @param string $column The column name for current table. (i.e. getPhpName() ?>Peer::COLUMN_NAME). * @return string */ public static function alias($alias, $column) { return $alias . substr($column, strlen(self::TABLE_NAME)); } /** * Add all the columns needed to create a new object. * * Note: any columns that were marked with lazyLoad="true" in the * XML schema will not be added to the select list and only loaded * on demand. * * @param criteria object containing the columns to add. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function addSelectColumns(Criteria $criteria) { getColumns() as $col) { if (!$col->isLazyLoad()) { ?> $criteria->addSelectColumn(self::); } hasPrimaryKey()) { $pk = $table->getPrimaryKey(); $count_col = $table->getName() . "." . strtoupper($pk[0]->getName()); } ?> const COUNT = "COUNT()"; const COUNT_DISTINCT = "COUNT(DISTINCT )"; /** * Returns the number of rows matching criteria. * * @param Criteria $criteria * @param boolean $distinct Whether to select only distinct columns. * @param Connection $con * @return int Number of matching rows. */ public static function doCount(Criteria $criteria, $distinct = false, $con = null) { // we're going to modify criteria, so copy it first $criteria = clone $criteria; // clear out anything that might confuse the ORDER BY clause $criteria->clearSelectColumns()->clearOrderByColumns(); if ($distinct || in_array(Criteria::DISTINCT, $criteria->getSelectModifiers())) { $criteria->addSelectColumn(getPhpName()?>Peer::COUNT_DISTINCT); } else { $criteria->addSelectColumn(getPhpName()?>Peer::COUNT); } $rs = getPhpName()?>Peer::doSelectRS($criteria, $con); if ($rs->next()) { return $rs->getInt(1); } else { // no rows returned; we infer that means 0 matches. return 0; } } /** * Method to select one object from the DB. * * @param Criteria $criteria object used to create the SELECT statement. * @param Connection $con * @return getPhpName() ?> * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectOne(Criteria $criteria, $con = null) { $critcopy = clone $criteria; $critcopy->setLimit(1); $objects = getPhpName() ?>Peer::doSelect($critcopy, $con); if ($objects) { return $objects[0]; } return null; } /** * Method to do selects. * * @param Criteria $criteria The Criteria object used to build the SELECT statement. * @param Connection $con * @return array Array of selected Objects * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelect(Criteria $criteria, $con = null) { return getPhpName() ?>Peer::populateObjects(getPhpName() ?>Peer::doSelectRS($criteria, $con)); } /** * Prepares the Criteria object and uses the parent doSelect() * method to get a ResultSet. * * Use this method directly if you want to just get the resultset * (instead of an array of objects). * * @param Criteria $criteria The Criteria object used to build the SELECT statement. * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. * @return ResultSet The resultset object with numerically-indexed fields. * @see ::doSelect() */ public static function doSelectRS(Criteria $criteria, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } if (!$criteria->getSelectColumns()) { getPhpName() ?>Peer::addSelectColumns($criteria); } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); // BasePeer returns a Creole ResultSet, set to return // rows indexed numerically. return ::doSelect($criteria, $con); } /** * The returned array will contain objects of the default type or * objects that inherit from the default. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function populateObjects(ResultSet $rs) { $results = array(); getChildrenColumn()) { ?> // set the class once to avoid overhead in the loop $cls = getPhpName() ?>Peer::getOMClass(); $cls = Propel::import($cls); // populate the object(s) while($rs->next()) { getChildrenColumn()) { ?> // class must be set each time from the record row $cls = Propel::import(getPhpName() ?>Peer::getOMClass($rs, 1)); $obj = new $cls(); $obj->hydrate($rs); $results[] = $obj; $obj = new $cls(); $obj->hydrate($rs); $results[] = $obj; } return $results; } isAlias() */ ?> getChildrenColumn()) { $col = $table->getChildrenColumn(); ?> /** * The returned Class will contain objects of the default type or * objects that inherit from the default. * * @param ResultSet $rs ResultSet with pointer to record containing om class. * @param int $colnum Column to examine for OM class information (first is 1). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass(ResultSet $rs, $colnum) { $c = null; try { isEnumeratedClasses()) { ?> $omClass = null; $classKey = $rs->getString($colnum - 1 + getPosition() ?>); switch($classKey) { getChildren() as $child) { ?> case self::CLASSKEY_getKey()) ?>: $omClass = self::CLASSNAME_getKey()) ?>; break; default: isAbstract()) { ?> $error = "You must implement the getOMClass method in your" ." Peer object in order for things to work properly." ." This method should return the proper Class that" ." represents the Peer's Business Object."; throw new PropelException($error); $omClass = self::CLASS_DEFAULT; } // switch $c = $omClass; $c = Propel::import($rs->getString($colnum - 1 + getPosition() ?>)); } catch (Exception $e) { throw new PropelException("Unable to get OM class.", $e); } return $c; } getchildrencolumn */ ?> /** * The class that the Peer will make instances of. * If the BO is abstract then you must implement this method * in the BO. * * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function getOMClass() {isAbstract()) { ?> $error = "You must implement the getOMClass method in your" ." Peer object in order for things to work properly." ." This method should return the proper Class that" ." represents the Peer's Business Object."; throw new PropelException($error); return self::CLASS_DEFAULT; } getchildrencolumn */ if (!$table->isAlias() && !$table->isReadOnly()) { ?> /** * Method perform an INSERT on the database, given a getPhpName() ?> or Criteria object. * * @param mixed $values Criteria or getPhpName() ?> object containing data that is used to create the INSERT statement. * @param Connection $con the connection to use * @return mixed The new primary key. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doInsert($values, $con = null) { if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = $values; } else { $criteria = $values->buildCriteria(); } getColumns() as $col) { $cfc = $col->getPhpName(); if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none") { ?> $criteria->remove(self::); // remove pkey col since this table uses auto-increment // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); try { // use transaction because $criteria could contain info // for more than one table (I guess, conceivably) $con->begin(); $pk = ::doInsert($criteria, $con); $con->commit(); } catch(PropelException $e) { $con->rollback(); throw $e; } return $pk; } supportsNativeDeleteTrigger() && count($table->getReferrers()) > 0) { foreach ($table->getReferrers() as $fk) { if ( $fk->getOnDelete() == ForeignKey::CASCADE ) { $deleteCascadeRelevant = true; } elseif ($fk->getOnDelete() == ForeignKey::SETNULL) { $deleteSetNullRelevant = true; } } } // if count(foreign keys) ?> /** * Method perform an UPDATE on the database, given a getPhpName() ?> or Criteria object. * * @param mixed $values Criteria or getPhpName() ?> object containing data that is used to create the UPDATE statement. * @param Connection $con The connection to use (specify Connection object to exert more control over transactions). * @return int The number of affected rows (if supported by underlying database driver). * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doUpdate($values, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $selectCriteria = new Criteria(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = $values; getColumns() as $col) { if($col->isPrimaryKey()) { ?> $selectCriteria->put(self::, $criteria->remove(self::)); } else { // $values is getPhpName() ?> object $criteria = $values->buildCriteria(); // gets full criteria $selectCriteria = $values->buildPkeyCriteria(); // gets criteria w/ primary key(s) } // set the correct dbName $criteria->setDbName(self::DATABASE_NAME); return ::doUpdate($selectCriteria, $criteria, $con); } /** * Method to DELETE all rows from the getName() ?> table. * * @return int The number of affected rows (if supported by underlying database driver). */ public static function doDeleteAll($con = null) { if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->begin(); $affectedRows += getPhpName() ?>Peer::doOnDeleteCascade(new Criteria(), $con); getPhpName() ?>Peer::doOnDeleteSetNull(new Criteria(), $con); $affectedRows += BasePeer::doDeleteAll(self::TABLE_NAME, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } } /** * Method perform a DELETE on the database, given a getPhpName() ?> or Criteria object OR a primary key value. * * @param mixed $values Criteria or getPhpName() ?> object or primary key which is used to create the DELETE statement * @param Connection $con the connection to use * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows * if supported by native driver or if emulated using Propel. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doDelete($values, $con = null) { if ($con === null) $con = Propel::getConnection(self::DATABASE_NAME); if ($values instanceof Criteria) { $criteria = $values; } elseif ($values instanceof getPhpName() ?>) { getColumns() as $col) { if($col->isPrimaryKey()) $pkey_count++; } if ($pkey_count > 0) { ?> $criteria = $values->buildPkeyCriteria(); $criteria = $values->buildCriteria(); } else { // it must be the primary key $criteria = new Criteria(self::DATABASE_NAME); getPrimaryKey()) == 1) { $col = array_shift($table->getPrimaryKey()); ?> $criteria->add(self::, $values); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey // values getPrimaryKey() as $col) { ?> $criteria->add(self::, $values[]); } // Set the correct dbName $criteria->setDbName(self::DATABASE_NAME); $affectedRows = 0; // initialize var to track total num of affected rows try { // use transaction because $criteria could contain info // for more than one table or we could emulating ON DELETE CASCADE, etc. $con->begin(); $affectedRows += getPhpName() ?>Peer::doOnDeleteCascade($criteria, $con); getPhpName() ?>Peer::doOnDeleteSetNull($criteria, $con); $affectedRows += ::doDelete($criteria, $con); $con->commit(); return $affectedRows; } catch (PropelException $e) { $con->rollback(); throw $e; } } /** * This is a method for emulating ON DELETE CASCADE for DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param Connection $con * @return int The number of affected rows (if supported by underlying database driver). */ protected static function doOnDeleteCascade(Criteria $criteria, Connection $con) { // initialize var to track total num of affected rows $affectedRows = 0; // first find the objects that are implicated by the $criteria $objects = getPhpName() ?>Peer::doSelect($criteria, $con); foreach($objects as $obj) { getReferrers() as $fk) { // $fk is the foreign key in the other table, so localTableName will // actually be the table name of other table $tblFK = $fk->getTable(); $tblFKPackage = ($tblFK->getPackage() ? $tblFK->getPackage() : $package); if (!$tblFK->isForReferenceOnly()) { // we can't perform operations on tables that are // not within the schema (i.e. that we have no map for, etc.) $fkClassName = $tblFK->getPhpName(); // i'm not sure whether we can allow delete cascade for foreign keys // within the same table? perhaps we can? if ( $fk->getOnDelete() == ForeignKey::CASCADE && $fk->getTable()->getName() != $table->getName()) { // backwards on purpose $columnNamesF = $fk->getLocalColumns(); $columnNamesL = $fk->getForeignColumns(); // should be same num as foreign ?> include_once 'getPhpName()); ?>'; // delete related objects $c = new Criteria(); getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); ?>$c->add(, $obj->getgetPhpName() ?>()); $affectedRows += Peer::doDelete($c, $con); } return $affectedRows; } /** * This is a method for emulating ON DELETE SET NULL DBs that don't support this * feature (like MySQL or SQLite). * * This method is not very speedy because it must perform a query first to get * the implicated records and then perform the deletes by calling those Peer classes. * * This method should be used within a transaction if possible. * * @param Criteria $criteria * @param Connection $con * @return void */ protected static function doOnDeleteSetNull(Criteria $criteria, Connection $con) { // first find the objects that are implicated by the $criteria $objects = getPhpName() ?>Peer::doSelect($criteria, $con); foreach($objects as $obj) { getReferrers() as $fk) { // $fk is the foreign key in the other table, so localTableName will // actually be the table name of other table $tblFK = $fk->getTable(); if (!$tblFK->isForReferenceOnly()) { // we can't perform operations on tables that are // not within the schema (i.e. that we have no map for, etc.) $fkClassName = $tblFK->getPhpName(); // i'm not sure whether we can allow delete setnull for foreign keys // within the same table? perhaps we can? if ( $fk->getOnDelete() == ForeignKey::SETNULL && $fk->getTable()->getName() != $table->getName()) { // backwards on purpose $columnNamesF = $fk->getLocalColumns(); $columnNamesL = $fk->getForeignColumns(); // should be same num as foreign ?> // set fkey col in related rows to NULL $selectCriteria = new Criteria(self::DATABASE_NAME); $updateValues = new Criteria(self::DATABASE_NAME); getColumn($columnNamesF[$x]); $columnL = $table->getColumn($columnNamesL[$x]); ?>$selectCriteria->add(, $obj->getgetPhpName() ?>()); $updateValues->add(, null); ::doUpdate($selectCriteria, $updateValues, $con); // use BasePeer because generated Peer doUpdate() methods only update using pkey } } /** * Validates all modified columns of given getPhpName()?> object. * If parameter $columns is either a single column name or an array of column names * than only those columns are validated. * * NOTICE: This does not apply to primary or foreign keys for now. * * @param getPhpName()?> $obj The object to validate. * @param mixed $cols Column name or array of column names. * * @return mixed TRUE if all columns are valid or the error message of the first invalid column. */ public static function doValidate(getPhpName()?> $obj, $cols = null) { $columns = array(); if ($cols) { $dbMap = Propel::getDatabaseMap(self::DATABASE_NAME); $tableMap = $dbMap->getTable(self::TABLE_NAME); if (! is_array($cols)) { $cols = array($cols); } foreach($cols as $colName) { if ($tableMap->containsColumn($colName)) { $get = 'get' . $tableMap->getColumn($colName)->getPhpName(); $columns[$colName] = $obj->$get(); } } } else { getValidators() as $val) { $col = $val->getColumn(); if (! $col->isAutoIncrement()) { $cfc = $col->getPhpName(); ?> if ($obj->isNew() || $obj->isColumnModified(self::)) $columns[self::] = $obj->get(); } return ::doValidate(self::DATABASE_NAME, self::TABLE_NAME, $columns); } isalias */ ?> getPrimaryKey()) > 0) { if ($table->isAlias()) { $retrieveMethod = "retrieve" . $table->getPhpName() . "ByPK"; } else { $retrieveMethod = "retrieveByPK"; } $pks = $table->getPrimaryKey(); if (count($table->getPrimaryKey()) === 1) { ?> /** * Retrieve a single object by pkey or NULL if not found. * * @param mixed $pk the primary key. * @param Connection $con the connection to use * @return getPhpName() . "\n" ?> */ public static function ($pk, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(self::DATABASE_NAME); getPrimaryKey()) === 1) { $col = array_shift($table->getPrimaryKey()); ?> $criteria->add(self::, $pk); // primary key is composite; we therefore, expect // the primary key passed to be an array of pkey // values getPrimaryKey() as $col) { ?> $criteria->add(self::, $pk[]); $v = getPhpName() ?>Peer::doSelect($criteria, $con); return count($v) > 0 ? $v[0] : null; } /** * Retrieve multiple objects by pkey. * * @param array $pks List of primary keys * @param Connection $con the connection to use * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function s($pks, $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $objs = null; if (empty($pks)) { $objs = array(); } else { $criteria = new Criteria(); getPrimaryKey()) == 1) { ?> $criteria->add(self::getPrimaryKey(); echo PeerBuilder::getColumnName($k1[0]); ?>, $pks, Criteria::IN); for($k=0,$size=count($pks); $k < $size; $k++) { $pk = $pks[$k]; getPrimaryKey() as $col) { ?> $c = $criteria->getNewCriterion(self::, $pk[], Criteria::EQUAL); 0) { ?> $c->addAnd($c); 0 */ $i++; } /* foreach */ ?> $criteria->addOr($c0); } $objs = getPhpName() ?>Peer::doSelect($criteria, $con); } return $objs; } 1 $comma = false; ?> /** * Retrieve object using using pk values or NULL if not found. *getPrimaryKey() as $col) { $clo = strtolower($col->getName()); $cptype = $col->getPhpNative(); ?> * @param $ * @param Connection $con * @return getPhpName() ?> */ public static function (getPrimaryKey() as $col) { $clo = strtolower($col->getName()); ?>, $ , $con = null) { if ($con === null) { $con = Propel::getConnection(self::DATABASE_NAME); } $criteria = new Criteria(); getPrimaryKey() as $col) { $clo = strtolower($col->getName()); ?> $criteria->add(self::, $); $v = getPhpName() ?>Peer::doSelect($criteria, $con); return count($v) > 0 ? $v[0] : null; } 1 */ } /* if pkey > 0 */ ?> getPhpName(); $countFK = count($table->getForeignKeys()); if ($countFK >= 1) { foreach ($table->getForeignKeys() as $fk) { $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); if (!$tblFK->isForReferenceOnly()) { // want to cover this other case, but the code is not there yet. if ( $fk->getForeignTableName() != $table->getName() ) { $partJoinName = ""; foreach ($fk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); if ($column->isMultipleFK() || $fk->getForeignTableName() == $table->getName()) { $partJoinName = $partJoinName . $column->getPhpName(); } } $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); $interfaceName = $joinTable->getPhpName(); if ($joinTable->getInterface()) { $interfaceName = $joinTable->getInterface(); } if ($partJoinName == "") { $joinColumnId = $joinClassName; $joinInterface = $interfaceName; $collThisTable = $className . "s"; $collThisTableMs = $className; } else { $joinColumnId= $joinClassName . "RelatedBy" . $partJoinName; $joinInterface= $interfaceName . "RelatedBy" . $partJoinName; $collThisTable= $className . "sRelatedBy" . $partJoinName; $collThisTableMs= $className . "RelatedBy" . $partJoinName; } // ------------------------------------------------------------ ?> /** * Selects a collection of objects pre-filled with their * objects. * * @return array Array of objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoin(Criteria $c, $con = null) { // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } getPhpName() ?>Peer::addSelectColumns($c); $startcol = (self::$numColumns - self::$numLazyLoadColumns) + 1; Peer::addSelectColumns($c); getLocalForeignMapping(); foreach ($fk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); $columnFk = $joinTable->getColumn( $lfMap[$columnName]); ?> $c->addJoin(getPhpName()) ?>, ); $rs = ::doSelect($c, $con); $results = array(); while($rs->next()) { getChildrenColumn()) { ?> $omClass = getPhpName() ?>Peer::getOMClass($rs, 1); $omClass = getPhpName() ?>Peer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); getChildrenColumn()) { ?> $omClass = Peer::getOMClass($rs, $startcol); $omClass = Peer::getOMClass(); $cls = Propel::import($omClass); $obj2 = new $cls(); $obj2->hydrate($rs, $startcol); $newObject = true; foreach($results as $temp_obj1) { $temp_obj2 = $temp_obj1->get(); if ($temp_obj2->getPrimaryKey() === $obj2->getPrimaryKey()) { $newObject = false; $temp_obj2->add($obj1); break; } } if ($newObject) { $obj2->init(); $obj2->add($obj1); } $results[] = $obj1; } return $results; } 1 // =========================================================== if ($countFK > 2) { $includeJoinAll = true; foreach ($table->getForeignKeys() as $fk) { $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); if ($tblFK->isForReferenceOnly()) { $includeJoinAll = false; } } if ($includeJoinAll) { // ------------------------------------------------------------------------ // doSelectJoinAll() // ------------------------------------------------------------------------ //1 ) create the master doSelectJoinAll() method $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $relatedByCol = ""; foreach ($fk->getLocalColumns() as $columnName) { $column = $table->getColumn($columnName); if ($column->isMultipleFK()) { $relatedByCol .= $column->getPhpName(); } } if ($relatedByCol == "") { $collThisTable = "${className}s"; $collThisTableMs = $className; } else { $collThisTable = $className . "sRelatedBy" . $relatedByCol; $collThisTableMs = $className . "RelatedBy" . $relatedByCol; } ?> /** * Selects a collection of objects pre-filled with * all related objects. * * @return array Array of objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAll(Criteria $c, $con = null) { // Set the correct dbName if it has not been overridden if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } getPhpName() ?>Peer::addSelectColumns($c); $startcol2 = (self::$numColumns - self::$numLazyLoadColumns) + 1; getForeignKeys() as $fk) { // want to cover this case, but the code is not there yet. if ( $fk->getForeignTableName() != $table->getName() ) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); $new_index = $index + 1; ?> Peer::addSelectColumns($c); $startcol = $startcol + Peer::$numColumns; getForeignTableName != table->getName } // foreach [sub] foreign keys foreach ($table->getForeignKeys() as $fk) { // want to cover this case, but the code is not there yet. if ( $fk->getForeignTableName() != $table->getName() ) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); $lfMap = $fk->getLocalForeignMapping(); foreach ($fk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); $columnFk = $joinTable->getColumn( $lfMap[$columnName]); ?> $c->addJoin(getPhpName()) ?>, ); $rs = ::doSelect($c, $con); $results = array(); while($rs->next()) { getChildrenColumn()) { ?> $omClass = getPhpName() ?>Peer::getOMClass($rs, 1); $omClass = getPhpName() ?>Peer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); getForeignKeys() as $fk ) { // want to cover this case, but the code is not there yet. if ( $fk->getForeignTableName() != $table->getName() ) { $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); $interfaceName = $joinTable->getPhpName(); if($joinTable->getInterface()) { $interfaceName = $joinTable->getInterface(); } $partJoinName = ""; foreach ($fk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); if ($column->isMultipleFK()) { $partJoinName .= $column->getPhpName(); } } if ($partJoinName == "") { $joinString = $interfaceName; $collThisTable = "${className}s"; $collThisTableMs = $className; } else { $joinString= $interfaceName."RelatedBy" . $partJoinName; $collThisTable= $className . "sRelatedBy" . $partJoinName; $collThisTableMs= $className . "RelatedBy" . $partJoinName; } $index++; ?> // Add objects for joined rows getChildrenColumn()) { ?> $omClass = Peer::getOMClass($rs, $startcol); $omClass = Peer::getOMClass(); getChildrenColumn() */ ?> $cls = Propel::import($omClass); $obj = new $cls(); $obj->hydrate($rs, $startcol); $newObject = true; for ($j=0, $resCount=count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj = $temp_obj1->get(); if ($temp_obj->getPrimaryKey() === $obj->getPrimaryKey()) { $newObject = false; $temp_obj->add($obj1); break; } } if ($newObject) { $obj->init(); $obj->add($obj1); } getForeignTableName() != $table->getName() } //foreach foreign key ?> $results[] = $obj1; } return $results; } getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over // getForeignKeys() will cause this to only execute one time. foreach ($fkeys as $fk ) { $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName()); $excludeTable = $table->getDatabase()->getTable($fk->getForeignTableName()); $excludeClassName = $excludeTable->getPhpName(); $relatedByCol = ""; foreach ($fk->getLocalColumns() as $columnName) { $column = $table->getColumn($columnName); if ($column->isMultipleFK()) { $relatedByCol .= $column->getPhpName(); } } if ($relatedByCol == "") { $excludeString = $excludeClassName; $collThisTable = "${className}s"; $collThisTableMs = $className; } else { $excludeString = $excludeClassName . "RelatedBy" . $relatedByCol; $collThisTable = $className . "sRelatedBy" . $relatedByCol; $collThisTableMs = $className . "RelatedBy" . $relatedByCol; } ?> /** * Selects a collection of objects pre-filled with * all related objects except . * * @return array Array of objects. * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ public static function doSelectJoinAllExcept(Criteria $c, $con = null) { // Set the correct dbName if it has not been overridden // $c->getDbName() will return the same object if not set to another value // so == check is okay and faster if ($c->getDbName() == Propel::getDefaultDB()) { $c->setDbName(self::DATABASE_NAME); } getPhpName() ?>Peer::addSelectColumns($c); $startcol2 = (self::$numColumns - self::$numLazyLoadColumns) + 1; getForeignKeys() as $subfk) { // want to cover this case, but the code is not there yet. if ( !($subfk->getForeignTableName() == $table->getName())) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); if ($joinClassName != $excludeClassName) { $new_index = $index + 1; ?> Peer::addSelectColumns($c); $startcol = $startcol + Peer::$numColumns; getForeignKeys() as $subfk) { // want to cover this case, but the code is not there yet. if ( $subfk->getForeignTableName() != $table->getName() ) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); if($joinClassName != $excludeClassName) { $lfMap = $subfk->getLocalForeignMapping(); foreach ($subfk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); $columnFk = $joinTable->getColumn( $lfMap[$columnName]); ?> $c->addJoin(getPhpName()) ?>, ); $rs = ::doSelect($c, $con); $results = array(); while($rs->next()) { getChildrenColumn()) { ?> $omClass = getPhpName() ?>Peer::getOMClass($rs, 1); $omClass = getPhpName() ?>Peer::getOMClass(); $cls = Propel::import($omClass); $obj1 = new $cls(); $obj1->hydrate($rs); getForeignKeys() as $subfk ) { // want to cover this case, but the code is not there yet. if ( $subfk->getForeignTableName() != $table->getName() ) { $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName()); $joinClassName = $joinTable->getPhpName(); $interfaceName = $joinTable->getPhpName(); if($joinTable->getInterface()) { $interfaceName = $joinTable->getInterface(); } if ($joinClassName != $excludeClassName) { $partJoinName = ""; foreach ($subfk->getLocalColumns() as $columnName ) { $column = $table->getColumn($columnName); if ($column->isMultipleFK()) { $partJoinName .= $column->getPhpName(); } } if ($partJoinName == "") { $joinString = $interfaceName; $collThisTable = "${className}s"; $collThisTableMs = $className; } else { $joinString= $interfaceName."RelatedBy" . $partJoinName; $collThisTable= $className . "sRelatedBy" . $partJoinName; $collThisTableMs= $className . "RelatedBy" . $partJoinName; } $index++; if ($joinTable->getChildrenColumn()) { ?> $omClass = Peer::getOMClass($rs, $startcol); $omClass = Peer::getOMClass(); getChildrenColumn() */ ?> $cls = Propel::import($omClass); $obj = new $cls(); $obj->hydrate($rs, $startcol); $newObject = true; for ($j=0, $resCount=count($results); $j < $resCount; $j++) { $temp_obj1 = $results[$j]; $temp_obj = $temp_obj1->get(); if ($temp_obj->getPrimaryKey() === $obj->getPrimaryKey()) { $newObject = false; $temp_obj->add($obj1); break; } } if ($newObject) { $obj->init(); $obj->add($obj1); } getForeignTableName() != $table->getName() } // foreach ?> $results[] = $obj1; } return $results; } 2 } /* if complex object model */ // two extra #end ... //------------------------------------------------------------ if (!$table->isAlias()) { ?> /** * Returns the TableMap related to this peer. This method is not * needed for general use but a specific application could have a need. * @return TableMap * @throws PropelException Any exceptions caught during processing will be * rethrown wrapped into a PropelException. */ protected static function getTableMap() { return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME); } isalias */ ?> } // static code to register the map builder for this Peer with the main Propel class if (Propel::isInit()) { // the MapBuilder classes register themselves with Propel during initialization // so we need to load them here. try { getPhpName() ?>Peer::getMapBuilder(); } catch (Exception $e) { Propel::log("Could not initialize Peer: " . $e->getMessage(), Propel::LOG_ERR); } } else { // even if Propel is not yet initialized, the map builder class can be registered // now and then it will be loaded when Propel initializes. require_once 'getPhpName() . 'MapBuilder') ?>'; Propel::registerMapBuilder(getPhpName()?>MapBuilder::CLASS_NAME); }