getDatabase();
if($table->getPackage()) {
$package = $table->getPackage();
} else {
$package = $targetPackage;
}
echo '<' . '?' . 'php';
$CLASS = $table->getPhpName() . 'Peer';
$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
*/
class getPhpName() ?>Peer
{
isAlias()) { ?>
/** the default database name for this class */
function DATABASE_NAME() { return "getDatabase()->getName() ?>"; }
/** the table name for this class */
function TABLE_NAME() { return "getName() ?>"; }
getColumns() as $col) { ?>
/** the column name for the getName()) ?> field */
function () { return "getName() . '.' . strtoupper($col->getName()) ?>"; }
isAlias()) */ ?>
/** number of columns for this peer (static) */
function numColumns() { return getNumColumns() ?>; }
/** number of lazy load columns for this peer */
function numLazyLoadColumns() { return getNumLazyLoadColumns() ?>; }
/** A class that can be returned by this peer. */
function CLASS_DEFAULT() { return "getPhpName() ?>"; }
/** The PHP to DB Name Mapping (static) */
var $phpNameMap = null;
/**
* @access private static
*/
function & getInstance()
{
static $instance;
if ($instance === null) {
$instance = new getPhpName()?>Peer();
}
return $instance;
}
/**
* @return MapBuilder the map builder for this peer
* @access public static
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
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
* @access public static
* @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.
*/
function getPhpNameMap()
{
$self =& getPhpName()?>Peer::getInstance();
if ($self->phpNameMap === null) {
$map = $self->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 */
function CLASSKEY_getKey()) ?>() { return getKey() . $quote ?>; }
/** A class that can be returned by this peer. */
function CLASSNAME_getKey()) ?>() { return "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
* @access public static
*/
function alias($alias, $column)
{
return $alias . substr($column, strlen(getPhpName()?>Peer::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.
* @access public static
*/
function addSelectColumns(/*Criteria*/ &$criteria)
{
Propel::typeHint($criteria, 'Criteria', '', 'addSelectColumns', 1);
getColumns() as $col) {
if (! $col->isLazyLoad()) {
?>
$criteria->addSelectColumn(getPhpName()?>Peer::());
}
hasPrimaryKey()) {
$pk = $table->getPrimaryKey();
$countColumn = $table->getName() . "." . strtoupper($pk[0]->getName());
}
?>
function COUNT() { return "COUNT()"; }
function COUNT_DISTINCT() { return "COUNT(DISTINCT )"; }
/**
* Returns the number of rows matching criteria.
*
* @param Criteria $criteria a Criteria object.
* @param boolean $distinct Whether to select only distinct columns.
* @param Connection $con An optional Connection object.
*
* @return int Number of matching rows.
*/
function doCount(/*Criteria*/ $criteria, $distinct = false, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doCount', 3);
Propel::typeHint($criteria, 'Criteria', '', 'doCount', 1);
/*
* clear out anything that might confuse the ORDER BY clause.
* Note: unlike php5 version $criteria is passed by value and has not to be cloned.
*/
$criteria->clearSelectColumns();
$criteria->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 (Propel::isError($rs)) { return $rs; }
if ($rs->next() === true) {
return $rs->getInt(1);
}
/* 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 An optional Connection object.
*
* @return mixed getPhpName() ?> on success, NULL on failure.
*/
function & doSelectOne($criteria, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelectOne', 2);
$criteria->setLimit(1);
$objects =& getPhpName()?>Peer::doSelect($criteria, $con);
if (Propel::isError($objects)) { return $objects; }
if ($objects) {
return $objects[0];
}
return null;
}
/**
* Method to do selects.
*
* @param Criteria $criteria Object used to create the SELECT statement.
* @param Connection $con An optional Connection object.
*
* @return array Array of selected Objects
* @throws PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
*/
function & doSelect($criteria, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelect', 2);
$rs =& getPhpName()?>Peer::doSelectRS($criteria, $con);
if (Propel::isError($rs)) { return $rs; }
return getPhpName()?>Peer::populateObjects($rs);
}
/**
* 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
* @param Connection $con An optional Connection object.
*
* @return ResultSet The resultset object with numerically-indexed fields.
* PropelException Any exceptions caught during processing will be
* rethrown wrapped into a PropelException.
* @see ::doSelect()
*/
function & doSelectRS($criteria, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelectRS', 2);
/* [MA] do not retrieve connection here, BasePeer::doSelect will do */
if (!$criteria->getSelectColumns()) {
getPhpName()?>Peer::addSelectColumns($criteria);
}
// Set the correct dbName
$criteria->setDbName(getPhpName()?>Peer::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.
*
* @return Array of getPhpName()?> objects on success OR
* PropelException Any exceptions caught during processing will be
* returned wrapped into a PropelException.
*/
function & populateObjects(/*ResultSet*/ &$rs)
{
$results = array();
if (! is_a($rs, 'ResultSet')) {
return new PropelException(PROPEL_ERROR, "parameter not of type 'ResultSet'");
}
getChildrenColumn()) { ?>
// set the class once to avoid overhead in the loop
$cls = getPhpName() ?>Peer::getOMClass();
if (Propel::isError($cls =& Propel::import($cls))) {
return $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));
if (Propel::isError($cls)) {
return $cls;
}
$obj =& new $cls();
if (Propel::isError($e =& $obj->hydrate($rs))) {
return $e;
}
$results[] =& $obj;
$obj =& new $cls();
if (Propel::isError($e =& $obj->hydrate($rs))) {
return $e;
}
$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.
*/
function getOMClass(/*ResultSet*/ &$rs, $colnum)
{
$c = null;
isEnumeratedClasses()) { ?>
$omClass = null;
$classKey = $rs->getString($colnum - 1 + getPosition() ?>);
switch($classKey)
{
getChildren() as $child) {
?>
case getPhpName()?>Peer::CLASSKEY_getKey()) ?>():
$omClass = getPhpName()?>Peer::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.";
return new PropelException(PROPEL_ERROR, $error);
$omClass = getPhpName()?>Peer::CLASS_DEFAULT();
} // switch
$c = $omClass;
$c =& Propel::import($rs->getString($colnum - 1 + getPosition() ?>));
if (Propel::isError($c)) {
return $c;
}
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.
*/
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.";
return new PropelException(PROPEL_ERROR, $error);
return getPhpName()?>Peer::CLASS_DEFAULT();
}
getchildrencolumn */
if (!$table->isAlias() && ! $table->isReadOnly())
{
?>
/**
* Method to do inserts. This method is to be used during a transaction,
* otherwise use the doInsert(Criteria) method. It will take care of
* the connection details internally.
*
* @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.
*/
function doInsert(&$values, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doInsert', 2);
$con =& Param::get($con);
if ($con === null) {
$con =& Propel::getConnection(getPhpName()?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
}
if (is_a($values, 'Criteria')) {
$criteria =& $values;
} else {
$criteria =& $values->buildCriteria();
}
getColumns() as $col)
{
$cfc = $col->getPhpName();
if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none")
{
?>
$criteria->remove(getPhpName()?>Peer::()); // remove pkey col since this table uses auto-increment
// Set the correct dbName
$criteria->setDbName(getPhpName()?>Peer::DATABASE_NAME());
// use transaction because $criteria could contain info
// for more than one table (I guess, conceivably)
$e = $con->begin();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
$pk = ::doInsert($criteria, $con);
if (Propel::isError($pk)) { $con->rollback(); return $pk; }
$e = $con->commit();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $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.
*
* @return mixed number of affected rows on success, any exceptions returned during processing
* wrapped in a PropelException on failure.
*/
function doUpdate(&$values, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doUpdate', 2);
$con =& Param::get($con);
if ($con === null) {
$con =& Propel::getConnection(getPhpName()?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
}
$selectCriteria =& new Criteria(getPhpName()?>Peer::DATABASE_NAME());
if (is_a($values, 'Criteria')) {
$criteria =& $values;
getColumns() as $col)
{
if($col->isPrimaryKey())
{
$pn = $table->getPhpName() . 'Peer';
$cn = PeerBuilder::getColumnName($col);
?>
$selectCriteria->put(::(), $criteria->remove(::()));
} 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(getPhpName()?>Peer::DATABASE_NAME());
return ::doUpdate($selectCriteria, $criteria, $con);
}
/**
* Method to DELETE all rows from the getName() ?> table.
*
* Note: If you want to pass a Connection object as reference,
* use Param::set() :
*
*
* $con =& Propel::getConnection();
* $e = BasePeer::doDeleteAll(Param::set($con));
*
*
* @return mixed number of affected rows on success, PropelException on failure.
*/
function doDeleteAll($con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doDeleteAll', 2);
$con =& Param::get($con);
if ($con === null) {
$con =& Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
}
$affectedRows = 0; // initialize var to track total num of affected rows
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$e = $con->begin();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
$e = getPhpName() ?>Peer::doOnDeleteCascade(new Criteria(), $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = getPhpName() ?>Peer::doOnDeleteSetNull(new Criteria(), $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = BasePeer::doDeleteAll(getPhpName() ?>Peer::TABLE_NAME(), $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = $con->commit();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
return $affectedRows;
}
/**
* 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 containing data that is used to create the DELETE statement.
* @param Connection $con the connection to use
*
* @return mixed number of affected rows on success, any exception returned during processing wrapped into a PropelException on failure.
*/
function doDelete(&$values, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doDelete', 2);
$con =& Param::get($con);
if ($con === null) {
$con =& Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
}
if (is_a($values, 'Criteria')) {
$criteria =& $values;
}
elseif (is_a($values, '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(getPhpName()?>Peer::DATABASE_NAME());
getPrimaryKey()) == 1) {
$col = array_shift($table->getPrimaryKey());
?>
$criteria->add(getPhpName()?>Peer::(), $values);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey
// values
getPrimaryKey() as $col) {
?>
$criteria->add(getPhpName()?>Peer::(), $values[]);
}
// Set the correct dbName
$criteria->setDbName(getPhpName()?>Peer::DATABASE_NAME());
$affectedRows = 0; // initialize var to track total num of affected rows
// use transaction because $criteria could contain info
// for more than one table or we could emulating ON DELETE CASCADE, etc.
$e = $con->begin();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
$e = getPhpName()?>Peer::doOnDeleteCascade($criteria, $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = getPhpName()?>Peer::doOnDeleteSetNull($criteria, $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = ::doDelete($criteria, $con);
if (Propel::isError($e)) { $con->rollback(); return $e; }
$affectedRows += $e;
$e = $con->commit();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
return $affectedRows;
}
/**
* 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 number of affected rows on success, PropelException on failure.
*/
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, Param::set($con));
if (Propel::isError($objects)) { return $objects; }
for($i=0, $j=count($objects); $i < $j; $i++)
{
$obj =& $objects[$i];
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() ?>());
$e = Peer::doDelete($c, Param::set($con));
if (Propel::isError($e)) { return $e; }
$affectedRows += $e;
}
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 mixed number of affected rows on success, PropelException on failure.
*/
function doOnDeleteSetNull(/*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, Param::set($con));
if (Propel::isError($objects)) { return $objects; }
for($i=0, $j=count($objects); $i < $j; $i++)
{
$obj =& $objects[$i];
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(getPhpName()?>Peer::DATABASE_NAME());
$updateValues =& new Criteria(getPhpName()?>Peer::DATABASE_NAME());
getColumn($columnNamesF[$x]);
$columnL = $table->getColumn($columnNamesL[$x]);
?>
$selectCriteria->add((),
$obj->getgetPhpName() ?>());
$updateValues->add((), null);
// use BasePeer because generated Peer doUpdate() methods only update using pkey
$e = ::doUpdate($selectCriteria, $updateValues, $con);
if (Propel::isError($e)) { return $e; }
$affectedRows += $e;
}
return $affectedRows;
}
/**
* 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.
*/
function doValidate(&$obj, $cols = null)
{
Propel::typeHint($obj, 'getPhpName()?>', '', 'doValidate');
$dbName = getPhpName()?>Peer::DATABASE_NAME();
$tableName = getPhpName()?>Peer::TABLE_NAME();
$columns = array();
if ($cols)
{
$dbMap =& Propel::getDatabaseMap($dbName);
$tableMap =& $dbMap->getTable($tableName);
if (! is_array($cols)) {
$cols = array($cols);
}
foreach($cols as $colName)
{
if ($tableMap->containsColumn($colName))
{
$colMap =& $tableMap->getColumn($colName);
$get = 'get' . $colMap->getPhpName();
$columns[$colName] = $obj->$get();
}
}
}
else
{
getValidators() as $val) {
$col = $val->getColumn();
if (! $col->isAutoIncrement()) {
$cfc = $col->getPhpName();
$cup = strtoupper($col->getName());
?>
if ($obj->isNew() || $obj->isColumnModified(getPhpName()?>Peer::()))
$columns[getPhpName()?>Peer::()] = $obj->get();
}
return ::doValidate($dbName, $tableName, $columns);
}
/**
* Build a Criteria object from the data object for this peer or from primary key(s).
*
* @param mixed $obj getPhpName() ?> object or getPrimaryKey()) == 1) { ?>scalar primary keyarray primary keys.
* @return Criteria The compiled Criteria object.
*/
function buildCriteria(&$obj)
{
if (is_a($obj, 'getPhpName() ?>' )) {
$criteria =& new Criteria(getPhpName()?>Peer::DATABASE_NAME());
getColumns() as $col) {
$cfc = $col->getPhpName();
if ($col->isPrimaryKey() && $table->getIdMethod() != "none") {
?>
if (! $obj->isNew())
$criteria->add(getPhpName()?>Peer::(), $obj->get()); // primary key on tables w/ id generation is only added if not new
if ($obj->isColumnModified(getPhpName()?>Peer::()))
$criteria->add(getPhpName()?>Peer::(), $obj->get());
} else {
// it must be the primary key
$criteria =& new Criteria(getPhpName()?>Peer::DATABASE_NAME());
getPrimaryKey()) == 1) {
$col = array_shift($table->getPrimaryKey()); ?>
$criteria->add(getPhpName()?>Peer::(), $obj);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey
// values
getPrimaryKey() as $col) { ?>
$criteria->add(getPhpName()?>Peer::(), $obj[]);
}
return $criteria;
}
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 mixed getPhpName(); ?> on success, NULL on failure
*/
function & ($pk, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', '', 2);
$criteria =& new Criteria();
getPrimaryKey()) === 1) {
$col = array_shift($table->getPrimaryKey());
?>
$criteria->add(getPhpName() ?>Peer::(), $pk);
// primary key is composite; we therefore, expect
// the primary key passed to be an array of pkey
// values
getPrimaryKey() as $col) {
?>
$criteria->add(getPhpName() ?>Peer::, $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.
*/
function & s($pks, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', '', 2);
$objs = null;
if (empty($pks)) {
$objs = array();
} else {
$criteria =& new Criteria();
getPrimaryKey()) == 1) { ?>
$criteria->add(getPhpName() ?>Peer::getPrimaryKey(); echo strtoupper($k1[0]->getName()); ?>(), $pks, Criteria::IN());
for($k=0,$size=count($pks); $k < $size; $k++) {
$pk = $pks[$k];
getPrimaryKey() as $col) { ?>
$c =& $criteria->getNewCriterion(getPhpName()?>Peer::(), $pk[], Criteria::EQUAL());
0) { ?>
$c->addAnd($c);
0 */
$i++;
} /* foreach */ ?>
$criteria->addOr($c0);
}
$objs =& getPhpName()?>Peer::doSelect($criteria, $con);
if (Propel::isError($objs)) { return $objs; }
}
return $objs;
}
1
$comma = false;
?>
/**
* Retrieve object using pk values or NULL if not found.
*
getPrimaryKey() as $col) {
$clo = strtolower($col->getName());
$cptype = $col->getPhpNative();
?>
* @param $
* @param Connection $con
*
* @return getPhpName() ?>
*/
function (getPrimaryKey() as $col) { $clo = strtolower($col->getName()); ?>, $, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', '', -1);
$criteria = new Criteria();
getPrimaryKey() as $col) {
$clo = strtolower($col->getName());
?>
$criteria->add(getPhpName()?>Peer::(), $);
$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.
*/
function & doSelectJoin(/*Criteria*/ $c, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelectJoin', 2);
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(getPhpName()?>Peer::DATABASE_NAME());
}
getPhpName() ?>Peer::addSelectColumns($c);
$startcol = getPhpName() ?>Peer::numColumns() - getPhpName() ?>Peer::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);
if (Propel::isError($rs)) { return $rs; }
$results = array();
while($rs->next())
{
getChildrenColumn()) { ?>
$omClass = getPhpName() ?>Peer::getOMClass($rs, 1);
$omClass = getPhpName() ?>Peer::getOMClass();
$cls =& Propel::import($omClass);
if (Propel::isError($cls)) { return $cls; }
$obj1 =& new $cls();
$e =& $obj1->hydrate($rs);
if (Propel::isError($e)) { return $e; }
getChildrenColumn()) { ?>
$omClass = Peer::getOMClass($rs, $startcol);
$omClass = Peer::getOMClass();
$cls =& Propel::import($omClass);
if (Propel::isError($cls)) { return $cls; }
$obj2 =& new $cls();
$e =& $obj2->hydrate($rs, $startcol);
if (Propel::isError($e)) { return $e; }
$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.
*/
function doSelectJoinAll(/*Criteria*/ &$c, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelectJoinAll', 2);
// Set the correct dbName if it has not been overridden
if ($c->getDbName() == Propel::getDefaultDB()) {
$c->setDbName(getPhpName()?>Peer::DATABASE_NAME());
}
getPhpName() ?>Peer::addSelectColumns($c);
$startcol2 = getPhpName() ?>Peer::numColumns() - getPhpName() ?>Peer::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);
if (Propel::isError($rs)) { return $rs; }
$results = array();
while($rs->next()) {
getChildrenColumn()) {
?>
$omClass = getPhpName() ?>Peer::getOMClass($rs, 1);
$omClass = getPhpName() ?>Peer::getOMClass();
$cls = Propel::import($omClass);
if (Propel::isError($cls)) { return $cls; }
$obj1 = new $cls();
$e =& $obj1->hydrate($rs);
if (Propel::isError()) { return $e; }
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);
if (Propel::isError($cls)) { return $cls; }
$obj = new $cls();
$e = $obj->hydrate($rs, $startcol);
if (Propel::isError($e)) { return $e; }
$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
foreach ($fkeys as $fk ) { // getForeignKeys() will cause this to only execute one time.
$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.
*/
function doSelectJoinAllExcept(/*Criteria*/ &$c, $con = null)
{
/* [MA] temporarily check */
Propel::assertParam($con, '', 'doSelectJoinAllExcept', 2);
// 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(getPhpName()?>Peer::DATABASE_NAME());
}
getPhpName() ?>Peer::addSelectColumns($c);
$startcol2 = getPhpName() ?>Peer::numColumns() - getPhpName() ?>Peer::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);
if (Propel::isError($rs)) { return $rs; }
$results = array();
while($rs->next()) {
getChildrenColumn()) {
?>
$omClass = getPhpName() ?>Peer::getOMClass($rs, 1);
$omClass = getPhpName() ?>Peer::getOMClass();
$cls = Propel::import($omClass);
if (Propel::isError($cls)) { return $cls; }
$obj1 = new $cls();
$e = $obj1->hydrate($rs);
if (Propel::isError()) { return $e; }
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);
if (Propel::isError($cls)) { return $cls; }
$obj = new $cls();
$e = $obj->hydrate($rs, $startcol);
if (Propel::isError($e)) { return $e; }
$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.
*/
function & getTableMap()
{
$dbMap =& Propel::getDatabaseMap(getPhpName()?>Peer::DATABASE_NAME());
if (Propel::isError($dbMap)) {
return $dbMap;
}
return $dbMap->getTable(getPhpName()?>Peer::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.
if (Propel::isError($e = getPhpName() ?>Peer::getMapBuilder())) {
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());
}