getDatabase();
if ($table->getPackage()) {
$package = $table->getPackage();
} else {
$package = $targetPackage;
}
$parentClass = ClassTools::getBaseClass($table);
?>
require_once '';
isAlias())
{
// If any columns in table are BLOB or CLOB then we need to make
// sure those classes are included so we can do things like
// if ($v instanceof Lob) etc.
$includes_lobs = false;
foreach ($table->getColumns() as $col) {
if ($col->isLob()) {
$includes_lobs = true;
break;
}
}
if($includes_lobs)
{
?>
include_once 'creole/util/Clob.php';
include_once 'creole/util/Blob.php';
include_once 'propel/util/Criteria.php';
getForeignKeys() as $fk)
{
$tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
$className = $tblFK->getPhpName();
if ($tblFK->getInterface()) {
$className = $tblFK->getInterface();
}
$tblFKPackage = ($tblFK->getPackage() ? $tblFK->getPackage() : $package);
$tblFKPackagePath = strtr($tblFKPackage, '.', '/');
if ($tblFKPackagePath != "") {
$tblFKPackagePath .= '/';
}
?>
// (on-demand) include_once '';
// (on-demand) include_once 'getPhpName() . 'Peer') ?>';
getForeignKeys() as $fk) */
?>
include_once 'getPhpName() . 'Peer') ?>';
/**
* Base class that represents a row from the 'getName() ?>' table.
*
* getDescription() ?>
*
* This class was autogenerated by Propel on:
*
* []
*
* You should not use this class directly. It should not even be
* extended; all references should be to getPhpName() ?> class.
*
* @package
*/
class getPhpName() ?> extends
{
/**
* The Peer class.
* Instance provides a convenient way of calling static methods on a class
* that calling code may not be able to identify.
* @var getPhpName() ?>Peer
*/
var $peer;
isAlias())
{
foreach ($table->getColumns() as $col)
{
$cptype = $col->getPhpNative();
$clo=strtolower($col->getName());
$defVal = "";
if (($val = $col->getDefaultValue()) !== null) {
settype($val, $cptype);
$defaultValue = var_export($val, true);
$defVal = " = " . $defaultValue;
}
?>
/**
* The value for the field.
* @var
*/
var $;
isLazyLoad()) {
?>
/**
* Whether the lazy-loaded value has been loaded from database.
* This is necessary to avoid repeated lookups if column is NULL.
* @var boolean
*/
var $_isLoaded = false;
isLazyLoad()) */
} /* foreach ($table->getColumns() as $col) */
foreach ($table->getColumns() as $col)
{
$cfc=$col->getPhpName();
$clo=strtolower($col->getName());
$cptype = $col->getPhpNative();
$defaultValue = null;
if (($val = $col->getDefaultValue()) !== null) {
settype($val, $cptype);
$defaultValue = var_export($val, true);
}
if ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP)
{
// these default values are based on the Creole defaults
// the date and time default formats are locale-sensitive
if ($col->getType() === PropelTypes::DATE) {
$defaultfmt = '%x';
} elseif ($col->getType() === PropelTypes::TIME) {
$defaultfmt = '%X';
} elseif ($col->getType() === PropelTypes::TIMESTAMP) {
$defaultfmt = 'Y-m-d H:i:s';
}
?>
/**
* Get the [optionally formatted] `` value.
* getDescription() ?>
*
* @param string $format The date/time format string (either date()-style or strftime()-style).
* If format is NULL, then the integer unix timestamp will be returned.
* @return mixed Formatted date/time value as string or integer unix timestamp (if format is NULL) on success,
* PropelException, if unable to convert the date/time to timestamp.
*/
function get($format = '')
{
isLazyLoad()) {
?>
if (! $this->_isLoaded && $this-> === null && !$this->isNew()) {
if (($e = $this->load()) !== true) {
return $e;
}
}
isLazyLoad) */
?>
if ($this-> === null || $this-> === '') {
return null;
} elseif (!is_int($this->)) {
// a non-timestamp value was set externally, so we convert it
$ts = strtotime($this->);
if ($ts === -1) {
return new PropelException(PROPEL_ERROR_INVALID, "Unable to parse value of as date/time value: " . $this->);
}
} else {
$ts = $this->;
}
if ($format === null) {
return $ts;
} elseif (strpos($format, '%') !== false) {
return strftime($format, $ts);
} else {
return date($format, $ts);
}
}
getType() != DATE | TIME | TIMESTAMP */
?>
/**
* Get the column value.
* getDescription() ?>
*
* @return
*/
function get()
{
isLazyLoad())
{
?>
if (! $this->_isLoaded && $this-> === null && !$this->isNew()) {
if (($e = $this->load()) !== true) {
return $e;
}
}
isLazyLoad */
?>
return $this->;
}
getType() != DATE | TIME | TIMESTAMP */
?>
isLazyLoad())
{
?>
/**
* Load the value for the [lazy-load] `` column.
*
* This method performs an additional query to return the value for
* the `` column, since it is not populated by
* the hydrate() method.
*
* @return void
* @returns mixed boolean TRUE on success, PropelException - any underlying error will be wrapped and re-thrown.
*/
function load()
{
$c = $this->buildPkeyCriteria();
$c->addSelectColumn(getPhpName()) ?>());
$rs =& getPhpName()?>Peer::doSelectRS($c);
if (Propel::isError($e =& $rs) || Propel::isError($e = $rs->next())) {
return new PropelException(PROPEL_ERROR, "Error loading value for `` column on demand.", $e);
}
getType()));
$clo = strtolower($col->getName());
switch($col->getType())
{
case PropelTypes::DATE:
case PropelTypes::TIME:
case PropelTypes::TIMESTAMP:
?>
$this-> = $rs->get(1, null);
$this-> = $rs->get(1);
getType */
?>
if (Propel::isError($this->)) {
return new PropelException(PROPEL_ERROR, "Error loading value for `` column on demand.", $this->);
}
$this->_isLoaded = true;
return true;
}
isLazyLoad */
if (! $table->isReadOnly())
{
$throwsClause = "";
if ($complexObjectModel)
{
if ($col->isForeignKey()) {
$throwsClause = "@throws PropelException";
}
if (count($col->getReferrers()) > 0 ) {
if ($throwsClause == "") {
$throwsClause = "@throws PropelException";
}
}
}
if ($col->getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP) {
$throwsClause = "@throws PropelException - If passed [not-null] date/time is in an invalid format.";
}
?>
/**
* Set the value of ``
* getDescription() ?>
*
* @param $v new value
* @return void
*
*/
function set($v)
{
isLazyLoad())
{
?>
// explicitly set the is-loaded flag to true for this lazy load col;
// it doesn't matter if the value is actually set or not (logic below) as
// any attempt to set the value means that no db lookup should be performed
// when the get() method is called.
$this->_isLoaded = true;
isLazyLoad */
if ($addSaveMethod)
{
if ($col->isLob())
{
// Setting of LOB columns gets some special handling
if ($col->getPropelType() === PropelTypes::BLOB || $col->getPropelType() === PropelTypes::LONGVARBINARY ) {
$lobClass = "Blob";
} else {
$lobClass = "Clob";
}
?>
// if the passed in parameter is the *same* object that
// is stored internally then we use the Lob->isModified()
// method to know whether contents changed.
if (is_a($v, 'Lob') && $v === $this->) {
$changed = $v->isModified();
} else {
$changed = ($this-> !== $v);
}
if ($changed) {
if ( ! is_a($v, 'Lob') ) {
$obj = new ();
$obj->setContents($v);
} else {
$obj =& $v;
}
$this-> = $obj;
$this->modifiedColumns[] = getPhpName()) ?>();
}
getType() === PropelTypes::DATE || $col->getType() === PropelTypes::TIME || $col->getType() === PropelTypes::TIMESTAMP)
{
// Setting a DATE/TIME value gets some special handling.
?>
if ($v !== null && !is_int($v)) {
$ts = strtotime($v);
if ($ts === -1) {
return new PropelException(PROPEL_ERROR_INVALID, "Unable to parse date/time value for from input: " . var_export($v, true));
}
} else {
$ts = $v;
}
if ($this-> !== $ts || $ts === ) {
$this-> = $ts;
$this->modifiedColumns[] = getPhpName()) ?>();
}
if ($this-> !== $v || $v === ) {
$this-> = $v;
$this->modifiedColumns[] = getPhpName()) ?>();
}
$this-> =& $v;
isForeignKey())
{
$tblFK = $table->getDatabase()->getTable($col->getRelatedTableName());
$colFK = $tblFK->getColumn($col->getRelatedColumnName());
if ($col->isMultipleFK() || $col->getRelatedTableName() == $table->getName()) {
$relCol = "";
foreach ($col->getForeignKey()->getLocalColumns() as $columnName) {
$column = $table->getColumn($columnName);
$relCol .= $column->getPhpName();
}
if ($relCol != "") {
$relCol = "RelatedBy".$relCol;
}
$varName = "a".$tblFK->getPhpName() . $relCol;
} else {
$varName = "a".$tblFK->getPhpName();
}
?>
if ($this-> !== null && $this->->getgetPhpName() ?>() !== $v) {
/*
* Save a reference to null instead of null directly as this would
* overwrite a previous stored getPhpName() ?> object.
*/
$this-> =& Propel::null();
}
isForeignKey) */
foreach ($col->getReferrers() as $fk)
{
// used to be getLocalForeignMapping() which did not work.
$flmap = $fk->getForeignLocalMapping();
$fkColName = $flmap[$col->getName()];
$tblFK = $fk->getTable();
if ( $tblFK->getName() != $table->getName() )
{
$colFK = $tblFK->getColumn($fkColName);
if ($colFK->isMultipleFK()) {
$collName = "coll" . $tblFK->getPhpName() . "sRelatedBy" . $colFK->getPhpName();
} else {
$collName = "coll" . $tblFK->getPhpName() . "s";
}
?>
// update associated getPhpName() ?>
if ($this-> !== null) {
for ($i=0,$size=count($this->); $i < $size; $i++) {
$this->[$i]->setgetPhpName()?>($v);
}
}
}
isReadOnly() */
} /* foreach ($table->getColumns() as $col) */
?>
/**
* Hydrates (populates) the object variables with values from the database resultset.
*
* An offset (1-based "start column") is specified so that objects can be hydrated
* with a subset of the columns in the resultset rows. This is needed, for example,
* for results of JOIN queries where the resultset row includes columns from two or
* more tables.
*
* @param ResultSet $rs The ResultSet class with cursor advanced to desired record pos.
* @param int $startcol 1-based offset column which indicates which restultset column to start with.
* @return void
* @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
*/
function hydrate(&$rs, $startcol = 1)
{
assert('is_a($rs, "ResultSet")');
getColumns() as $col)
{
if (! $col->isLazyLoad())
{
$affix = CreoleTypes::getAffix(CreoleTypes::getCreoleCode($col->getType()));
$clo = strtolower($col->getName());
switch($col->getType())
{
case PropelTypes::DATE:
case PropelTypes::TIME:
case PropelTypes::TIMESTAMP:
?>
if (Creole::isError($value = $rs->get($startcol + , null))) {
return new PropelException(PROPEL_ERROR_DB, "Error populating getPhpName()?> object", $value);
}
$this-> = $value;
if (Creole::isError($value = $rs->get($startcol + ))) {
return new PropelException(PROPEL_ERROR_DB, "Error populating object", $value);
}
$this-> = $value;
isLazyLoad() */
} /* foreach ($table->getColumns() as $col) */
if ($addSaveMethod)
{
?>
$this->resetModified();
$this->setNew(false);
return true;
}
/**
* Builds a Criteria object containing the primary key for this object.
*
* Unlike buildCriteria() this method includes the primary key values regardless
* of whether or not they have been modified.
*
* @return Criteria The Criteria object containing value(s) for primary key(s).
*/
function &buildPkeyCriteria()
{
$criteria = new Criteria(getPhpName()?>Peer::DATABASE_NAME());
getColumns() as $col)
{
$clo = strtolower($col->getName());
if ($col->isPrimaryKey())
{
?>
$criteria->add(getPhpName()) ?>(), $this->);
isPrimaryKey */
} /* foreach ($table->getColumns() as $col) */
?>
return $criteria;
}
/**
* Build a Criteria object containing the values of all modified columns in this object.
*
* @return Criteria The Criteria object containing all modified values.
*/
function &buildCriteria()
{
$criteria = new Criteria(getPhpName()?>Peer::DATABASE_NAME());
getColumns() as $col)
{
$clo = strtolower($col->getName());
?>
if ($this->isColumnModified(getPhpName()) ?>())) {
$criteria->add(getPhpName()) ?>(), $this->);
}
return $criteria;
}
isAlias */
// association code
if ($complexObjectModel)
{
$pVars = array(); // Array of object set method names for later reference.
$aVars = array(); // Array of object field names for later reference.
foreach ($table->getForeignKeys() as $fk)
{
$tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
$className = $tblFK->getPhpName();
$tblFKPackage = ($tblFK->getPackage() ? $tblFK->getPackage() : $package);
$tblFKPackagePath = strtr($tblFKPackage, '.', '/');
if ($tblFKPackagePath != "") {
$tblFKPackagePath .= '/';
}
$relCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $table->getColumn($columnName);
if ($column->isMultipleFK() || $fk->getForeignTableName() == $table->getName()) {
$relCol .= $column->getPhpName();
}
}
if ($relCol != "") {
$relCol = "RelatedBy" . $relCol;
}
$pVarName = $className . $relCol;
$varName = "a" . $pVarName;
$retVal = ($pVars[] = $pVarName);
$retVal = ($aVars[] = $varName);
?>
/**
* @var
*/
var $;
/**
* Declares an association between this object and a object
*
* @param $v
* @return void
* @throws PropelException
*/
function set(&$v)
{
getLocalColumns() as $columnName)
{
$column = $table->getColumn($columnName);
$lfmap = $fk->getLocalForeignMapping();
$colFKName = $lfmap[$columnName];
$colFK = $tblFK->getColumn($colFKName);
?>
if ($v === null) {
$this->setgetPhpName() ?>(getDefaultValue()) ?>);
} else {
$this->setgetPhpName() ?>($v->getgetPhpName() ?>());
}
$this-> =& $v;
}
getLocalColumns() as $columnName)
{
$column = $table->getColumn($columnName);
$cptype = $column->getPhpNative();
$clo = strtolower($column->getName());
if ($cptype == "integer" || $cptype == "float" || $cptype == "double") {
$conditional .= $and . "\$this->". $clo ." > 0";
} elseif($cptype == "string") {
$conditional .= $and . "(\$this->" . $clo ." !== \"\" && \$this->".$clo." !== null)";
} else {
$conditional .= $and . "\$this->" . $clo ." !== null";
}
$arglist .= $comma . "\$this->" . $clo;
$and = " && ";
$comma = ", ";
$argsize = $argsize + 1;
}
$pCollName = $table->getPhpName() . 's' . $relCol;
?>
/**
* Get the associated object
*
* @return The associated object.
* @throws PropelException
*/
function & get()
{
// include the Peer class
include_once 'Peer.php';
if ($this-> === null && ())
{
isAlias())
{
if ($argsize > 1) {
?>
$ =& Peer::retrieveByPK();
$ =& Peer::retrieveByPK();
1) */
}
else
{
if ($argsize > 1) {
?>
$ =& Peer::retrieveByPK();
$ =& Peer::retrieveByPK();
isAlias
?>
if (Propel::isError($)) { return $; }
$this-> =& $;
/* The following can be used instead of the line above to
guarantee the related object contains a reference
to this object, but this level of coupling
may be undesirable in many circumstances.
As it can lead to a db query with many results that may
never be used.
$obj = Peer::retrieveByPK();
$obj->add($this);
*/
}
return $this->;
}
/**
* Provides convenient way to set a relationship based on a
* key. e.g.
* $bar->setFooKey($foo->getPrimaryKey())
*
getLocalColumns()) > 1) {
?>
* Note: It is important that the xml schema used to create this class
* maintains consistency in the order of related columns between
* getName() ?> and getName() ?>.
* If for some reason this is impossible, this method should be
* overridden in getPhpName() ?>.
* @return void
* @throws PropelException
*/
function setKey($key)
{
getLocalColumns()) > 1)
{
$i = 0;
foreach ($fk->getLocalColumns() as $colName)
{
$col = $table->getColumn($colName);
$fktype = $col->getPhpNative();
?>
$this->setgetPhpName() ?>( () $key[] );
getLocalColumns();
$colName = $lcols[0];
$col = $table->getColumn($colName);
$fktype = $col->getPhpNative();
?>
$this->setgetPhpName() ?>( () $key);
}
getReferrers() as $fk)
{
$tblFK = $fk->getTable();
$tblFKPackage = ($tblFK->getPackage() ? $tblFK->getPackage() : $package);
$tblFKPackagePath = strtr($tblFKPackage, '.', '/');
if ($tblFKPackagePath != "") {
$tblFKPackagePath .= '/';
}
$className = $tblFK->getPhpName();
$relatedByCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK() || $tblFK->getName() == $table->getName()) {
// if there are seeral foreign keys that point to the same table
// then we need to generate methods like getAuthorRelatedByColName()
// instead of just getAuthor(). Currently we are doing the same
// for self-referential foreign keys, to avoid confusion.
$relatedByCol .= $column->getPhpName();
}
}
if ($relatedByCol == "") {
$suffix = "";
$relCol = $className . "s";
$relColMs = $className;
} else {
$suffix = "RelatedBy" . $relatedByCol;
$relCol= $className . "sRelatedBy" . $relatedByCol;
$relColMs= $className . "RelatedBy" . $relatedByCol;
}
$collName = "coll" . $relCol;
?>
/**
* Collection to store aggregation of
* @var array
*/
var $;
/**
* Temporary storage of to save a possible db hit in
* the event objects are add to the collection, but the
* complete collection is never requested.
* @return void
*/
function init()
{
if ($this-> === null) {
$this-> = array();
}
}
/**
* Method called to associate a getPhpName() ?> object to this object
* through the foreign key attribute
*
* @param $l $className
* @return void
* @throws PropelException
*/
function add(/**/ &$l)
{
$this->[] =& $l;
$l->setgetPhpName() . $suffix ?>($this);
}
/**
* The criteria used to select the current contents of .
* @var Criteria
*/
var $lastCriteria = null;
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this getPhpName() ?> has previously
* been saved, it will retrieve related ${relCol} from storage.
* If this getPhpName() ?> is new, it will return
* an empty collection or the current collection, the criteria
* is ignored on a new object.
*
* @param Criteria $criteria
* @throws PropelException
*/
function & get($criteria = null)
{
// include the Peer class
include_once 'Peer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
if ($this-> === null)
{
if ($this->isNew()) {
$this-> = array();
} else {
getForeignColumns() as $columnName)
{
$column = $table->getColumn($columnName);
// used to be getLocalForeignMapping() but that didn't seem to work
// (maybe a problem in translation of HashTable code to PHP).
$flmap = $fk->getForeignLocalMapping();
$colFKName = $flmap[$columnName];
$colFK = $tblFK->getColumn($colFKName);
?>
$criteria->add((), $this->getgetPhpName() ?>() );
getForeignColumns()) */
?>
$ =& Peer::doSelect($criteria);
if (Propel::isError($)) { return $; }
$this-> =& $;
}
} else {
// criteria has no effect for a new object
if (!$this->isNew())
{
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
getForeignColumns() as $columnName)
{
$column = $table->getColumn($columnName);
$flmap = $fk->getForeignLocalMapping();
$colFKName = $flmap[$columnName];
$colFK = $tblFK->getColumn($colFKName);
?>
$criteria->add((), $this->getgetPhpName() ?>());
getForeignColumns()) */
?>
if (!isset($this->lastCriteria) || !$this->lastCriteria->equals($criteria))
{
$ =& Peer::doSelect($criteria);
if (Propel::isError($)) { return $; }
$this-> =& $;
}
}
}
$this->lastCriteria = $criteria;
return $this->;
}
getForeignKeys() as $dummyFK) {
$countFK = $countFK + 1;
}
// ------------------------------------------------------------
//
if ($countFK >= 1)
{
$lastTable = "";
foreach ($tblFK->getForeignKeys() as $fk2)
{
// Add join methods if the fk2 table is not this table or
// the fk2 table references this table multiple times.
$doJoinGet = true;
if ( $fk2->getForeignTableName() == $table->getName() ) {
$doJoinGet = false;
}
foreach ($fk2->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK()) {
$doJoinGet = true;
}
}
$tblFK2 = $table->getDatabase()->getTable($fk2->getForeignTableName());
$doJoinGet = !$tblFK2->isForReferenceOnly();
$relatedByCol2 = "";
foreach ($fk2->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK()) {
$relatedByCol2 .= $column->getPhpName();
}
}
$fkClassName = $tblFK2->getPhpName();
// do not generate code for self-referencing fk's, it would be
// good to do, but it is just not implemented yet.
if ($className == $fkClassName) {
// $doJoinGet = false; -- SELF REFERENCING FKs UNDER TESTING
}
if ($relatedByCol2 == "") {
$relCol2 = $fkClassName;
} else {
$relCol2 = $fkClassName . "RelatedBy". $relatedByCol2;
}
if ( $relatedByCol == "") {
// nothing?
} else {
if ( $relatedByCol == $relatedByCol2 ) {
$doJoinGet = false;
}
}
if ($doJoinGet)
{
?>
/**
* If this collection has already been initialized with
* an identical criteria, it returns the collection.
* Otherwise if this getPhpName() ?> is new, it will return
* an empty collection; or if this getPhpName() ?> has previously
* been saved, it will retrieve related from storage.
*
* This method is protected by default in order to keep the public
* api reasonable. You can provide public methods for those you
* actually need in getPhpName() ?>.
*/
function & getJoin($criteria = null)
{
// include the Peer class
include_once 'Peer.php';
if ($criteria === null) {
$criteria = new Criteria();
}
if ($this-> === null) {
if ($this->isNew()) {
$this-> = array();
} else {
getForeignColumns() as $columnName)
{
$column = $table->getColumn($columnName);
$flMap = $fk->getForeignLocalMapping();
$colFKName = $flMap[$columnName];
$colFK = $tblFK->getColumn($colFKName);
?>
$criteria->add((), $this->getgetPhpName() ?>());
getForeignColumns()) */
?>
$ =& Peer::doSelectJoin($criteria);
if (Propel::isError($)) { return $; }
$this-> =& $;
}
} else {
// the following code is to determine if a new query is
// called for. If the criteria is the same as the last
// one, just return the collection.
getForeignColumns() as $columnName)
{
$column = $table->getColumn($columnName);
$flMap = $fk->getForeignLocalMapping();
$colFKName = $flMap[$columnName];
$colFK = $tblFK->getColumn($colFKName);
?>
$criteria->add((), $this->getgetPhpName() ?>());
getForeignColumns()) */
?>
if (!isset($this->lastCriteria) || !$this->lastCriteria->equals($criteria))
{
$ =& Peer::doSelectJoin($criteria);
if (Propel::isError($)) { return $; }
$this-> =& $;
}
}
$this->lastCriteria = $criteria;
return $this->;
}
getForeignKeys() as $fk2) {*/
} /* if countFK >= 1 */
} /*ends foreach over table->getReferrers() */
} /* the if(complexObjectModel) */
//
// getByName code
//
if (!$table->isAlias() && $addGenericAccessors)
{
?>
var $fieldNames;
/**
* Generate a list of field names.
*
* @return array A list of field names
*/
function getFieldNames()
{
if ($this->fieldNames === null) {
$this->fieldNames = array(getColumns() as $col) { ?>"getName() ?>", );
}
return $this->fieldNames;
}
var $colNames;
/**
* Generate a list of original field names.
*
* @return array A list of field names
*/
function getColumnNames()
{
if ($this->colNames === null) {
$this->colNames = array(getColumns() as $col) { ?>"getName() ?>", );
}
return $this->colNames;
}
/**
*
*/
function & getByAssocArray()
{
$retval = array();
getColumns() as $col)
{
$colName = $col->getName();
$phpName = $col->getPhpName();
?>
$retval[""] = $this->get();
return($retval);
}
/**
* Retrieves a field from the object by name passed in as a string.
* Field name can either be the raw column name, php name or peer name.
*
*
* $author->setByName('author_id', 1);
* $author->setByName('authorId', 1);
* $author->setByName('author.AUTHOR_ID', 1);
*
*
* @param string $name field name
* @return mixed Value of field
*/
function & getByName($name)
{
switch($name)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative(); // not safe to use it because some methods may return objects (Blob)
?>
case "getName()?>":
case "getPhpName()?>":
case "getName() . '.' . strtoupper($col->getName()) ?>":
return $this->get();
break;
default:
return null;
} // switch()
}
/**
* Retrieves a field from the object by name passed in
* as a string. The string must be one of the static
* strings defined in this Class' Peer.
*
* @param string $name peer name
* @return mixed Value of field.
*/
function & getByPeerName($name)
{
switch($name)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative(); // not safe to use it because some methods may return objects (Blob)
?>
case getPhpName()) ?>():
return $this->get();
break;
default:
return null;
} // switch()
}
/**
* Retrieves a field from the object by Position as specified
* in the xml schema. Zero-based.
*
* @param int $pos position in xml schema
* @return mixed Value of field at $pos
*/
function & getByPosition($pos)
{
switch($pos)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative();// not safe to use it because some methods may return objects (Blob)
?>
case :
return $this->get();
break;
default:
return null;
} // switch()
}
isAlias() && $addGenericMutators && ! $table->isReadOnly())
{
?>
/**
* Sets all field values from the object passed in as array.
* Does not set primary keys or foreign keys !
*
* @param array $obj field => name.
* @return void
*/
function setByAssocArray(&$obj)
{
if (! is_array($obj))
return(false);
getColumns() as $col)
{
if (! $col->isPrimaryKey() && ! $col->isForeignKey())
{
$colName = $col->getName();
$phpName = $col->getPhpName();
?>
if (isset($obj[""]))
$this->set($obj[""]);
return true;
}
/**
* Sets a field value from the object by name passed in as a string.
*
* @param string $name field name
* @param mixed $value field value
* @return void
*/
function setByName($name, &$value)
{
switch($name)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative();
?>
case "getName()?>":
case "getPhpName()?>":
$this->set($value);
break;
} // switch()
}
/**
* Sets a field from the object by name passed in
* as a string. The string must be one of the static
* strings defined in this Class' Peer.
*
* @param string $name peer name
* @param mixed $value field value
* @return void
*/
function setByPeerName($name, &$value)
{
switch($name)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative();
?>
case getPhpName()) ?>():
$this->set($value);
break;
} // switch()
}
/**
* Sets a field from the object by Position as specified
* in the xml schema. Zero-based.
*
* @param int $pos position in xml schema
* @param mixed $value field value
* @return void
*/
function setByPosition($pos, &$value)
{
switch($pos)
{
getColumns() as $col)
{
$cfc = $col->getPhpName();
$cptype = $col->getPhpNative();
?>
case :
$this->set($value);
break;
} // switch()
}
isAlias() && isset($addSaveMethod) && $addSaveMethod && ! $table->isReadOnly())
{
?>
/**
* Removes this object from datastore and sets delete attribute.
*
* @return mixed TRUE on success, PropelException on failure.
* @throws PropelException
* @see BaseObject::setDeleted()
* @see BaseObject::isDeleted()
*/
function delete()
{
if ($this->isDeleted()) {
return new PropelException(PROPEL_ERROR, "This object has already been deleted.");
}
$con =& Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
$e = $con->begin();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
$e = getPhpName() ?>Peer::doDelete($this, Param::set($con));
if (Propel::isError($e)) { $con->rollback(); return $e; }
$this->setDeleted(true);
$e = $con->commit();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
return true;
}
/**
* flag to prevent endless save loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
var $alreadyInSave = false;
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed. This method
* wraps the doSave() worker method in a transaction.
*
* @return mixed TRUE on success, PropelException on failure.
*/
function save()
{
if ($this->isDeleted()) {
return new PropelException(PROPEL_ERROR, "You cannot save an object that has been deleted.");
}
$con =& Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
$e = $con->begin();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
$e = $this->doSave(Param::set($con));
if (Propel::isError($e)) { $con->rollback(); return $e; }
$e = $con->commit();
if (Creole::isError($e)) { $con->rollback(); return new PropelException(PROPEL_ERROR_DB, $e); }
return true;
}
/**
* Stores the object in the database. If the object is new,
* it inserts it; otherwise an update is performed.
*
* @return void
* @throws PropelException
*/
function doSave($con = null)
function save()
{
if ($this->isDeleted()) {
return new PropelException(PROPEL_ERROR, "You cannot save an object that has been deleted.");
}
$con =& Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME());
if (Propel::isError($con)) { return $con; }
/* [MA] temporarily check */
Propel::assertParam($con, 'getPhpName(); ?>', 'save', 1);
if (! $this->alreadyInSave) {
$this->alreadyInSave = true;
// We call the save method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this-> !== null) {
if ($this->->isModified()) {
if (Propel::isError($e = $this->->save())) {
return $e;
}
}
$this->set($this->);
}
// If this object has been modified, then save it to the database.
if ($this->isModified()) {
if ($this->isNew()) {
$pk = getPhpName() ?>Peer::doInsert($this, $conParam::set($con));
if (Propel::isError($pk)) { return $pk; }
getIdMethod() != "none") {
if (count($pks = $table->getPrimaryKey())) {
foreach ($pks as $pk) {
if ($pk->isAutoIncrement()) {
?>
$this->setgetPhpName();?>( $pk ); //[IMV] update autoincrement primary key
$this->setNew(false);
}
else {
$e = getPhpName() ?>Peer::doUpdate($this, $conParam::set($con));
if (Propel::isError($e)) { return $e; }
}
$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
}
getReferrers() as $fk)
{
$tblFK = $fk->getTable();
if ( $tblFK->getName() != $table->getName() )
{
$className = $tblFK->getPhpName();
$relCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK()) {
$relCol .= $column->getPhpName();
}
}
if ($relCol == "") {
$relCol = $className . "s";
} else {
$relCol = $className . "sRelatedBy" . $relCol;
}
$collName = "coll" . $relCol;
?>
if ($this-> !== null) {
for ($i=0,$size=count($this->); $i < $size; $i++) {
if (Propel::isError($e = $this->[$i]->save())) {
return $e;
}
}
}
$this->alreadyInSave = false;
}
return true;
}
isAlias && isset .... */
if (! $table->isAlias() && ! $table->isReadOnly())
{
?>
/**
* Validates the objects modified field values.
* This includes all objects related to this table.
*
* If $columns is either a column name or an array of column names
* only those columns are validated.
*
* @param mixed $columns Column name or an array of column names.
*
* @return mixed true if all columns pass validation
* or an array of ValidationFailed objects for columns that fail.
*/
function & validate($columns = null)
{
if ($columns)
{
return getPhpName()?>Peer::doValidate($this, $columns);
}
return getPhpName()?>Peer::doValidate($this);
return $this->doValidate();
}
/**
* flag to prevent endless validation loop, if this object is referenced
* by another object which falls in this transaction.
* @var boolean
*/
var $alreadyInValidation = false;
/**
* This function performs the validation work for complex object models.
*
* In addition to checking the current object, all related objects will
* also be validated. If all pass then true is returned; otherwise
* an aggreagated array of ValidationFailed objects will be returned.
*
* @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
*/
function & doValidate()
{
if (! $this->alreadyInValidation)
{
$this->alreadyInValidation = true;
$retval = null;
$failureMap = array();
// We call the validate method on the following object(s) if they
// were passed to this object by their coresponding set
// method. This object relates to these object(s) by a
// foreign key reference.
if ($this-> !== null) {
if (($retval = $this->->validate()) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
}
if (($retval = getPhpName()?>Peer::doValidate($this)) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
getReferrers() as $fk)
{
$tblFK = $fk->getTable();
if ( $tblFK->getName() != $table->getName() )
{
$className = $tblFK->getPhpName();
$relCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK()) {
$relCol .= $column->getPhpName();
}
}
if ($relCol == "") {
$relCol = $className . "s";
} else {
$relCol = $className . "sRelatedBy" . $relCol;
}
$collName = "coll" . $relCol;
?>
if ($this-> !== null) {
for ($i=0,$size=count($this->); $i < $size; $i++) {
if (($retval = $this->[$i]->validate()) !== true) {
$failureMap = array_merge($failureMap, $retval);
}
}
}
$this->alreadyInValidation = false;
return (!empty($failureMap) ? $failureMap : true);
}
return true;
}
isAlias())
{
if (! $table->isReadOnly())
{
$throwsClause = "@throws PropelException";
if (count($table->getPrimaryKey()) == 1)
{
$pkeys = $table->getPrimaryKey();
$col = $pkeys[0];
$clo=strtolower($col->getName());
$cptype= $col->getPhpNative();
?>
/**
* Set the PrimaryKey.
*
* @param mixed Primary key.
* @return void
*
*/
function setPrimaryKey($key)
{
$this->setgetPhpName() ?>($key);
}
getPrimaryKey()) > 1)
{
?>
var $pks = array();
/**
* Set the PrimaryKey.
*
* @param array $keys The elements of the composite key (order must match the order in XML file).
* @return void
* @throws PropelException
*/
function setPrimaryKey($keys)
{
getPrimaryKey() as $pk)
{
$pktype = $pk->getPhpNative();
?>
$this->setgetPhpName() ?>($keys[]);
getPrimaryKey() as $pk) */
?>
}
getPrimaryKey()) == 1) */
?>
/**
* Dummy primary key setter.
* For now this function needs to exist because it's mandated in the Persistent
* interface, and because other methods will attempt to set the primary key.
*
* This should be removed in favor of more complex template work.
*/
function setPrimaryKey($pk)
{
// do nothing, because this doesn't support primary keys
}
getPrimaryKey()) == 1) */
} /* if ! $table->isReadOnly() */
?>
/**
* Returns an id that differentiates this object from others
* of its class.
* @return getPrimaryKey()) === 0) { echo "null"; } elseif (count($table->getPrimaryKey()) > 1) { echo "array"; } else { $pkeys = $table->getPrimaryKey(); echo $pkeys[0]->getPhpType(); } ?>
*/
function getPrimaryKey()
{
getPrimaryKey()) == 1) {
?>
return $this->getgetPrimaryKey(); echo $pkeys[0]->getPhpName()?>();
getPrimaryKey()) > 1) {
$i = 0;
foreach ($table->getPrimaryKey() as $pk) {
?>
$this->pks[] = $this->getgetPhpName() ?>();
getPrimaryKey() as $pk) */
?>
return $this->pks;
return null;
}
isAbstract())
{
?>
/**
* Makes a copy of this object.
* It creates a new object filling in the simple attributes, but skipping any primary
* keys that are defined for the table.
*
* If desired, this method can also make copies of all associated (fkey referrers)
* objects.
*
* @param boolean $deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
*
* @return getPhpName() ?> Clone of current object.
* @throws PropelException
*/
function copy($deepCopy = false)
{
$copyObj = new getPhpName() ?>();
getColumns() as $pkcol) {
if ($pkcol->isPrimaryKey()) {
$pkcols[] = $pkcol->getName();
}
}
foreach ($table->getColumns() as $col)
{
if (!in_array($col->getName(), $pkcols)) {
?>
$copyObj->setgetPhpName()?>($this->getName()) ?>);
getReferrers()) > 0)
{
?>
if ($deepCopy) {
// important: setNew(false) because this affects the behavior of
// the getter/setter methods for fkey referrer objects.
$copyObj->setNew(false);
getReferrers() as $fk)
{
$tblFK = $fk->getTable();
if ( $tblFK->getName() != $table->getName() )
{
$className = $tblFK->getPhpName();
$relCol = "";
foreach ($fk->getLocalColumns() as $columnName) {
$column = $tblFK->getColumn($columnName);
if ($column->isMultipleFK()) {
$relCol .= $column->getPhpName();
}
}
if ($relCol == "") {
$pCollName = $className . "s";
$pCollNameNoS = $className;
} else {
$pCollName = $className . "sRelatedBy".$relCol;
$pCollNameNoS = $className . "RelatedBy".$relCol;
}
?>
foreach($this->get() as $relObj) {
$copyObj->add($relObj->copy());
}
} /* if ($deepCopy) */
0 ) */
?>
$copyObj->setNew(true);
getColumns() as $col)
{
if ($col->isPrimaryKey())
{
$coldefval = $col->getDefaultValue();
// This seems to work pretty well for getting
// the right value (including NULL)
$coldefval = var_export($coldefval, true);
?>
$copyObj->setgetPhpName()?>(); // this is a pkey column, so set to default value
isPrimaryKey
} // foreach
?>
return $copyObj;
}
isAbstract()) */
?>
/**
* Returns a peer instance associated with this om. Since Peer classes
* are not to have any instance attributes, this method returns the
* same instance for all member of this class. The method could therefore
* be static, but this would prevent one from overriding the behavior.
*
* @return getPhpName() ?>Peer
*/
function & getPeer()
{
static $instance;
if ($instance === null) {
$instance = new getPhpName()?>Peer();
}
return $instance;
}
isAlias */
?>
}