getDatabase(); if ($table->getPackage()) { $package = $table->getPackage(); } else { $package = $targetPackage; } $parentClass = ClassTools::getBaseClass($table); ?> require_once ''; 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') ?>'; 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 */ abstract class getPhpName() ?> extends implements { /** * 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 */ protected static $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 */ protected $; isLazyLoad()) { ?> /** * Whether the lazy-loaded value has been loaded from database. * This is necessary to avoid repeated lookups if column is NULL. * @var boolean */ protected $_isLoaded = false; 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] `` column 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). * @throws PropelException - if unable to convert the date/time to timestamp. */ public function get($format = ''isLazyLoad()) echo ', $con = null'; ?>) { isLazyLoad()) { ?> if (!$this->_isLoaded && $this-> === null && !$this->isNew()) { $this->load($con); } 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) { throw new PropelException("Unable to parse value of as date/time value: " . var_export($this->, true)); } } else { $ts = $this->; } if ($format === null) { return $ts; } elseif (strpos($format, '%') !== false) { return strftime($format, $ts); } else { return date($format, $ts); } } /** * Get the column value. * getDescription() ?> * @return */ public function get(isLazyLoad()) echo '$con = null'; ?>) { isLazyLoad()) { ?> if (!$this->_isLoaded && $this-> === null && !$this->isNew()) { $this->load($con); } return $this->; } 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. * * @param Connection * @return void * @throws PropelException - any underlying error will be wrapped and re-thrown. */ protected function load($con = null) { $c = $this->buildPkeyCriteria(); $c->addSelectColumn(getPhpName()) ?>); try { $rs = getPhpName()?>Peer::doSelectRS($c, $con); $rs->next(); 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); $this->_isLoaded = true; } catch (Exception $e) { throw new PropelException("Error loading value for `` column on demand.", $e); } } 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 `` column. * getDescription() ?> * @param $v new value * @return void * */ public 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; 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 ($v instanceof Lob && $v === $this->) { $changed = $v->isModified(); } else { $changed = ($this-> !== $v); } if ($changed) { if ( !($v instanceof 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) { throw new PropelException("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) { $this-> = null; } 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 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. */ public function hydrate(ResultSet $rs, $startcol = 1) { try { 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: ?> $this-> = $rs->get($startcol + , null); $this-> = $rs->get($startcol + ); isLazyLoad() } /* foreach */ ?> $this->resetModified(); $this->setNew(false); } catch (Exception $e) { throw new PropelException("Error populating getPhpName()?> object", $e); } } /** * 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). */ public function buildPkeyCriteria() { $criteria = new Criteria(getPhpName()?>Peer::DATABASE_NAME); getColumns() as $col) { $clo = strtolower($col->getName()); if ($col->isPrimaryKey()) { ?> $criteria->add(getPhpName()) ?>, $this->); 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. */ public 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 */ ?> 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 */ protected $; /** * Declares an association between this object and a object * * @param $v * @return void * @throws PropelException */ public 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 * * @param Connection Optional Connection object. * @return The associated object. * @throws PropelException */ public function get($con = null) { // include the Peer class include_once 'Peer.php'; if ($this-> === null && ()) { isAlias()) { if ($argsize > 1) { ?> $this-> = Peer::retrieveByPK(, $con); $this-> = Peer::retrieveByPK(, $con); 1) { ?> $this-> = Peer::retrieveByPK(, $con); $this-> = Peer::retrieveByPK(, $con); isAlias ?> /* 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(, $con); $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 */ public 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 */ protected $; /** * 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 */ public 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 */ public function add( $l) { $this->[] = $l; $l->setgetPhpName() . $suffix ?>($this); } /** * The criteria used to select the current contents of . * @var Criteria */ private $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 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 Connection $con * @param Criteria $criteria * @throws PropelException */ public function get($criteria = null, $con = 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() ?> $this-> = Peer::doSelect($criteria, $con); } } 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)) { $this-> = Peer::doSelect($criteria, $con); } } } $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() ?>. */ public function getJoin($criteria = null, $con = 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() ?> $this-> = Peer::doSelectJoin($criteria, $con); } } 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)) { $this-> = Peer::doSelectJoin($criteria, $con); } } $this->lastCriteria = $criteria; return $this->; } getForeignKeys() as $fk2) { */ } /* end if countFK >= 1 */ } /*ends foreach over table->getReferrers() */ } /* the if(complexObjectModel) */ // // getByName code // if (!$table->isAlias() && $addGenericAccessors) { ?> private $fieldNames; /** * Generate a list of field names. * * @return array A list of field names */ public function getFieldNames() { if ($this->fieldNames === null) { $this->fieldNames = array(getColumns() as $col) { ?>"getName() ?>", ); } return $this->fieldNames; } /** * 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. */ public 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 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 */ public 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()) { ?> /** * Convenience method to populate the object using an array. * This is particularly useful when populating an object from one of the request arrays (e.g. $_POST). This method * goest through the column (peer) names, checking to see whether a matching key exists in populated array. If * so the setByName() method is called for that column. * @param array $arr An array where keys are column names. * @return void */ public function populateFromArray($arr) { getColumns() as $col) { $cfc = $col->getPhpName(); $cptype = $col->getPhpNative(); ?> if (array_key_exists(getPhpName()) ?>, $arr)) $this->set($arr[getPhpName()) ?>]); } /** * 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 */ public function setByName($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 */ public 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. * * @param Connection $con * @return void * @throws PropelException * @see BaseObject::setDeleted() * @see BaseObject::isDeleted() */ public function delete($con = null) { if ($this->isDeleted()) { throw new PropelException("This object has already been deleted."); } if ($con === null) $con = Propel::getConnection(getPhpName()?>Peer::DATABASE_NAME); try { $con->begin(); getPhpName() ?>Peer::doDelete($this, $con); $this->setDeleted(true); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } } /** * flag to prevent endless save loop, if this object is referenced * by another object which falls in this transaction. * @var boolean */ private $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. * * @param Connection $con * @return void * @throws PropelException */ public function save($con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) $con = Propel::getConnection(getPhpName()?>Peer::DATABASE_NAME); try { $con->begin(); $this->doSave($con); $con->commit(); } catch (PropelException $e) { $con->rollback(); throw $e; } } /** * Stores the object in the database. If the object is new, * it inserts it; otherwise an update is performed. * * @param Connection $con * @return void * @throws PropelException */ protected function doSave($con) public function save($con = null) { if ($this->isDeleted()) { throw new PropelException("You cannot save an object that has been deleted."); } if ($con === null) { $con = Propel::getConnection(getPhpName() ?>Peer::DATABASE_NAME); } 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()) $this->->save($con); $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, $con); 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 { getPhpName() ?>Peer::doUpdate($this, $con); } $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++) { $this->[$i]->save($con); } } $this->alreadyInSave = false; } } isAlias && isset .... */ ?> 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. */ public 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 */ protected $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. */ protected 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); } 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 * */ public function setPrimaryKey($key) { $this->setgetPhpName() ?>($key); } getPrimaryKey()) > 1) { /* if(count($table->getPrimaryKey()) == 1) */ ?> private $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 */ public function setPrimaryKey($keys) { getPrimaryKey() as $pk) { $pktype = $pk->getPhpNative(); ?> $this->setgetPhpName() ?>($keys[]); getPrimaryKey() */ ?> } 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. */ public function setPrimaryKey($pk) { // do nothing, because this doesn't support primary keys } getPrimaryKey()) == 1) */ } /* !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(); } ?> */ public function getPrimaryKey() { getPrimaryKey()) == 1) { ?> return $this->getgetPrimaryKey(); echo $pkeys[0]->getPhpName()?>(); getPrimaryKey()) > 1) { /* if (count($table->getPrimaryKey()) == 1) { */ $i = 0; foreach ($table->getPrimaryKey() as $pk) { ?> $this->pks[] = $this->getgetPhpName() ?>(); return $this->pks; getPrimaryKey()) == 1) { */ ?> return null; getPrimaryKey()) == 1) { */ ?> } isAbstract()) { ?> /** * Makes a copy of this object that will be inserted as a new row in table when saved. * 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 */ public 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 */ public function getPeer() { if (self::$peer === null) { self::$peer = new getPhpName() ?>Peer(); } return self::$peer; } isAlias */ ?> }