diff --git a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php
index 77d5ee866..dbc9a628a 100755
--- a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php
+++ b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php
@@ -36,1379 +36,1384 @@ require_once 'propel/engine/builder/om/ObjectBuilder.php';
*/
class PHP5BasicObjectBuilder extends ObjectBuilder {
- /**
- * Gets the package for the [base] object classes.
- * @return string
- */
- public function getPackage()
- {
- return parent::getPackage() . ".om";
- }
+ /**
+ * Gets the package for the [base] object classes.
+ * @return string
+ */
+ public function getPackage()
+ {
+ return parent::getPackage() . ".om";
+ }
- /**
- * Returns the name of the current class being built.
- * @return string
- */
- public function getClassname()
- {
- return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getClassname();
- }
+ /**
+ * Returns the name of the current class being built.
+ * @return string
+ */
+ public function getClassname()
+ {
+ return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getClassname();
+ }
- /**
- * Adds the include() statements for files that this class depends on or utilizes.
- * @param string &$script The script will be modified in this method.
- */
- protected function addIncludes(&$script)
- {
+ /**
+ * Adds the include() statements for files that this class depends on or utilizes.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addIncludes(&$script)
+ {
- $table = $this->getTable();
- $package = $this->getPackage();
- $parentClass = $this->getBaseClass();
- $interface = $this->getInterface();
+ $table = $this->getTable();
+ $package = $this->getPackage();
+ $parentClass = $this->getBaseClass();
+ $interface = $this->getInterface();
- $script .= "
+ $script .= "
require_once '".$this->getFilePath($parentClass)."';
";
- if (!empty($interface)) {
- $script .= "
+ if (!empty($interface)) {
+ $script .= "
require_once '".$this->getFilePath($interface)."';
";
- }
+ }
- if (!$table->isAlias()) {
+ if (!$table->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.
+ // 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;
- }
- }
+ $includes_lobs = false;
+ foreach ($table->getColumns() as $col) {
+ if ($col->isLob()) {
+ $includes_lobs = true;
+ break;
+ }
+ }
- if($includes_lobs) {
- $script .= "
+ if($includes_lobs) {
+ $script .= "
include_once 'creole/util/Clob.php';
include_once 'creole/util/Blob.php';
";
- }
- } // if table is not alias
+ }
+ } // if table is not alias
- $script .= "
+ $script .= "
include_once 'propel/util/Criteria.php';
";
- $script .= "
+ $script .= "
include_once '".$this->getStubPeerBuilder()->getClassFilePath()."';
";
- } // addIncludes()
+ } // addIncludes()
- /**
- * Adds class phpdoc comment and openning of class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addClassOpen(&$script)
- {
+ /**
+ * Adds class phpdoc comment and openning of class.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addClassOpen(&$script)
+ {
- $table = $this->getTable();
- $tableName = $table->getName();
- $tableDesc = $table->getDescription();
- $interface = $this->getInterface();
+ $table = $this->getTable();
+ $tableName = $table->getName();
+ $tableDesc = $table->getDescription();
+ $interface = $this->getInterface();
- $script .= "
+ $script .= "
/**
* Base class that represents a row from the '$tableName' table.
*
* $tableDesc
*";
- if ($this->getBuildProperty('addTimeStamp')) {
- $now = strftime('%c');
- $script .= "
+ if ($this->getBuildProperty('addTimeStamp')) {
+ $now = strftime('%c');
+ $script .= "
* This class was autogenerated by Propel on:
*
* $now
*";
- }
- $script .= "
+ }
+ $script .= "
* @package workflow.".$this->getPackage()."
*/
abstract class ".$this->getClassname()." extends ".ClassTools::classname($this->getBaseClass())." ";
- $interface = ClassTools::getInterface($table);
- if ($interface) {
- $script .= " implements " . ClassTools::classname($interface);
- }
+ $interface = ClassTools::getInterface($table);
+ if ($interface) {
+ $script .= "implements " . ClassTools::classname($interface);
+ }
- $script .= " {
+ $script .= "\n{\n";
+ }
+
+ /**
+ * Specifies the methods that are added as part of the basic OM class.
+ * This can be overridden by subclasses that wish to add more methods.
+ * @see ObjectBuilder::addClassBody()
+ */
+ protected function addClassBody(&$script)
+ {
+ $table = $this->getTable();
+ if (!$table->isAlias()) {
+ $this->addConstants($script);
+ $this->addAttributes($script);
+ }
+
+ $this->addColumnAccessorMethods($script);
+ $this->addColumnMutatorMethods($script);
+
+ $this->addHydrate($script);
+
+ $this->addManipulationMethods($script);
+ $this->addValidationMethods($script);
+
+ if ($this->isAddGenericAccessors()) {
+ $this->addGetByName($script);
+ $this->addGetByPosition($script);
+ $this->addToArray($script);
+ }
+
+ if ($this->isAddGenericMutators()) {
+ $this->addSetByName($script);
+ $this->addSetByPosition($script);
+ $this->addFromArray($script);
+ }
+
+ $this->addBuildCriteria($script);
+ $this->addBuildPkeyCriteria($script);
+ $this->addGetPrimaryKey($script);
+ $this->addSetPrimaryKey($script);
+
+ $this->addCopy($script);
+
+ if (!$table->isAlias()) {
+ $this->addGetPeer($script);
+ }
+ }
+
+ /**
+ * Closes class.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addClassClose(&$script)
+ {
+ $script .= "}
";
- }
+ }
- /**
- * Specifies the methods that are added as part of the basic OM class.
- * This can be overridden by subclasses that wish to add more methods.
- * @see ObjectBuilder::addClassBody()
- */
- protected function addClassBody(&$script)
- {
- $table = $this->getTable();
- if (!$table->isAlias()) {
- $this->addConstants($script);
- $this->addAttributes($script);
- }
+ /**
+ * Adds any constants to the class.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addConstants(&$script)
+ {
+ // nothing to do here any more
+ // fieldnameTypeConstants have been moved to class BasePeer [sv]
+ }
- $this->addColumnAccessorMethods($script);
- $this->addColumnMutatorMethods($script);
-
- $this->addHydrate($script);
-
- $this->addManipulationMethods($script);
- $this->addValidationMethods($script);
-
- if ($this->isAddGenericAccessors()) {
- $this->addGetByName($script);
- $this->addGetByPosition($script);
- $this->addToArray($script);
- }
-
- if ($this->isAddGenericMutators()) {
- $this->addSetByName($script);
- $this->addSetByPosition($script);
- $this->addFromArray($script);
- }
-
- $this->addBuildCriteria($script);
- $this->addBuildPkeyCriteria($script);
- $this->addGetPrimaryKey($script);
- $this->addSetPrimaryKey($script);
-
- $this->addCopy($script);
-
- if (!$table->isAlias()) {
- $this->addGetPeer($script);
- }
- }
-
- /**
- * Closes class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addClassClose(&$script)
- {
- $script .= "
-} // " . $this->getClassname() . "
+ /**
+ * Adds class attributes.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addAttributes(&$script)
+ {
+ $script .= "
+ /**
+ * 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 ".$this->getPeerClassname()."
+ */
+ protected static \$peer;
";
- }
+ if (!$this->getTable()->isAlias()) {
+ $this->addColumnAttributes($script);
+ }
+ }
- /**
- * Adds any constants to the class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addConstants(&$script)
- {
- // nothing to do here any more
- // fieldnameTypeConstants have been moved to class BasePeer [sv]
- }
+ /**
+ * Adds variables that store column values.
+ * @param string &$script The script will be modified in this method.
+ * @see addColumnNameConstants()
+ */
+ protected function addColumnAttributes(&$script) {
- /**
- * Adds class attributes.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAttributes(&$script)
- {
- $script .= "
- /**
- * 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 ".$this->getPeerClassname()."
- */
- protected static \$peer;
-";
- if (!$this->getTable()->isAlias()) {
- $this->addColumnAttributes($script);
- }
- }
+ $table = $this->getTable();
- /**
- * Adds variables that store column values.
- * @param string &$script The script will be modified in this method.
- * @see addColumnNameConstants()
- */
- protected function addColumnAttributes(&$script) {
+ foreach ($table->getColumns() as $col) {
- $table = $this->getTable();
+ $cptype = $col->getPhpNative();
+ $clo=strtolower($col->getName());
+ $defVal = "";
+ if (($val = $col->getPhpDefaultValue()) !== null) {
+ settype($val, $cptype);
+ $defaultValue = var_export($val, true);
+ $defVal = " = " . $defaultValue;
+ }
- foreach ($table->getColumns() as $col) {
-
- $cptype = $col->getPhpNative();
- $clo=strtolower($col->getName());
- $defVal = "";
- if (($val = $col->getPhpDefaultValue()) !== null) {
- settype($val, $cptype);
- $defaultValue = var_export($val, true);
- $defVal = " = " . $defaultValue;
- }
-
- $script .= "
-
- /**
- * The value for the $clo field.
- * @var $cptype
- */
- protected \$" . $clo . $defVal . ";
+ $script .= "
+ /**
+ * The value for the $clo field.
+ * @var $cptype
+ */
+ protected \$" . $clo . $defVal . ";
";
- if ($col->isLazyLoad()) {
- $script .= "
- /**
- * Whether the lazy-loaded $clo value has been loaded from database.
- * This is necessary to avoid repeated lookups if $clo column is NULL in the db.
- * @var boolean
- */
- protected \$".$clo."_isLoaded = false;
+ if ($col->isLazyLoad()) {
+ $script .= "
+ /**
+ * Whether the lazy-loaded $clo value has been loaded from database.
+ * This is necessary to avoid repeated lookups if $clo column is NULL in the db.
+ * @var boolean
+ */
+ protected \$".$clo."_isLoaded = false;
";
- }
+ }
- } // foreach col
+ } // foreach col
- } // addColumnAttributes()
+ } // addColumnAttributes()
- /**
- * Adds the getPeer() method.
- * This is a convenient, non introspective way of getting the Peer class for a particular object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetPeer(&$script)
- {
- $script .= "
- /**
- * 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 ".$this->getPeerClassname()."
- */
- public function getPeer()
- {
- if (self::\$peer === null) {
- self::\$peer = new ".$this->getPeerClassname()."();
- }
- return self::\$peer;
- }
+ /**
+ * Adds the getPeer() method.
+ * This is a convenient, non introspective way of getting the Peer class for a particular object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetPeer(&$script)
+ {
+ $script .= "
+ /**
+ * 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 ".$this->getPeerClassname()."
+ */
+ public function getPeer()
+ {
+ if (self::\$peer === null) {
+ self::\$peer = new ".$this->getPeerClassname()."();
+ }
+ return self::\$peer;
+ }
";
- }
+ }
- // --------------------------------------------------------------
- //
- // A C C E S S O R M E T H O D S
- //
- // --------------------------------------------------------------
+ // --------------------------------------------------------------
+ //
+ // A C C E S S O R M E T H O D S
+ //
+ // --------------------------------------------------------------
- /**
- * Adds a date/time/timestamp getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addTemporalAccessor(&$script, $col)
- {
- $cfc=$col->getPhpName();
- $clo=strtolower($col->getName());
+ /**
+ * Adds a date/time/timestamp getter method.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnAccessors()
+ */
+ protected function addTemporalAccessor(&$script, $col)
+ {
+ $cfc=$col->getPhpName();
+ $clo=strtolower($col->getName());
- // these default values are based on the Creole defaults
- // the date and time default formats are locale-sensitive
- if ($col->getType() === PropelTypes::DATE) {
- $defaultfmt = $this->getBuildProperty('defaultDateFormat');
- } elseif ($col->getType() === PropelTypes::TIME) {
- $defaultfmt = $this->getBuildProperty('defaultTimeFormat');
- } elseif ($col->getType() === PropelTypes::TIMESTAMP) {
- $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
- }
+ // these default values are based on the Creole defaults
+ // the date and time default formats are locale-sensitive
+ if ($col->getType() === PropelTypes::DATE) {
+ $defaultfmt = $this->getBuildProperty('defaultDateFormat');
+ } elseif ($col->getType() === PropelTypes::TIME) {
+ $defaultfmt = $this->getBuildProperty('defaultTimeFormat');
+ } elseif ($col->getType() === PropelTypes::TIMESTAMP) {
+ $defaultfmt = $this->getBuildProperty('defaultTimeStampFormat');
+ }
- // if the default format property was an empty string, then we'll set it
- // to NULL, which will return the "native" integer timestamp
- if (empty($defaultfmt)) { $defaultfmt = null; }
+ // if the default format property was an empty string, then we'll set it
+ // to NULL, which will return the "native" integer timestamp
+ if (empty($defaultfmt)) { $defaultfmt = null; }
- $script .= "
- /**
- * Get the [optionally formatted] [$clo] column value.
- * ".$col->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$cfc(\$format = ".var_export($defaultfmt, true)."";
- if ($col->isLazyLoad()) $script .= ", \$con = null";
- $script .= ")
- {
+ $script .= "
+ /**
+ * Get the [optionally formatted] [$clo] column value.
+ * ".$col->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$cfc(\$format = ".var_export($defaultfmt, true)."";
+ if ($col->isLazyLoad()) $script .= ", \$con = null";
+ $script .= ")
+ {
";
- if ($col->isLazyLoad()) {
- $script .= "
- if (!\$this->".$clo."_isLoaded && \$this->$clo === null && !\$this->isNew()) {
- \$this->load$cfc(\$con);
- }
+ if ($col->isLazyLoad()) {
+ $script .= "
+ if (!\$this->".$clo."_isLoaded && \$this->$clo === null && !\$this->isNew()) {
+ \$this->load$cfc(\$con);
+ }
";
- }
- $script .= "
- if (\$this->$clo === null || \$this->$clo === '') {
- return null;
- } elseif (!is_int(\$this->$clo)) {
- // a non-timestamp value was set externally, so we convert it
- \$ts = strtotime(\$this->$clo);
- if (\$ts === -1 || \$ts === false) { // in PHP 5.1 return value changes to FALSE
- throw new PropelException(\"Unable to parse value of [$clo] as date/time value: \" . var_export(\$this->$clo, true));
- }
- } else {
- \$ts = \$this->$clo;
- }
- if (\$format === null) {
- return \$ts;
- } elseif (strpos(\$format, '%') !== false) {
- return strftime(\$format, \$ts);
- } else {
- return date(\$format, \$ts);
- }
- }
+ }
+ $script .= "
+ if (\$this->$clo === null || \$this->$clo === '') {
+ return null;
+ } elseif (!is_int(\$this->$clo)) {
+ // a non-timestamp value was set externally, so we convert it
+ \$ts = strtotime(\$this->$clo);
+ if (\$ts === -1 || \$ts === false) {
+ throw new PropelException(\"Unable to parse value of [$clo] as date/time value: \" .
+ var_export(\$this->$clo, true));
+ }
+ } else {
+ \$ts = \$this->$clo;
+ }
+ if (\$format === null) {
+ return \$ts;
+ } elseif (strpos(\$format, '%') !== false) {
+ return strftime(\$format, \$ts);
+ } else {
+ return date(\$format, \$ts);
+ }
+ }
";
- } // addTemporalAccessor
+ } // addTemporalAccessor
- /**
- * Adds a normal (non-temporal) getter method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addGenericAccessor(&$script, $col)
- {
- $cfc=$col->getPhpName();
- $clo=strtolower($col->getName());
+ /**
+ * Adds a normal (non-temporal) getter method.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnAccessors()
+ */
+ protected function addGenericAccessor(&$script, $col)
+ {
+ $cfc=$col->getPhpName();
+ $clo=strtolower($col->getName());
- $script .= "
- /**
- * Get the [$clo] column value.
- * ".$col->getDescription()."
- * @return ".$col->getPhpNative()."
- */
- public function get$cfc(";
- if ($col->isLazyLoad()) $script .= "\$con = null";
- $script .= ")
- {
+ $script .= "
+ /**
+ * Get the [$clo] column value.
+ * ".$col->getDescription()."
+ * @return ".$col->getPhpNative()."
+ */
+ public function get$cfc(";
+ if ($col->isLazyLoad()) $script .= "\$con = null";
+ $script .= ")
+ {
";
- if ($col->isLazyLoad()) {
- $script .= "
- if (!\$this->".$clo."_isLoaded && \$this->$clo === null && !\$this->isNew()) {
- \$this->load$cfc(\$con);
- }
+ if ($col->isLazyLoad()) {
+ $script .= "
+ if (!\$this->".$clo."_isLoaded && \$this->$clo === null && !\$this->isNew()) {
+ \$this->load$cfc(\$con);
+ }
";
- }
- $script .= "
- return \$this->$clo;
- }
+ }
+ $script .= "
+ return \$this->$clo;
+ }
";
- }
+ }
- /**
- * Adds the lazy loader method.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnAccessors()
- */
- protected function addLazyLoader(&$script, $col)
- {
- $cfc=$col->getPhpName();
- $clo=strtolower($col->getName());
+ /**
+ * Adds the lazy loader method.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnAccessors()
+ */
+ protected function addLazyLoader(&$script, $col)
+ {
+ $cfc=$col->getPhpName();
+ $clo=strtolower($col->getName());
- $script .= "
- /**
- * Load the value for the lazy-loaded [$clo] column.
- *
- * This method performs an additional query to return the value for
- * the [$clo] column, since it is not populated by
- * the hydrate() method.
- *
- * @param \$con Connection
- * @return void
- * @throws PropelException - any underlying error will be wrapped and re-thrown.
- */
- protected function load$cfc(\$con = null)
- {
- \$c = \$this->buildPkeyCriteria();
- \$c->addSelectColumn(".$this->getColumnConstant($col).");
- try {
- \$rs = ".$this->getPeerClassname()."::doSelectRS(\$c, \$con);
- \$rs->next();
+ $script .= "
+ /**
+ * Load the value for the lazy-loaded [$clo] column.
+ *
+ * This method performs an additional query to return the value for
+ * the [$clo] column, since it is not populated by
+ * the hydrate() method.
+ *
+ * @param \$con Connection
+ * @return void
+ * @throws PropelException - any underlying error will be wrapped and re-thrown.
+ */
+ protected function load$cfc(\$con = null)
+ {
+ \$c = \$this->buildPkeyCriteria();
+ \$c->addSelectColumn(".$this->getColumnConstant($col).");
+ try {
+ \$rs = ".$this->getPeerClassname()."::doSelectRS(\$c, \$con);
+ \$rs->next();
";
- $affix = CreoleTypes::getAffix(CreoleTypes::getCreoleCode($col->getType()));
- $clo = strtolower($col->getName());
- switch($col->getType()) {
- case PropelTypes::DATE:
- case PropelTypes::TIME:
- case PropelTypes::TIMESTAMP:
- $script .= "
- \$this->$clo = \$rs->get$affix(1, null);
+ $affix = CreoleTypes::getAffix(CreoleTypes::getCreoleCode($col->getType()));
+ $clo = strtolower($col->getName());
+ switch($col->getType()) {
+ case PropelTypes::DATE:
+ case PropelTypes::TIME:
+ case PropelTypes::TIMESTAMP:
+ $script .= "
+ \$this->$clo = \$rs->get$affix(1, null);
";
- break;
- default:
- $script .= "
- \$this->$clo = \$rs->get$affix(1);
+ break;
+ default:
+ $script .= "
+ \$this->$clo = \$rs->get$affix(1);
";
- } // switch
- $script .= "
- \$this->".$clo."_isLoaded = true;
- } catch (Exception \$e) {
- throw new PropelException(\"Error loading value for [$clo] column on demand.\", \$e);
- }
- }
+ } // switch
+ $script .= "
+ \$this->".$clo."_isLoaded = true;
+ } catch (Exception \$e) {
+ throw new PropelException(\"Error loading value for [$clo] column on demand.\", \$e);
+ }
+ }
";
- } // addLazyLoader()
+ } // addLazyLoader()
- // --------------------------------------------------------------
- //
- // M U T A T O R M E T H O D S
- //
- // --------------------------------------------------------------
+ // --------------------------------------------------------------
+ //
+ // M U T A T O R M E T H O D S
+ //
+ // --------------------------------------------------------------
- /**
- * Adds the open of the mutator (setter) method for a column.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addMutatorOpen(&$script, Column $col)
- {
- $cfc=$col->getPhpName();
- $clo=strtolower($col->getName());
+ /**
+ * Adds the open of the mutator (setter) method for a column.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ */
+ protected function addMutatorOpen(&$script, Column $col)
+ {
+ $cfc=$col->getPhpName();
+ $clo=strtolower($col->getName());
- $script .= "
- /**
- * Set the value of [$clo] column.
- * ".$col->getDescription()."
- * @param ".$col->getPhpNative()." \$v new value
- * @return void
- */
- public function set$cfc(\$v)
- {
+ $script .= "
+ /**
+ * Set the value of [$clo] column.
+ * ".$col->getDescription()."
+ * @param ".$col->getPhpNative()." \$v new value
+ * @return void
+ */
+ public function set$cfc(\$v)
+ {
";
- if ($col->isLazyLoad()) {
- $script .= "
- // 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$cfc() method is called.
- \$this->".$clo."_isLoaded = true;
+ if ($col->isLazyLoad()) {
+ $script .= "
+ // 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$cfc() method is called.
+ \$this->".$clo."_isLoaded = true;
";
- }
+ }
- }
+ }
- /**
- * Adds the close of the mutator (setter) method for a column.
- * This can be overridden (e.g. by PHP5ComplexObjectBuilder) if additional functionality is needed.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- */
- protected function addMutatorClose(&$script, Column $col)
- {
- $script .= "
- } // set".$col->getPhpName()."()
+ /**
+ * Adds the close of the mutator (setter) method for a column.
+ * This can be overridden (e.g. by PHP5ComplexObjectBuilder) if additional functionality is needed.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ */
+ protected function addMutatorClose(&$script, Column $col)
+ {
+ $script .= "
+ } // set".$col->getPhpName()."()
";
- }
+ }
- /**
- * Adds a setter for date/time/timestamp columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addLobMutator(&$script, Column $col)
- {
- $this->addMutatorOpen($script, $col);
- $clo = strtolower($col->getName());
- // Setting of LOB columns gets some special handling
+ /**
+ * Adds a setter for date/time/timestamp columns.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnMutators()
+ */
+ protected function addLobMutator(&$script, Column $col)
+ {
+ $this->addMutatorOpen($script, $col);
+ $clo = strtolower($col->getName());
+ // Setting of LOB columns gets some special handling
- if ($col->getPropelType() === PropelTypes::BLOB || $col->getPropelType() === PropelTypes::LONGVARBINARY ) {
- $lobClass = 'Blob';
- } else {
- $lobClass = 'Clob';
- }
- $script .= "
- // 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->$clo) {
- \$changed = \$v->isModified();
- } else {
- \$changed = (\$this->$clo !== \$v);
- }
- if (\$changed) {
- if ( !(\$v instanceof Lob) ) {
- \$obj = new $lobClass();
- \$obj->setContents(\$v);
- } else {
- \$obj = \$v;
- }
- \$this->$clo = \$obj;
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
+ if ($col->getPropelType() === PropelTypes::BLOB || $col->getPropelType() === PropelTypes::LONGVARBINARY ) {
+ $lobClass = 'Blob';
+ } else {
+ $lobClass = 'Clob';
+ }
+ $script .= "
+ // 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->$clo) {
+ \$changed = \$v->isModified();
+ } else {
+ \$changed = (\$this->$clo !== \$v);
+ }
+ if (\$changed) {
+ if ( !(\$v instanceof Lob) ) {
+ \$obj = new $lobClass();
+ \$obj->setContents(\$v);
+ } else {
+ \$obj = \$v;
+ }
+ \$this->$clo = \$obj;
+ \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
+ }
";
- $this->addMutatorClose($script, $col);
+ $this->addMutatorClose($script, $col);
- } // addLobMutatorSnippet
+ } // addLobMutatorSnippet
- /**
- * Adds a setter method for date/time/timestamp columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addTemporalMutator(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
+ /**
+ * Adds a setter method for date/time/timestamp columns.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnMutators()
+ */
+ protected function addTemporalMutator(&$script, Column $col)
+ {
+ $clo = strtolower($col->getName());
- $defaultValue = null;
- if (($val = $col->getPhpDefaultValue()) !== null) {
- settype($val, $col->getPhpNative());
- $defaultValue = var_export($val, true);
- }
+ $defaultValue = null;
+ if (($val = $col->getPhpDefaultValue()) !== null) {
+ settype($val, $col->getPhpNative());
+ $defaultValue = var_export($val, true);
+ }
- $this->addMutatorOpen($script, $col);
+ $this->addMutatorOpen($script, $col);
- $script .= "
- if (\$v !== null && !is_int(\$v)) {
- \$ts = strtotime(\$v);
- if (\$ts === -1 || \$ts === false) { // in PHP 5.1 return value changes to FALSE
- throw new PropelException(\"Unable to parse date/time value for [$clo] from input: \" . var_export(\$v, true));
- }
- } else {
- \$ts = \$v;
- }
- if (\$this->$clo !== \$ts";
- if ($defaultValue !== null) {
- $script .= " || \$ts === $defaultValue";
- }
- $script .= ") {
- \$this->$clo = \$ts;
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
+ $script .= "
+ if (\$v !== null && !is_int(\$v)) {
+ \$ts = strtotime(\$v);
+ if (\$ts === -1 || \$ts === false) {
+ throw new PropelException(\"Unable to parse date/time value for [$clo] from input: \" .
+ var_export(\$v, true));
+ }
+ } else {
+ \$ts = \$v;
+ }
+ if (\$this->$clo !== \$ts";
+ if ($defaultValue !== null) {
+ $script .= " || \$ts === $defaultValue";
+ }
+ $script .= ") {
+ \$this->$clo = \$ts;
+ \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
+ }
";
- $this->addMutatorClose($script, $col);
- }
+ $this->addMutatorClose($script, $col);
+ }
- /**
- * Adds setter method for "normal" columns.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see parent::addColumnMutators()
- */
- protected function addDefaultMutator(&$script, Column $col)
- {
- $clo = strtolower($col->getName());
+ /**
+ * Adds setter method for "normal" columns.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see parent::addColumnMutators()
+ */
+ protected function addDefaultMutator(&$script, Column $col)
+ {
+ $clo = strtolower($col->getName());
- // FIXME: refactor this
- $defaultValue = null;
- if (($val = $col->getPhpDefaultValue()) !== null) {
- settype($val, $col->getPhpNative());
- $defaultValue = var_export($val, true);
- }
+ // FIXME: refactor this
+ $defaultValue = null;
+ if (($val = $col->getPhpDefaultValue()) !== null) {
+ settype($val, $col->getPhpNative());
+ $defaultValue = var_export($val, true);
+ }
- $this->addMutatorOpen($script, $col);
-
- // Perform some smart checking here to handle possible type discrepancies
- // between the passed-in value and the value from the DB
-
- if ($col->getPhpNative() === "int") {
- $script .= "
- // Since the native PHP type for this column is integer,
- // we will cast the input value to an int (if it is not).
- if (\$v !== null && !is_int(\$v) && is_numeric(\$v)) {
- \$v = (int) \$v;
- }
+ $this->addMutatorOpen($script, $col);
+
+ // Perform some smart checking here to handle possible type discrepancies
+ // between the passed-in value and the value from the DB
+
+ if ($col->getPhpNative() === "int") {
+ $script .= "
+ // Since the native PHP type for this column is integer,
+ // we will cast the input value to an int (if it is not).
+ if (\$v !== null && !is_int(\$v) && is_numeric(\$v)) {
+ \$v = (int) \$v;
+ }
";
- } elseif ($col->getPhpNative() === "string") {
- $script .= "
- // Since the native PHP type for this column is string,
- // we will cast the input to a string (if it is not).
- if (\$v !== null && !is_string(\$v)) {
- \$v = (string) \$v;
- }
+ } elseif ($col->getPhpNative() === "string") {
+ $script .= "
+ // Since the native PHP type for this column is string,
+ // we will cast the input to a string (if it is not).
+ if (\$v !== null && !is_string(\$v)) {
+ \$v = (string) \$v;
+ }
";
- }
-
- $script .= "
- if (\$this->$clo !== \$v";
- if ($defaultValue !== null) {
- $script .= " || \$v === $defaultValue";
- }
- $script .= ") {
- \$this->$clo = \$v;
- \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
- }
+ }
+
+ $script .= "
+ if (\$this->$clo !== \$v";
+ if ($defaultValue !== null) {
+ $script .= " || \$v === $defaultValue";
+ }
+ $script .= ") {
+ \$this->$clo = \$v;
+ \$this->modifiedColumns[] = ".$this->getColumnConstant($col).";
+ }
";
- $this->addMutatorClose($script, $col);
- }
+ $this->addMutatorClose($script, $col);
+ }
- /**
- * Adds the hydrate() method, which sets attributes of the object based on a ResultSet.
- */
- protected function addHydrate(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the hydrate() method, which sets attributes of the object based on a ResultSet.
+ */
+ protected function addHydrate(&$script)
+ {
+ $table = $this->getTable();
- $script .= "
- /**
- * 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 int next starting column
- * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
- */
- public function hydrate(ResultSet \$rs, \$startcol = 1)
- {
- try {
+ $script .= "
+ /**
+ * 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 int next starting column
+ * @throws PropelException - Any caught Exception will be rewrapped as a PropelException.
+ */
+ public function hydrate(ResultSet \$rs, \$startcol = 1)
+ {
+ try {
";
- $n = 0;
- foreach($table->getColumns() as $col) {
- if(!$col->isLazyLoad()) {
- $affix = CreoleTypes::getAffix(CreoleTypes::getCreoleCode($col->getType()));
- $clo = strtolower($col->getName());
- switch($col->getType()) {
+ $n = 0;
+ foreach($table->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:
- $script .= "
- \$this->$clo = \$rs->get$affix(\$startcol + $n, null);
+ case PropelTypes::DATE:
+ case PropelTypes::TIME:
+ case PropelTypes::TIMESTAMP:
+ $script .= "
+ \$this->$clo = \$rs->get$affix(\$startcol + $n, null);
";
- break;
- default:
- $script .= "
- \$this->$clo = \$rs->get$affix(\$startcol + $n);
+ break;
+ default:
+ $script .= "
+ \$this->$clo = \$rs->get$affix(\$startcol + $n);
";
- }
- $n++;
- } // if col->isLazyLoad()
- } /* foreach */
+ }
+ $n++;
+ } // if col->isLazyLoad()
+ } /* foreach */
- if ($this->getBuildProperty("addSaveMethod")) {
- $script .= "
- \$this->resetModified();
+ if ($this->getBuildProperty("addSaveMethod")) {
+ $script .= "
+ \$this->resetModified();
";
- }
+ }
- $script .= "
- \$this->setNew(false);
+ $script .= "
+ \$this->setNew(false);
- // FIXME - using NUM_COLUMNS may be clearer.
- return \$startcol + $n; // $n = ".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS).
+ // FIXME - using NUM_COLUMNS may be clearer.
+ return \$startcol + $n; // $n = ".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS).
- } catch (Exception \$e) {
- throw new PropelException(\"Error populating ".$table->getPhpName()." object\", \$e);
- }
- }
+ } catch (Exception \$e) {
+ throw new PropelException(\"Error populating ".$table->getPhpName()." object\", \$e);
+ }
+ }
";
- } // addHydrate()
+ } // addHydrate()
- /**
- *
- */
- protected function addBuildPkeyCriteria(&$script) {
+ /**
+ *
+ */
+ protected function addBuildPkeyCriteria(&$script) {
- $script .= "
- /**
- * 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(".$this->getPeerClassname()."::DATABASE_NAME);
+ $script .= "
+ /**
+ * 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(".$this->getPeerClassname()."::DATABASE_NAME);
";
- foreach ($this->getTable()->getColumns() as $col) {
- $clo = strtolower($col->getName());
- if ($col->isPrimaryKey()) {
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);";
- }
- }
+ foreach ($this->getTable()->getColumns() as $col) {
+ $clo = strtolower($col->getName());
+ if ($col->isPrimaryKey()) {
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);";
+ }
+ }
- $script .= "
+ $script .= "
- return \$criteria;
- }
+ return \$criteria;
+ }
";
- }
+ }
- /**
- *
- */
- protected function addBuildCriteria(&$script)
- {
- $script .= "
- /**
- * 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(".$this->getPeerClassname()."::DATABASE_NAME);
+ /**
+ *
+ */
+ protected function addBuildCriteria(&$script)
+ {
+ $script .= "
+ /**
+ * 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(".$this->getPeerClassname()."::DATABASE_NAME);
";
- foreach ($this->getTable()->getColumns() as $col) {
- $clo = strtolower($col->getName());
- $script .= "
- if (\$this->isColumnModified(".$this->getColumnConstant($col).")) \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);";
- }
- $script .= "
-
- return \$criteria;
- }
+ foreach ($this->getTable()->getColumns() as $col) {
+ $clo = strtolower($col->getName());
+ $script .= "
+ if (\$this->isColumnModified(".$this->getColumnConstant($col).")) {
+ \$criteria->add(".$this->getColumnConstant($col).", \$this->$clo);
+ }
";
- } // addBuildCriteria()
+ }
+ $script .= "
- protected function addToArray(&$script)
- {
- $script .= "
- /**
- * Exports the object as an array.
- *
- * You can specify the key type of the array by passing one of the class
- * type constants.
- *
- * @param string \$keyType One of the class type constants TYPE_PHPNAME,
- * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
- * @return an associative array containing the field names (as keys) and field values
- */
- public function toArray(\$keyType = BasePeer::TYPE_PHPNAME)
- {
- \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType);
- \$result = array(";
- foreach ($this->getTable()->getColumns() as $num => $col) {
- $script .= "
- \$keys[$num] => \$this->get".$col->getPhpName()."(),";
- }
- $script .= "
- );
- return \$result;
- }
+ return \$criteria;
+ }
";
- } // addToArray()
+ } // addBuildCriteria()
- protected function addGetByName(&$script)
- {
- $script .= "
- /**
- * Retrieves a field from the object by name passed in as a string.
- *
- * @param string \$name name
- * @param string \$type The type of fieldname the \$name is of:
- * one of the class type constants TYPE_PHPNAME,
- * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
- * @return mixed Value of field.
- */
- public function getByName(\$name, \$type = BasePeer::TYPE_PHPNAME)
- {
- \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM);
- return \$this->getByPosition(\$pos);
- }
+ protected function addToArray(&$script)
+ {
+ $script .= "
+ /**
+ * Exports the object as an array.
+ *
+ * You can specify the key type of the array by passing one of the class
+ * type constants.
+ *
+ * @param string \$keyType One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return an associative array containing the field names (as keys) and field values
+ */
+ public function toArray(\$keyType = BasePeer::TYPE_PHPNAME)
+ {
+ \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType);
+ \$result = array(";
+ foreach ($this->getTable()->getColumns() as $num => $col) {
+ $script .= "
+ \$keys[$num] => \$this->get".$col->getPhpName()."(),";
+ }
+ $script .= "
+ );
+ return \$result;
+ }
";
- }
+ } // addToArray()
- protected function addGetByPosition(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * 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) {";
- $i = 0;
- foreach ($table->getColumns() as $col) {
- $cfc = $col->getPhpName();
- $cptype = $col->getPhpNative();// not safe to use it because some methods may return objects (Blob)
+ protected function addGetByName(&$script)
+ {
+ $script .= "
+ /**
+ * Retrieves a field from the object by name passed in as a string.
+ *
+ * @param string \$name name
+ * @param string \$type The type of fieldname the \$name is of:
+ * one of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return mixed Value of field.
+ */
+ public function getByName(\$name, \$type = BasePeer::TYPE_PHPNAME)
+ {
+ \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM);
+ return \$this->getByPosition(\$pos);
+ }
+";
+ }
+
+ protected function addGetByPosition(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * 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) {";
+ $i = 0;
+ foreach ($table->getColumns() as $col) {
+ $cfc = $col->getPhpName();
+ $cptype = $col->getPhpNative();// not safe to use it because some methods may return objects (Blob)
$script .= "
- case $i:
- return \$this->get$cfc();
- break;";
- $i++;
- } /* foreach */
+ case $i:
+ return \$this->get$cfc();
+ break;";
+ $i++;
+ } /* foreach */
$script .= "
- default:
- return null;
- break;
- } // switch()
- }
+ default:
+ return null;
+ break;
+ } // switch()
+ }
";
- }
+ }
- protected function addSetByName(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Sets a field from the object by name passed in as a string.
- *
- * @param string \$name peer name
- * @param mixed \$value field value
- * @param string \$type The type of fieldname the \$name is of:
- * one of the class type constants TYPE_PHPNAME,
- * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
- * @return void
- */
- public function setByName(\$name, \$value, \$type = BasePeer::TYPE_PHPNAME)
- {
- \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM);
- return \$this->setByPosition(\$pos, \$value);
- }
+ protected function addSetByName(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Sets a field from the object by name passed in as a string.
+ *
+ * @param string \$name peer name
+ * @param mixed \$value field value
+ * @param string \$type The type of fieldname the \$name is of:
+ * one of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return void
+ */
+ public function setByName(\$name, \$value, \$type = BasePeer::TYPE_PHPNAME)
+ {
+ \$pos = ".$this->getPeerClassname()."::translateFieldName(\$name, \$type, BasePeer::TYPE_NUM);
+ return \$this->setByPosition(\$pos, \$value);
+ }
";
- }
+ }
- protected function addSetByPosition(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * 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) {";
- $i = 0;
- foreach ($table->getColumns() as $col) {
- $cfc = $col->getPhpName();
- $cptype = $col->getPhpNative();
- $script .= "
- case $i:
- \$this->set$cfc(\$value);
- break;";
- $i++;
- } /* foreach */
- $script .= "
- } // switch()
- }
+ protected function addSetByPosition(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * 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) {";
+ $i = 0;
+ foreach ($table->getColumns() as $col) {
+ $cfc = $col->getPhpName();
+ $cptype = $col->getPhpNative();
+ $script .= "
+ case $i:
+ \$this->set$cfc(\$value);
+ break;";
+ $i++;
+ } /* foreach */
+ $script .= "
+ } // switch()
+ }
";
- } // addSetByPosition()
+ } // addSetByPosition()
- protected function addFromArray(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Populates the object using an array.
- *
- * This is particularly useful when populating an object from one of the
- * request arrays (e.g. \$_POST). This method goes through the column
- * names, checking to see whether a matching key exists in populated
- * array. If so the setByName() method is called for that column.
- *
- * You can specify the key type of the array by additionally passing one
- * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
- * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
- *
- * @param array \$arr An array to populate the object from.
- * @param string \$keyType The type of keys the array uses.
- * @return void
- */
- public function fromArray(\$arr, \$keyType = BasePeer::TYPE_PHPNAME)
- {
- \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType);
+ protected function addFromArray(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Populates the object using an array.
+ *
+ * This is particularly useful when populating an object from one of the
+ * request arrays (e.g. \$_POST). This method goes through the column
+ * names, checking to see whether a matching key exists in populated
+ * array. If so the setByName() method is called for that column.
+ *
+ * You can specify the key type of the array by additionally passing one
+ * of the class type constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME,
+ * TYPE_NUM. The default key type is the column's phpname (e.g. 'authorId')
+ *
+ * @param array \$arr An array to populate the object from.
+ * @param string \$keyType The type of keys the array uses.
+ * @return void
+ */
+ public function fromArray(\$arr, \$keyType = BasePeer::TYPE_PHPNAME)
+ {
+ \$keys = ".$this->getPeerClassname()."::getFieldNames(\$keyType);
";
- foreach ($table->getColumns() as $num => $col) {
- $cfc = $col->getPhpName();
- $cptype = $col->getPhpNative();
- $script .= "
- if (array_key_exists(\$keys[$num], \$arr)) \$this->set$cfc(\$arr[\$keys[$num]]);";
- } /* foreach */
- $script .= "
- }
+ foreach ($table->getColumns() as $num => $col) {
+ $cfc = $col->getPhpName();
+ $cptype = $col->getPhpNative();
+ $script .= "
+ if (array_key_exists(\$keys[$num], \$arr)) {
+ \$this->set$cfc(\$arr[\$keys[$num]]);
+ }
";
- } // addFromArray
-
-
-
- protected function addDelete(&$script)
- {
- $script .= "
- /**
- * 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(".$this->getPeerClassname()."::DATABASE_NAME);
- }
-
- try {
- \$con->begin();
- ".$this->getPeerClassname()."::doDelete(\$this, \$con);
- \$this->setDeleted(true);
- \$con->commit();
- } catch (PropelException \$e) {
- \$con->rollback();
- throw \$e;
- }
- }
+ } /* foreach */
+ $script .= "
+ }
";
- } // addDelete()
+ } // addFromArray
- /**
- * Adds the methods related to saving and deleting the object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addManipulationMethods(&$script)
- {
- $this->addDelete($script);
- $this->addSave($script);
- }
- /**
- * Adds the methods related to validationg the object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidationMethods(&$script)
- {
- $this->addValidationFailuresAttribute($script);
- $this->addGetValidationFailures($script);
- $this->addValidate($script);
- }
- /**
- * Adds the save() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addSave(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Stores the object in the database.
- *
- * If the object is new, it inserts it; otherwise an update is performed.
- *
- * @param Connection \$con
- * @return int The number of rows affected by this insert/update operation (for non-complex OM this will be at most 1).
- * @throws PropelException
- */
- public function save(\$con = null)
- {
- \$affectedRows = 0; // initialize var to track total num of affected rows
+ protected function addDelete(&$script)
+ {
+ $script .= "
+ /**
+ * 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 this object has been modified, then save it to the database.
- if (\$this->isModified()) {
- if (\$this->isNew()) {
- \$pk = ".$this->getPeerClassname()."::doInsert(\$this, \$con);
- \$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
- // should always be true here (even though technically
- // BasePeer::doInsert() can insert multiple rows).
+ if (\$con === null) {
+ \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME);
+ }
+
+ try {
+ \$con->begin();
+ ".$this->getPeerClassname()."::doDelete(\$this, \$con);
+ \$this->setDeleted(true);
+ \$con->commit();
+ } catch (PropelException \$e) {
+ \$con->rollback();
+ throw \$e;
+ }
+ }
";
- if ($table->getIdMethod() != "none") {
- if (count($pks = $table->getPrimaryKey())) {
- foreach ($pks as $pk) {
- if ($pk->isAutoIncrement()) {
- $script .= "
- \$this->set".$pk->getPhpName()."(\$pk); //[IMV] update autoincrement primary key
-";
- }
- }
- }
- }
- $script .= "
- \$this->setNew(false);
- } else {
- \$affectedRows += ".$this->getPeerClassname()."::doUpdate(\$this, \$con);
- }
- \$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
- } // if \$this->isModified()
+ } // addDelete()
- return \$affectedRows;
- } // save()
+ /**
+ * Adds the methods related to saving and deleting the object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addManipulationMethods(&$script)
+ {
+ $this->addDelete($script);
+ $this->addSave($script);
+ }
+
+ /**
+ * Adds the methods related to validationg the object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addValidationMethods(&$script)
+ {
+ $this->addValidationFailuresAttribute($script);
+ $this->addGetValidationFailures($script);
+ $this->addValidate($script);
+ }
+
+ /**
+ * Adds the save() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addSave(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Stores the object in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ *
+ * @param Connection \$con
+ * @return int The number of rows affected by this insert/update operation
+ * @throws PropelException
+ */
+ public function save(\$con = null)
+ {
+ \$affectedRows = 0; // initialize var to track total num of affected rows
+
+ // If this object has been modified, then save it to the database.
+ if (\$this->isModified()) {
+ if (\$this->isNew()) {
+ \$pk = ".$this->getPeerClassname()."::doInsert(\$this, \$con);
+ \$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
+ // should always be true here (even though technically
+ // BasePeer::doInsert() can insert multiple rows).
+";
+ if ($table->getIdMethod() != "none") {
+ if (count($pks = $table->getPrimaryKey())) {
+ foreach ($pks as $pk) {
+ if ($pk->isAutoIncrement()) {
+ $script .= "
+ \$this->set".$pk->getPhpName()."(\$pk); //[IMV] update autoincrement primary key
+";
+ }
+ }
+ }
+ }
+ $script .= "
+ \$this->setNew(false);
+ } else {
+ \$affectedRows += ".$this->getPeerClassname()."::doUpdate(\$this, \$con);
+ }
+ \$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ } // if \$this->isModified()
+
+ return \$affectedRows;
+ } // save()
";
- } // addSave()
+ } // addSave()
- /**
- * Adds the $validationFailures attribute to store ValidationFailed objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidationFailuresAttribute(&$script)
- {
- $script .= "
- /**
- * Array of ValidationFailed objects.
- * @var array ValidationFailed[]
- */
- protected \$validationFailures = array();
+ /**
+ * Adds the $validationFailures attribute to store ValidationFailed objects.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addValidationFailuresAttribute(&$script)
+ {
+ $script .= "
+ /**
+ * Array of ValidationFailed objects.
+ * @var array ValidationFailed[]
+ */
+ protected \$validationFailures = array();
";
- }
+ }
- /**
- * Adds the validate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidate(&$script)
- {
- $script .= "
- /**
- * Validates the objects modified field values.
- *
- * 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 ".$this->getPeerClassname()."::doValidate(\$this, \$columns);
- }
- return ".$this->getPeerClassname()."::doValidate(\$this);
- }
+ /**
+ * Adds the validate() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addValidate(&$script)
+ {
+ $script .= "
+ /**
+ * Validates the objects modified field values.
+ *
+ * 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 ".$this->getPeerClassname()."::doValidate(\$this, \$columns);
+ }
+ return ".$this->getPeerClassname()."::doValidate(\$this);
+ }
";
- } // addValidate()
+ } // addValidate()
- /**
- * Adds the getValidationFailures() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetValidationFailures(&$script)
- {
- $script .= "
- /**
- * Gets any ValidationFailed objects that resulted from last call to validate().
- *
- *
- * @return array ValidationFailed[]
- * @see validate()
- */
- public function getValidationFailures()
- {
- return \$this->validationFailures;
- }
+ /**
+ * Adds the getValidationFailures() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetValidationFailures(&$script)
+ {
+ $script .= "
+ /**
+ * Gets any ValidationFailed objects that resulted from last call to validate().
+ *
+ *
+ * @return array ValidationFailed[]
+ * @see validate()
+ */
+ public function getValidationFailures()
+ {
+ return \$this->validationFailures;
+ }
";
- } // addGetValidationFailures()
+ } // addGetValidationFailures()
- /**
- * Adds the correct getPrimaryKey() method for this object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetPrimaryKey(&$script)
- {
- $pkeys = $this->getTable()->getPrimaryKey();
- if (count($pkeys) == 1) {
- $this->addGetPrimaryKey_SinglePK($script);
- } elseif (count($pkeys) > 1) {
- $this->addGetPrimaryKey_MultiPK($script);
- } else {
- // no primary key -- this is deprecated, since we don't *need* this method anymore
- $this->addGetPrimaryKey_NoPK($script);
- }
- }
+ /**
+ * Adds the correct getPrimaryKey() method for this object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetPrimaryKey(&$script)
+ {
+ $pkeys = $this->getTable()->getPrimaryKey();
+ if (count($pkeys) == 1) {
+ $this->addGetPrimaryKey_SinglePK($script);
+ } elseif (count($pkeys) > 1) {
+ $this->addGetPrimaryKey_MultiPK($script);
+ } else {
+ // no primary key -- this is deprecated, since we don't *need* this method anymore
+ $this->addGetPrimaryKey_NoPK($script);
+ }
+ }
- /**
- * Adds the getPrimaryKey() method for tables that contain a single-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetPrimaryKey_SinglePK(&$script)
- {
- $table = $this->getTable();
- $pkeys = $table->getPrimaryKey();
- $cptype = $pkeys[0]->getPhpType();
+ /**
+ * Adds the getPrimaryKey() method for tables that contain a single-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetPrimaryKey_SinglePK(&$script)
+ {
+ $table = $this->getTable();
+ $pkeys = $table->getPrimaryKey();
+ $cptype = $pkeys[0]->getPhpType();
- $script .= "
- /**
- * Returns the primary key for this object (row).
- * @return $cptype
- */
- public function getPrimaryKey()
- {
- return \$this->get".$pkeys[0]->getPhpName()."();
- }
+ $script .= "
+ /**
+ * Returns the primary key for this object (row).
+ * @return $cptype
+ */
+ public function getPrimaryKey()
+ {
+ return \$this->get".$pkeys[0]->getPhpName()."();
+ }
";
- } // addetPrimaryKey_SingleFK
+ } // addetPrimaryKey_SingleFK
- /**
- * Adds the setPrimaryKey() method for tables that contain a multi-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetPrimaryKey_MultiPK(&$script)
- {
+ /**
+ * Adds the setPrimaryKey() method for tables that contain a multi-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetPrimaryKey_MultiPK(&$script)
+ {
- $script .= "
- /**
- * Returns the composite primary key for this object.
- * The array elements will be in same order as specified in XML.
- * @return array
- */
- public function getPrimaryKey()
- {
- \$pks = array();
+ $script .= "
+ /**
+ * Returns the composite primary key for this object.
+ * The array elements will be in same order as specified in XML.
+ * @return array
+ */
+ public function getPrimaryKey()
+ {
+ \$pks = array();
";
- $i = 0;
- foreach ($this->getTable()->getPrimaryKey() as $pk) {
- $script .= "
- \$pks[$i] = \$this->get".$pk->getPhpName()."();
+ $i = 0;
+ foreach ($this->getTable()->getPrimaryKey() as $pk) {
+ $script .= "
+ \$pks[$i] = \$this->get".$pk->getPhpName()."();
";
- $i++;
- } /* foreach */
- $script .= "
- return \$pks;
- }
+ $i++;
+ } /* foreach */
+ $script .= "
+ return \$pks;
+ }
";
- } // addGetPrimaryKey_MultiFK()
+ } // addGetPrimaryKey_MultiFK()
- /**
- * Adds the getPrimaryKey() method for objects that have no primary key.
- * This "feature" is dreprecated, since the getPrimaryKey() method is not required
- * by the Persistent interface (or used by the templates). Hence, this method is also
- * deprecated.
- * @param string &$script The script will be modified in this method.
- * @deprecated
- */
- protected function addGetPrimaryKey_NoPK(&$script)
- {
- $script .= "
- /**
- * Returns NULL since this table doesn't have a primary key.
- * This method exists only for BC and is deprecated!
- * @return null
- */
- public function getPrimaryKey()
- {
- return null;
- }
+ /**
+ * Adds the getPrimaryKey() method for objects that have no primary key.
+ * This "feature" is dreprecated, since the getPrimaryKey() method is not required
+ * by the Persistent interface (or used by the templates). Hence, this method is also
+ * deprecated.
+ * @param string &$script The script will be modified in this method.
+ * @deprecated
+ */
+ protected function addGetPrimaryKey_NoPK(&$script)
+ {
+ $script .= "
+ /**
+ * Returns NULL since this table doesn't have a primary key.
+ * This method exists only for BC and is deprecated!
+ * @return null
+ */
+ public function getPrimaryKey()
+ {
+ return null;
+ }
";
- }
- /**
- * Adds the correct setPrimaryKey() method for this object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addSetPrimaryKey(&$script)
- {
- $pkeys = $this->getTable()->getPrimaryKey();
- if (count($pkeys) == 1) {
- $this->addSetPrimaryKey_SinglePK($script);
- } elseif (count($pkeys) > 1) {
- $this->addSetPrimaryKey_MultiPK($script);
- } else {
- // no primary key -- this is deprecated, since we don't *need* this method anymore
- $this->addSetPrimaryKey_NoPK($script);
- }
- }
+ }
+ /**
+ * Adds the correct setPrimaryKey() method for this object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addSetPrimaryKey(&$script)
+ {
+ $pkeys = $this->getTable()->getPrimaryKey();
+ if (count($pkeys) == 1) {
+ $this->addSetPrimaryKey_SinglePK($script);
+ } elseif (count($pkeys) > 1) {
+ $this->addSetPrimaryKey_MultiPK($script);
+ } else {
+ // no primary key -- this is deprecated, since we don't *need* this method anymore
+ $this->addSetPrimaryKey_NoPK($script);
+ }
+ }
- /**
- * Adds the setPrimaryKey() method for tables that contain a single-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addSetPrimaryKey_SinglePK(&$script)
- {
+ /**
+ * Adds the setPrimaryKey() method for tables that contain a single-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addSetPrimaryKey_SinglePK(&$script)
+ {
- $pkeys = $this->getTable()->getPrimaryKey();
- $col = $pkeys[0];
- $clo=strtolower($col->getName());
- $ctype = $col->getPhpNative();
+ $pkeys = $this->getTable()->getPrimaryKey();
+ $col = $pkeys[0];
+ $clo=strtolower($col->getName());
+ $ctype = $col->getPhpNative();
- $script .= "
- /**
- * Generic method to set the primary key ($clo column).
- *
- * @param $ctype \$key Primary key.
- * @return void
- */
- public function setPrimaryKey(\$key)
- {
- \$this->set".$col->getPhpName()."(\$key);
- }
+ $script .= "
+ /**
+ * Generic method to set the primary key ($clo column).
+ *
+ * @param $ctype \$key Primary key.
+ * @return void
+ */
+ public function setPrimaryKey(\$key)
+ {
+ \$this->set".$col->getPhpName()."(\$key);
+ }
";
- } // addSetPrimaryKey_SinglePK
+ } // addSetPrimaryKey_SinglePK
- /**
- * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addSetPrimaryKey_MultiPK(&$script)
- {
+ /**
+ * Adds the setPrimaryKey() method for tables that contain a multi-columnprimary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addSetPrimaryKey_MultiPK(&$script)
+ {
- $script .="
- /**
- * Set the [composite] primary key.
- *
- * @param array \$keys The elements of the composite key (order must match the order in XML file).
- * @return void
- */
- public function setPrimaryKey(\$keys)
- {
+ $script .="
+ /**
+ * Set the [composite] primary key.
+ *
+ * @param array \$keys The elements of the composite key (order must match the order in XML file).
+ * @return void
+ */
+ public function setPrimaryKey(\$keys)
+ {
";
- $i = 0;
- foreach ($this->getTable()->getPrimaryKey() as $pk) {
- $pktype = $pk->getPhpNative();
- $script .= "
- \$this->set".$pk->getPhpName()."(\$keys[$i]);
+ $i = 0;
+ foreach ($this->getTable()->getPrimaryKey() as $pk) {
+ $pktype = $pk->getPhpNative();
+ $script .= "
+ \$this->set".$pk->getPhpName()."(\$keys[$i]);
";
- $i++;
- } /* foreach ($table->getPrimaryKey() */
- $script .= "
- }
+ $i++;
+ } /* foreach ($table->getPrimaryKey() */
+ $script .= "
+ }
";
- } // addSetPrimaryKey_MultiPK
+ } // addSetPrimaryKey_MultiPK
- /**
- * Adds the setPrimaryKey() method for objects that have no primary key.
- * This "feature" is dreprecated, since the setPrimaryKey() method is not required
- * by the Persistent interface (or used by the templates). Hence, this method is also
- * deprecated.
- * @param string &$script The script will be modified in this method.
- * @deprecated
- */
- protected function addSetPrimaryKey_NoPK(&$script)
- {
- $script .="
- /**
- * Dummy primary key setter.
- *
- * This function only exists to preserve backwards compatibility. It is no longer
- * needed or required by the Persistent interface. It will be removed in next BC-breaking
- * release of Propel.
- *
- * @deprecated
- */
- public function setPrimaryKey(\$pk)
- {
- // do nothing, because this object doesn't have any primary keys
- }
+ /**
+ * Adds the setPrimaryKey() method for objects that have no primary key.
+ * This "feature" is dreprecated, since the setPrimaryKey() method is not required
+ * by the Persistent interface (or used by the templates). Hence, this method is also
+ * deprecated.
+ * @param string &$script The script will be modified in this method.
+ * @deprecated
+ */
+ protected function addSetPrimaryKey_NoPK(&$script)
+ {
+ $script .="
+ /**
+ * Dummy primary key setter.
+ *
+ * This function only exists to preserve backwards compatibility. It is no longer
+ * needed or required by the Persistent interface. It will be removed in next BC-breaking
+ * release of Propel.
+ *
+ * @deprecated
+ */
+ public function setPrimaryKey(\$pk)
+ {
+ // do nothing, because this object doesn't have any primary keys
+ }
";
- }
+ }
- /**
- * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addCopy(&$script)
- {
- $this->addCopyInto($script);
+ /**
+ * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addCopy(&$script)
+ {
+ $this->addCopyInto($script);
- $table = $this->getTable();
+ $table = $this->getTable();
- $script .= "
- /**
- * 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.
- *
- * @return ".$table->getPhpName()." Clone of current object.
- * @throws PropelException
- */
- public function copy()
- {
- // we use get_class(), because this might be a subclass
- \$clazz = get_class(\$this);
- \$copyObj = new \$clazz();
- \$this->copyInto(\$copyObj);
- return \$copyObj;
- }
+ $script .= "
+ /**
+ * 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.
+ *
+ * @return ".$table->getPhpName()." Clone of current object.
+ * @throws PropelException
+ */
+ public function copy()
+ {
+ // we use get_class(), because this might be a subclass
+ \$clazz = get_class(\$this);
+ \$copyObj = new \$clazz();
+ \$this->copyInto(\$copyObj);
+ return \$copyObj;
+ }
";
- } // addCopy()
+ } // addCopy()
- /**
- * Adds the copy() method.
- */
- protected function addCopyInto(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the copy() method.
+ */
+ protected function addCopyInto(&$script)
+ {
+ $table = $this->getTable();
- $script .= "
- /**
- * Sets contents of passed object to values from current object.
- *
- * @param object \$copyObj An object of ".$table->getPhpName()." (or compatible) type.
- * @return ".$table->getPhpName()." Clone of current object.
- * @throws PropelException
- */
- public function copyInto(\$copyObj)
- {
+ $script .= "
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * @param object \$copyObj An object of ".$table->getPhpName()." (or compatible) type.
+ * @return ".$table->getPhpName()." Clone of current object.
+ * @throws PropelException
+ */
+ public function copyInto(\$copyObj)
+ {
";
- $pkcols = array();
- foreach ($table->getColumns() as $pkcol) {
- if ($pkcol->isPrimaryKey()) {
- $pkcols[] = $pkcol->getName();
- }
- }
+ $pkcols = array();
+ foreach ($table->getColumns() as $pkcol) {
+ if ($pkcol->isPrimaryKey()) {
+ $pkcols[] = $pkcol->getName();
+ }
+ }
- foreach ($table->getColumns() as $col) {
- if (!in_array($col->getName(), $pkcols)) {
- $script .= "
- \$copyObj->setgetPhpName()?>(\$this->getName()) ?>);";
- }
- } // foreach
+ foreach ($table->getColumns() as $col) {
+ if (!in_array($col->getName(), $pkcols)) {
+ $script .= "
+ \$copyObj->setgetPhpName()?>(\$this->getName()) ?>);";
+ }
+ } // foreach
- $script .= "
+ $script .= "
- \$copyObj->setNew(true);";
+ \$copyObj->setNew(true);";
- foreach ($table->getColumns() as $col) {
- if ($col->isPrimaryKey()) {
- $coldefval = $col->getPhpDefaultValue();
- $coldefval = var_export($coldefval, true);
- $script .= "
- \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a pkey column, so set to default value";
- } // if col->isPrimaryKey
- } // foreach
- $script .= "
- return \$copyObj;
- }
+ foreach ($table->getColumns() as $col) {
+ if ($col->isPrimaryKey()) {
+ $coldefval = $col->getPhpDefaultValue();
+ $coldefval = var_export($coldefval, true);
+ $script .= "
+ \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a pkey column, so set to default value";
+ } // if col->isPrimaryKey
+ } // foreach
+ $script .= "
+ return \$copyObj;
+ }
";
- } // addCopy()
+ } // addCopy()
} // PHP5BasicObjectBuilder
diff --git a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php
index 9f353be5e..fbf140dd8 100755
--- a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php
+++ b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php
@@ -36,1443 +36,1444 @@ require_once 'propel/engine/builder/om/PeerBuilder.php';
*/
class PHP5BasicPeerBuilder extends PeerBuilder {
- /**
- * Returns the name of the current class being built.
- * @return string
- */
- public function getClassname()
- {
- return $this->getBuildProperty('basePrefix') . $this->getStubPeerBuilder()->getClassname();
- }
+ /**
+ * Returns the name of the current class being built.
+ * @return string
+ */
+ public function getClassname()
+ {
+ return $this->getBuildProperty('basePrefix') . $this->getStubPeerBuilder()->getClassname();
+ }
- /**
- * Gets the package for the [base] peer classes.
- * @return string
- */
- public function getPackage()
- {
- return parent::getPackage() . ".om";
- }
+ /**
+ * Gets the package for the [base] peer classes.
+ * @return string
+ */
+ public function getPackage()
+ {
+ return parent::getPackage() . ".om";
+ }
- /**
- * Adds the include() statements for files that this class depends on or utilizes.
- * @param string &$script The script will be modified in this method.
- */
- protected function addIncludes(&$script) {
+ /**
+ * Adds the include() statements for files that this class depends on or utilizes.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addIncludes(&$script) {
- $table = $this->getTable();
+ $table = $this->getTable();
- $basePeerFile = $this->getFilePath($this->basePeerClass);
- $objectFile = $this->getStubObjectBuilder()->getClassFilePath();
+ $basePeerFile = $this->getFilePath($this->basePeerClass);
+ $objectFile = $this->getStubObjectBuilder()->getClassFilePath();
- $script .= "
+ $script .= "
require_once '$basePeerFile';
// The object class -- needed for instanceof checks in this class.
// actual class may be a subclass -- as returned by ".$this->getPeerClassname()."::getOMClass()
include_once '$objectFile';";
- $script .= "
+ $script .= "
";
- } // addIncludes()
+ } // addIncludes()
- /**
- * Adds class phpdoc comment and openning of class.
- * @param string &$script The script will be modified in this method.
- */
- protected function addClassOpen(&$script) {
+ /**
+ * Adds class phpdoc comment and openning of class.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addClassOpen(&$script) {
- $tableName = $this->getTable()->getName();
- $tableDesc = $this->getTable()->getDescription();
+ $tableName = $this->getTable()->getName();
+ $tableDesc = $this->getTable()->getDescription();
- $script .= "
+ $script .= "
/**
* Base static class for performing query and update operations on the '$tableName' table.
*
* $tableDesc
*";
- if ($this->getBuildProperty('addTimeStamp')) {
- $now = strftime('%c');
- $script .= "
+ if ($this->getBuildProperty('addTimeStamp')) {
+ $now = strftime('%c');
+ $script .= "
* This class was autogenerated by Propel on:
*
* $now
*";
- }
- $script .= "
+ }
+ $script .= "
* @package workflow.".$this->getPackage()."
*/
-abstract class ".$this->getClassname()." {
+abstract class ".$this->getClassname()."
+{
";
- }
+ }
+
+ /**
+ * Closes class.
+ * Adds closing brace at end of class and the static map builder registration code.
+ * @param string &$script The script will be modified in this method.
+ * @see addStaticMapBuilderRegistration()
+ */
+ protected function addClassClose(&$script)
+ {
+ $script .= "
+}
- /**
- * Closes class.
- * Adds closing brace at end of class and the static map builder registration code.
- * @param string &$script The script will be modified in this method.
- * @see addStaticMapBuilderRegistration()
- */
- protected function addClassClose(&$script)
- {
- $script .= "
-} // " . $this->getClassname() . "
";
- $this->addStaticMapBuilderRegistration($script);
- }
+ $this->addStaticMapBuilderRegistration($script);
+ }
- /**
- * Adds the static map builder registraction code.
- * @param string &$script The script will be modified in this method.
- */
- protected function addStaticMapBuilderRegistration(&$script)
- {
- $table = $this->getTable();
- $mapBuilderFile = $this->getMapBuilderBuilder()->getClassFilePath();
+ /**
+ * Adds the static map builder registraction code.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addStaticMapBuilderRegistration(&$script)
+ {
+ $table = $this->getTable();
+ $mapBuilderFile = $this->getMapBuilderBuilder()->getClassFilePath();
- $script .= "
+ $script .= "
// static code to register the map builder for this Peer with the main Propel class
if (Propel::isInit()) {
- // the MapBuilder classes register themselves with Propel during initialization
- // so we need to load them here.
- try {
- ".$this->getClassname()."::getMapBuilder();
- } catch (Exception \$e) {
- Propel::log('Could not initialize Peer: ' . \$e->getMessage(), Propel::LOG_ERR);
- }
+ // the MapBuilder classes register themselves with Propel during initialization
+ // so we need to load them here.
+ try {
+ ".$this->getClassname()."::getMapBuilder();
+ } catch (Exception \$e) {
+ Propel::log('Could not initialize Peer: ' . \$e->getMessage(), Propel::LOG_ERR);
+ }
} else {
- // even if Propel is not yet initialized, the map builder class can be registered
- // now and then it will be loaded when Propel initializes.
- require_once '$mapBuilderFile';
- Propel::registerMapBuilder('".$this->getMapBuilderBuilder()->getClasspath()."');
+ // 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 '$mapBuilderFile';
+ Propel::registerMapBuilder('".$this->getMapBuilderBuilder()->getClasspath()."');
}
-";
- }
-
- /**
- * Adds constant and variable declarations that go at the top of the class.
- * @param string &$script The script will be modified in this method.
- * @see addColumnNameConstants()
- */
- protected function addConstantsAndAttributes(&$script)
- {
- $tableName = $this->getTable()->getName();
- $dbName = $this->getDatabase()->getName();
- $script .= "
- /** the default database name for this class */
- const DATABASE_NAME = '$dbName';
-
- /** the table name for this class */
- const TABLE_NAME = '$tableName';
-
- /** A class that can be returned by this peer. */
- const CLASS_DEFAULT = '".$this->getStubObjectBuilder()->getClasspath()."';
-
- /** The total number of columns. */
- const NUM_COLUMNS = ".$this->getTable()->getNumColumns().";
-
- /** The number of lazy-loaded columns. */
- const NUM_LAZY_LOAD_COLUMNS = ".$this->getTable()->getNumLazyLoadColumns().";
";
- $this->addColumnNameConstants($script);
- $this->addInheritanceColumnConstants($script);
+ }
- $script .= "
- /** The PHP to DB Name Mapping */
- private static \$phpNameMap = null;
+ /**
+ * Adds constant and variable declarations that go at the top of the class.
+ * @param string &$script The script will be modified in this method.
+ * @see addColumnNameConstants()
+ */
+ protected function addConstantsAndAttributes(&$script)
+ {
+ $tableName = $this->getTable()->getName();
+ $dbName = $this->getDatabase()->getName();
+ $script .= "
+ /** the default database name for this class */
+ const DATABASE_NAME = '$dbName';
+
+ /** the table name for this class */
+ const TABLE_NAME = '$tableName';
+
+ /** A class that can be returned by this peer. */
+ const CLASS_DEFAULT = '".$this->getStubObjectBuilder()->getClasspath()."';
+
+ /** The total number of columns. */
+ const NUM_COLUMNS = ".$this->getTable()->getNumColumns().";
+
+ /** The number of lazy-loaded columns. */
+ const NUM_LAZY_LOAD_COLUMNS = ".$this->getTable()->getNumLazyLoadColumns().";
+
+";
+ $this->addColumnNameConstants($script);
+ $this->addInheritanceColumnConstants($script);
+
+ $script .= "
+ /** The PHP to DB Name Mapping */
+ private static \$phpNameMap = null;
";
- $this->addFieldNamesAttribute($script);
- $this->addFieldKeysAttribute($script);
+ $this->addFieldNamesAttribute($script);
+ $this->addFieldKeysAttribute($script);
- }
+ }
- /**
- * Adds the COLUMN_NAME contants to the class definition.
- * @param string &$script The script will be modified in this method.
- */
- protected function addColumnNameConstants(&$script)
- {
- foreach ($this->getTable()->getColumns() as $col) {
+ /**
+ * Adds the COLUMN_NAME contants to the class definition.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addColumnNameConstants(&$script)
+ {
+ foreach ($this->getTable()->getColumns() as $col) {
- $script .= "
- /** the column name for the ".strtoupper($col->getName()) ." field */
- const ".$this->getColumnName($col) ." = '".$this->getTable()->getName().".".strtoupper($col->getName())."';
+ $script .= "
+ /** the column name for the ".strtoupper($col->getName()) ." field */
+ const ".$this->getColumnName($col) ." = '".$this->getTable()->getName().".".strtoupper($col->getName())."';
";
- } // foreach
- }
+ } // foreach
+ }
- protected function addFieldNamesAttribute(&$script)
- {
- $table = $this->getTable();
+ protected function addFieldNamesAttribute(&$script)
+ {
+ $table = $this->getTable();
- $tableColumns = $table->getColumns();
- $tablePhpname = $table->getPhpName();
+ $tableColumns = $table->getColumns();
+ $tablePhpname = $table->getPhpName();
- $script .= "
- /**
- * holds an array of fieldnames
- *
- * first dimension keys are the type constants
- * e.g. self::\$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
- */
- private static \$fieldNames = array (
- BasePeer::TYPE_PHPNAME => array (";
- foreach ($tableColumns as $col) {
- $script .= "'".$col->getPhpName()."', ";
- }
- $script .= "),
- BasePeer::TYPE_COLNAME => array (";
- foreach ($tableColumns as $col) {
- $script .= $this->getColumnConstant($col).", ";
- }
- $script .= "),
- BasePeer::TYPE_FIELDNAME => array (";
- foreach ($tableColumns as $col) {
- $script .= "'".$col->getName()."', ";
- }
- $script .= "),
- BasePeer::TYPE_NUM => array (";
- foreach ($tableColumns as $num => $col) {
- $script .= "$num, ";
- }
- $script .= ")
- );
+ $script .= "
+ /**
+ * holds an array of fieldnames
+ *
+ * first dimension keys are the type constants
+ * e.g. self::\$fieldNames[self::TYPE_PHPNAME][0] = 'Id'
+ */
+ private static \$fieldNames = array (
+ BasePeer::TYPE_PHPNAME => array (";
+ foreach ($tableColumns as $col) {
+ $script .= "'".$col->getPhpName()."', ";
+ }
+ $script .= "),
+ BasePeer::TYPE_COLNAME => array (";
+ foreach ($tableColumns as $col) {
+ $script .= $this->getColumnConstant($col).", ";
+ }
+ $script .= "),
+ BasePeer::TYPE_FIELDNAME => array (";
+ foreach ($tableColumns as $col) {
+ $script .= "'".$col->getName()."', ";
+ }
+ $script .= "),
+ BasePeer::TYPE_NUM => array (";
+ foreach ($tableColumns as $num => $col) {
+ $script .= "$num, ";
+ }
+ $script .= ")
+ );
";
- }
+ }
- protected function addFieldKeysAttribute(&$script)
- {
- $table = $this->getTable();
+ protected function addFieldKeysAttribute(&$script)
+ {
+ $table = $this->getTable();
- $tableColumns = $table->getColumns();
- $tablePhpname = $table->getPhpName();
+ $tableColumns = $table->getColumns();
+ $tablePhpname = $table->getPhpName();
- $script .= "
- /**
- * holds an array of keys for quick access to the fieldnames array
- *
- * first dimension keys are the type constants
- * e.g. self::\$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
- */
- private static \$fieldKeys = array (
- BasePeer::TYPE_PHPNAME => array (";
- foreach ($tableColumns as $num => $col) {
- $script .= "'".$col->getPhpName()."' => $num, ";
- }
- $script .= "),
- BasePeer::TYPE_COLNAME => array (";
- foreach ($tableColumns as $num => $col) {
- $script .= $this->getColumnConstant($col)." => $num, ";
- }
- $script .= "),
- BasePeer::TYPE_FIELDNAME => array (";
- foreach ($tableColumns as $num => $col) {
- $script .= "'".$col->getName()."' => $num, ";
- }
- $script .= "),
- BasePeer::TYPE_NUM => array (";
- foreach ($tableColumns as $num => $col) {
- $script .= "$num, ";
- }
- $script .= ")
- );
+ $script .= "
+ /**
+ * holds an array of keys for quick access to the fieldnames array
+ *
+ * first dimension keys are the type constants
+ * e.g. self::\$fieldNames[BasePeer::TYPE_PHPNAME]['Id'] = 0
+ */
+ private static \$fieldKeys = array (
+ BasePeer::TYPE_PHPNAME => array (";
+ foreach ($tableColumns as $num => $col) {
+ $script .= "'".$col->getPhpName()."' => $num, ";
+ }
+ $script .= "),
+ BasePeer::TYPE_COLNAME => array (";
+ foreach ($tableColumns as $num => $col) {
+ $script .= $this->getColumnConstant($col)." => $num, ";
+ }
+ $script .= "),
+ BasePeer::TYPE_FIELDNAME => array (";
+ foreach ($tableColumns as $num => $col) {
+ $script .= "'".$col->getName()."' => $num, ";
+ }
+ $script .= "),
+ BasePeer::TYPE_NUM => array (";
+ foreach ($tableColumns as $num => $col) {
+ $script .= "$num, ";
+ }
+ $script .= ")
+ );
";
- } // addFielKeysAttribute
+ } // addFielKeysAttribute
- protected function addGetFieldNames(&$script)
- {
- $script .= "
- /**
- * Returns an array of of field names.
- *
- * @param string \$type The type of fieldnames to return:
- * One of the class type constants TYPE_PHPNAME,
- * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
- * @return array A list of field names
- */
+ protected function addGetFieldNames(&$script)
+ {
+ $script .= "
+ /**
+ * Returns an array of of field names.
+ *
+ * @param string \$type The type of fieldnames to return:
+ * One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @return array A list of field names
+ */
- static public function getFieldNames(\$type = BasePeer::TYPE_PHPNAME)
- {
- if (!array_key_exists(\$type, self::\$fieldNames)) {
- throw new PropelException('Method getFieldNames() expects the parameter \$type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . \$type . ' was given.');
- }
- return self::\$fieldNames[\$type];
- }
+ static public function getFieldNames(\$type = BasePeer::TYPE_PHPNAME)
+ {
+ if (!array_key_exists(\$type, self::\$fieldNames)) {
+ throw new PropelException('Method getFieldNames() expects the parameter \$type to be one of the class constants TYPE_PHPNAME, TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM. ' . \$type . ' was given.');
+ }
+ return self::\$fieldNames[\$type];
+ }
";
- } // addGetFieldNames()
+ } // addGetFieldNames()
- protected function addTranslateFieldName(&$script)
- {
- $script .= "
- /**
- * Translates a fieldname to another type
- *
- * @param string \$name field name
- * @param string \$fromType One of the class type constants TYPE_PHPNAME,
- * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
- * @param string \$toType One of the class type constants
- * @return string translated name of the field.
- */
- static public function translateFieldName(\$name, \$fromType, \$toType)
- {
- \$toNames = self::getFieldNames(\$toType);
- \$key = isset(self::\$fieldKeys[\$fromType][\$name]) ? self::\$fieldKeys[\$fromType][\$name] : null;
- if (\$key === null) {
- throw new PropelException(\"'\$name' could not be found in the field names of type '\$fromType'. These are: \" . print_r(self::\$fieldKeys[\$fromType], true));
- }
- return \$toNames[\$key];
- }
+ protected function addTranslateFieldName(&$script)
+ {
+ $script .= "
+ /**
+ * Translates a fieldname to another type
+ *
+ * @param string \$name field name
+ * @param string \$fromType One of the class type constants TYPE_PHPNAME,
+ * TYPE_COLNAME, TYPE_FIELDNAME, TYPE_NUM
+ * @param string \$toType One of the class type constants
+ * @return string translated name of the field.
+ */
+ static public function translateFieldName(\$name, \$fromType, \$toType)
+ {
+ \$toNames = self::getFieldNames(\$toType);
+ \$key = isset(self::\$fieldKeys[\$fromType][\$name]) ? self::\$fieldKeys[\$fromType][\$name] : null;
+ if (\$key === null) {
+ throw new PropelException(\"'\$name' could not be found in the field names of type '\$fromType'. These are: \" . print_r(self::\$fieldKeys[\$fromType], true));
+ }
+ return \$toNames[\$key];
+ }
";
- } // addTranslateFieldName()
+ } // addTranslateFieldName()
- /**
- * Adds the getMapBuilder() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetMapBuilder(&$script)
- {
- $script .= "
- /**
- * @return MapBuilder the map builder for this peer
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function getMapBuilder()
- {
- include_once '" . $this->getMapBuilderBuilder()->getClassFilePath()."';
- return ".$this->basePeerClassname."::getMapBuilder('". $this->getMapBuilderBuilder()->getClasspath() ."');
- }";
- }
+ /**
+ * Adds the getMapBuilder() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetMapBuilder(&$script)
+ {
+ $script .= "
+ /**
+ * @return MapBuilder the map builder for this peer
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getMapBuilder()
+ {
+ include_once '" . $this->getMapBuilderBuilder()->getClassFilePath()."';
+ return ".$this->basePeerClassname."::getMapBuilder('". $this->getMapBuilderBuilder()->getClasspath() ."');
+ }";
+ }
- /**
- * Adds the getPhpNameMap() method.
- * @param string &$script The script will be modified in this method.
- * @todo Replace with static version (this can be built at build-time).
- */
- protected function addGetPhpNameMap(&$script)
- {
- $script .= "
- /**
- * Gets a map (hash) of PHP names to DB column names.
- *
- * @return array The PHP to DB name map for this peer
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
- */
- public static function getPhpNameMap()
- {
- if (self::\$phpNameMap === null) {
- \$map = ".$this->getTable()->getPhpName()."Peer::getTableMap();
- \$columns = \$map->getColumns();
- \$nameMap = array();
- foreach (\$columns as \$column) {
- \$nameMap[\$column->getPhpName()] = \$column->getColumnName();
- }
- self::\$phpNameMap = \$nameMap;
- }
- return self::\$phpNameMap;
- }";
- }
+ /**
+ * Adds the getPhpNameMap() method.
+ * @param string &$script The script will be modified in this method.
+ * @todo Replace with static version (this can be built at build-time).
+ */
+ protected function addGetPhpNameMap(&$script)
+ {
+ $script .= "
+ /**
+ * Gets a map (hash) of PHP names to DB column names.
+ *
+ * @return array The PHP to DB name map for this peer
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @deprecated Use the getFieldNames() and translateFieldName() methods instead of this.
+ */
+ public static function getPhpNameMap()
+ {
+ if (self::\$phpNameMap === null) {
+ \$map = ".$this->getTable()->getPhpName()."Peer::getTableMap();
+ \$columns = \$map->getColumns();
+ \$nameMap = array();
+ foreach (\$columns as \$column) {
+ \$nameMap[\$column->getPhpName()] = \$column->getColumnName();
+ }
+ self::\$phpNameMap = \$nameMap;
+ }
+ return self::\$phpNameMap;
+ }";
+ }
- /**
- * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance.
- * @param string &$script The script will be modified in this method.
- */
- public function addInheritanceColumnConstants(&$script)
- {
- if ($this->getTable()->getChildrenColumn()) {
+ /**
+ * Adds the CLASSKEY_* and CLASSNAME_* constants used for inheritance.
+ * @param string &$script The script will be modified in this method.
+ */
+ public function addInheritanceColumnConstants(&$script)
+ {
+ if ($this->getTable()->getChildrenColumn()) {
- $col = $this->getTable()->getChildrenColumn();
- $tfc = $this->getTable()->getPhpName();
- $cfc = $col->getPhpName();
+ $col = $this->getTable()->getChildrenColumn();
+ $tfc = $this->getTable()->getPhpName();
+ $cfc = $col->getPhpName();
- if ($col->isEnumeratedClasses()) {
+ if ($col->isEnumeratedClasses()) {
- if ($col->isPrimitiveNumeric()) $quote = "";
- else $quote = '"';
+ if ($col->isPrimitiveNumeric()) $quote = "";
+ else $quote = '"';
- foreach ($col->getChildren() as $child) {
- $childBuilder = $this->getMultiExtendObjectBuilder();
- $childBuilder->setChild($child);
+ foreach ($col->getChildren() as $child) {
+ $childBuilder = $this->getMultiExtendObjectBuilder();
+ $childBuilder->setChild($child);
- $script .= "
- /** A key representing a particular subclass */
- const CLASSKEY_".strtoupper($child->getKey())." = '" . $child->getKey() . "';
+ $script .= "
+ /** A key representing a particular subclass */
+ const CLASSKEY_".strtoupper($child->getKey())." = '" . $child->getKey() . "';
";
-
- if (strtoupper($child->getClassname()) != strtoupper($child->getKey())) {
- $script .= "
- /** A key representing a particular subclass */
- const CLASSKEY_".strtoupper($child->getClassname())." = '" . $child->getKey() . "';
+
+ if (strtoupper($child->getClassname()) != strtoupper($child->getKey())) {
+ $script .= "
+ /** A key representing a particular subclass */
+ const CLASSKEY_".strtoupper($child->getClassname())." = '" . $child->getKey() . "';
";
- }
-
- $script .= "
- /** A class that can be returned by this peer. */
- const CLASSNAME_".strtoupper($child->getKey())." = '". $childBuilder->getClasspath() . "';
+ }
+
+ $script .= "
+ /** A class that can be returned by this peer. */
+ const CLASSNAME_".strtoupper($child->getKey())." = '". $childBuilder->getClasspath() . "';
";
- } /* foreach children */
- } /* if col->isenumerated...() */
- } /* if table->getchildrencolumn() */
+ } /* foreach children */
+ } /* if col->isenumerated...() */
+ } /* if table->getchildrencolumn() */
- } //
+ } //
- /**
- * Adds the alias() utility method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAlias(&$script)
- {
- $script .= "
- /**
- * 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. ".$this->getTable()->getPhpName()."Peer::COLUMN_NAME).
- * @return string
- */
- public static function alias(\$alias, \$column)
- {
- return str_replace(".$this->getPeerClassname()."::TABLE_NAME.'.', \$alias.'.', \$column);
- }
+ /**
+ * Adds the alias() utility method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addAlias(&$script)
+ {
+ $script .= "
+ /**
+ * 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. ".$this->getTable()->getPhpName()."Peer::COLUMN_NAME).
+ * @return string
+ */
+ public static function alias(\$alias, \$column)
+ {
+ return str_replace(".$this->getPeerClassname()."::TABLE_NAME.'.', \$alias.'.', \$column);
+ }
";
- } // addAliasMethod
+ } // addAliasMethod
- /**
- * Adds the addSelectColumns() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAddSelectColumns(&$script)
- {
- $script .= "
- /**
- * Add all the columns needed to create a new object.
- *
- * Note: any columns that were marked with lazyLoad=\"true\" in the
- * XML schema will not be added to the select list and only loaded
- * on demand.
- *
- * @param criteria object containing the columns to add.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function addSelectColumns(Criteria \$criteria)
- {
+ /**
+ * Adds the addSelectColumns() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addAddSelectColumns(&$script)
+ {
+ $script .= "
+ /**
+ * Add all the columns needed to create a new object.
+ *
+ * Note: any columns that were marked with lazyLoad=\"true\" in the
+ * XML schema will not be added to the select list and only loaded
+ * on demand.
+ *
+ * @param criteria object containing the columns to add.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function addSelectColumns(Criteria \$criteria)
+ {
";
- foreach ($this->getTable()->getColumns() as $col) {
- if (!$col->isLazyLoad()) {
- $script .= "
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::".$this->getColumnName($col).");
+ foreach ($this->getTable()->getColumns() as $col) {
+ if (!$col->isLazyLoad()) {
+ $script .= "
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::".$this->getColumnName($col).");
";
- } // if !col->isLazyLoad
- } // foreach
- $script .="
- }
+ } // if !col->isLazyLoad
+ } // foreach
+ $script .="
+ }
";
- } // addAddSelectColumns()
+ } // addAddSelectColumns()
- /**
- * Adds the COUNT constants.
- * @param string &$script The script will be modified in this method.
- */
- protected function addCountConstants(&$script)
- {
- $table = $this->getTable();
- $count_col = "*";
- /*
- * FIXME
- * (HL) wanted to remove this because AFAIK count(*) is generally
- * optimized in databases, and furthermore the code below isn't correct
- * (multi-pkey needs to be accounted for)....
- */
- if ($table->hasPrimaryKey()) {
- $pk = $table->getPrimaryKey();
- $count_col = $table->getName().".".strtoupper($pk[0]->getName());
- }
+ /**
+ * Adds the COUNT constants.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addCountConstants(&$script)
+ {
+ $table = $this->getTable();
+ $count_col = "*";
+ /*
+ * FIXME
+ * (HL) wanted to remove this because AFAIK count(*) is generally
+ * optimized in databases, and furthermore the code below isn't correct
+ * (multi-pkey needs to be accounted for)....
+ */
+ if ($table->hasPrimaryKey()) {
+ $pk = $table->getPrimaryKey();
+ $count_col = $table->getName().".".strtoupper($pk[0]->getName());
+ }
- $script .= "
- const COUNT = 'COUNT($count_col)';
- const COUNT_DISTINCT = 'COUNT(DISTINCT $count_col)';
+ $script .= "
+ const COUNT = 'COUNT($count_col)';
+ const COUNT_DISTINCT = 'COUNT(DISTINCT $count_col)';
";
- }
+ }
- /**
- * Adds the doCount() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoCount(&$script)
- {
- $script .= "
- /**
- * Returns the number of rows matching criteria.
- *
- * @param Criteria \$criteria
- * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
- * @param Connection \$con
- * @return int Number of matching rows.
- */
- public static function doCount(Criteria \$criteria, \$distinct = false, \$con = null)
- {
- // we're going to modify criteria, so copy it first
- \$criteria = clone \$criteria;
+ /**
+ * Adds the doCount() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoCount(&$script)
+ {
+ $script .= "
+ /**
+ * Returns the number of rows matching criteria.
+ *
+ * @param Criteria \$criteria
+ * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
+ * @param Connection \$con
+ * @return int Number of matching rows.
+ */
+ public static function doCount(Criteria \$criteria, \$distinct = false, \$con = null)
+ {
+ // we're going to modify criteria, so copy it first
+ \$criteria = clone \$criteria;
- // clear out anything that might confuse the ORDER BY clause
- \$criteria->clearSelectColumns()->clearOrderByColumns();
- if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
- } else {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
- }
+ // clear out anything that might confuse the ORDER BY clause
+ \$criteria->clearSelectColumns()->clearOrderByColumns();
+ if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
+ } else {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
+ }
- // just in case we're grouping: add those columns to the select statement
- foreach(\$criteria->getGroupByColumns() as \$column)
- {
- \$criteria->addSelectColumn(\$column);
- }
+ // just in case we're grouping: add those columns to the select statement
+ foreach (\$criteria->getGroupByColumns() as \$column) {
+ \$criteria->addSelectColumn(\$column);
+ }
- \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
- if (\$rs->next()) {
- return \$rs->getInt(1);
- } else {
- // no rows returned; we infer that means 0 matches.
- return 0;
- }
- }";
- }
+ \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
+ if (\$rs->next()) {
+ return \$rs->getInt(1);
+ } else {
+ // no rows returned; we infer that means 0 matches.
+ return 0;
+ }
+ }";
+ }
- /**
- * Adds the doSelectOne() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelectOne(&$script)
- {
- $script .= "
- /**
- * Method to select one object from the DB.
- *
- * @param Criteria \$criteria object used to create the SELECT statement.
- * @param Connection \$con
- * @return ".$this->getTable()->getPhpName()."
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectOne(Criteria \$criteria, \$con = null)
- {
- \$critcopy = clone \$criteria;
- \$critcopy->setLimit(1);
- \$objects = ".$this->getPeerClassname()."::doSelect(\$critcopy, \$con);
- if (\$objects) {
- return \$objects[0];
- }
- return null;
- }";
- }
+ /**
+ * Adds the doSelectOne() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelectOne(&$script)
+ {
+ $script .= "
+ /**
+ * Method to select one object from the DB.
+ *
+ * @param Criteria \$criteria object used to create the SELECT statement.
+ * @param Connection \$con
+ * @return ".$this->getTable()->getPhpName()."
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectOne(Criteria \$criteria, \$con = null)
+ {
+ \$critcopy = clone \$criteria;
+ \$critcopy->setLimit(1);
+ \$objects = ".$this->getPeerClassname()."::doSelect(\$critcopy, \$con);
+ if (\$objects) {
+ return \$objects[0];
+ }
+ return null;
+ }";
+ }
- /**
- * Adds the doSelect() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelect(&$script)
- {
- $script .= "
- /**
- * Method to do selects.
- *
- * @param Criteria \$criteria The Criteria object used to build the SELECT statement.
- * @param Connection \$con
- * @return array Array of selected Objects
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelect(Criteria \$criteria, \$con = null)
- {
- return ".$this->getPeerClassname()."::populateObjects(".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con));
- }";
- }
+ /**
+ * Adds the doSelect() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelect(&$script)
+ {
+ $script .= "
+ /**
+ * Method to do selects.
+ *
+ * @param Criteria \$criteria The Criteria object used to build the SELECT statement.
+ * @param Connection \$con
+ * @return array Array of selected Objects
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelect(Criteria \$criteria, \$con = null)
+ {
+ return ".$this->getPeerClassname()."::populateObjects(".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con));
+ }";
+ }
- /**
- * Adds the doSelectRS() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelectRS(&$script)
- {
+ /**
+ * Adds the doSelectRS() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelectRS(&$script)
+ {
- $script .= "
- /**
- * Prepares the Criteria object and uses the parent doSelect()
- * method to get a ResultSet.
- *
- * Use this method directly if you want to just get the resultset
- * (instead of an array of objects).
- *
- * @param Criteria \$criteria The Criteria object used to build the SELECT statement.
- * @param Connection \$con the connection to use
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- * @return ResultSet The resultset object with numerically-indexed fields.
- * @see ".$this->basePeerClassname."::doSelect()
- */
- public static function doSelectRS(Criteria \$criteria, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
+ $script .= "
+ /**
+ * Prepares the Criteria object and uses the parent doSelect()
+ * method to get a ResultSet.
+ *
+ * Use this method directly if you want to just get the resultset
+ * (instead of an array of objects).
+ *
+ * @param Criteria \$criteria The Criteria object used to build the SELECT statement.
+ * @param Connection \$con the connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ * @return ResultSet The resultset object with numerically-indexed fields.
+ * @see ".$this->basePeerClassname."::doSelect()
+ */
+ public static function doSelectRS(Criteria \$criteria, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
- if (!\$criteria->getSelectColumns()) {
- \$criteria = clone \$criteria;
- ".$this->getPeerClassname()."::addSelectColumns(\$criteria);
- }
+ if (!\$criteria->getSelectColumns()) {
+ \$criteria = clone \$criteria;
+ ".$this->getPeerClassname()."::addSelectColumns(\$criteria);
+ }
- // Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ // Set the correct dbName
+ \$criteria->setDbName(self::DATABASE_NAME);
- // BasePeer returns a Creole ResultSet, set to return
- // rows indexed numerically.
- return ".$this->basePeerClassname."::doSelect(\$criteria, \$con);
- }";
- }
+ // BasePeer returns a Creole ResultSet, set to return
+ // rows indexed numerically.
+ return ".$this->basePeerClassname."::doSelect(\$criteria, \$con);
+ }";
+ }
- /**
- * Adds the populateObjects() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addPopulateObjects(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * The returned array will contain objects of the default type or
- * objects that inherit from the default.
- *
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function populateObjects(ResultSet \$rs)
- {
- \$results = array();
- ";
- if (!$table->getChildrenColumn()) {
- $script .= "
- // set the class once to avoid overhead in the loop
- \$cls = ".$this->getPeerClassname()."::getOMClass();
- \$cls = Propel::import(\$cls);";
- }
-
- $script .= "
- // populate the object(s)
- while(\$rs->next()) {
- ";
- if ($table->getChildrenColumn()) {
- $script .= "
- // class must be set each time from the record row
- \$cls = Propel::import(".$this->getPeerClassname()."::getOMClass(\$rs, 1));
- \$obj = new \$cls();
- \$obj->hydrate(\$rs);
- \$results[] = \$obj;
- ";
- } else {
- $script .= "
- \$obj = new \$cls();
- \$obj->hydrate(\$rs);
- \$results[] = \$obj;
- ";
- }
- $script .= "
- }
- return \$results;
- }";
- }
-
- /**
- * Adds a getOMClass() for non-abstract tables that have inheritance.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetOMClass_Inheritance(&$script)
- {
- $col = $this->getTable()->getChildrenColumn();
- $script .= "
- /**
- * The returned Class will contain objects of the default type or
- * objects that inherit from the default.
- *
- * @param ResultSet \$rs ResultSet with pointer to record containing om class.
- * @param int \$colnum Column to examine for OM class information (first is 1).
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function getOMClass(ResultSet \$rs, \$colnum)
- {
- try {
+ /**
+ * Adds the populateObjects() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addPopulateObjects(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * The returned array will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function populateObjects(ResultSet \$rs)
+ {
+ \$results = array();
";
- if ($col->isEnumeratedClasses()) {
- $script .= "
- \$omClass = null;
- \$classKey = \$rs->getString(\$colnum - 1 + " . $col->getPosition() . ");
+ if (!$table->getChildrenColumn()) {
+ $script .= "
+ // set the class once to avoid overhead in the loop
+ \$cls = ".$this->getPeerClassname()."::getOMClass();
+ \$cls = Propel::import(\$cls);";
+ }
- switch(\$classKey) {
+ $script .= "
+ // populate the object(s)
+ while (\$rs->next()) {
";
- foreach ($col->getChildren() as $child) {
- $script .= "
- case self::CLASSKEY_".strtoupper($child->getKey()).":
- \$omClass = self::CLASSNAME_".strtoupper($child->getKey()).";
- break;
+ if ($table->getChildrenColumn()) {
+ $script .= "
+ // class must be set each time from the record row
+ \$cls = Propel::import(".$this->getPeerClassname()."::getOMClass(\$rs, 1));
+ \$obj = new \$cls();
+ \$obj->hydrate(\$rs);
+ \$results[] = \$obj;
";
- } /* foreach */
- $script .= "
- default:
- \$omClass = self::CLASS_DEFAULT;
+ } else {
+ $script .= "
+ \$obj = new \$cls();
+ \$obj->hydrate(\$rs);
+ \$results[] = \$obj;
";
- $script .= "
- } // switch
-";
- } else { /* if not enumerated */
- $script .= "
- \$omClass = Propel::import(\$rs->getString(\$colnum - 1 + ".$col->getPosition()."));
-";
- }
- $script .= "
- } catch (Exception \$e) {
- throw new PropelException('Unable to get OM class.', \$e);
- }
- return \$omClass;
- }
-";
- }
+ }
+ $script .= "
+ }
+ return \$results;
+ }";
+ }
- /**
- * Adds a getOMClass() signature for abstract tables that have inheritance.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetOMClass_Inheritance_Abstract(&$script)
- {
- $script .= "
- /**
- * The returned Class will contain objects of the default type or
- * objects that inherit from the default.
- *
- * This method must be overridden by the stub subclass, because
- * ".$this->getTable()->getPhpName()." is declared abstract in the schema.
- *
- * @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.
- */
- abstract public static function getOMClass();
+ /**
+ * Adds a getOMClass() for non-abstract tables that have inheritance.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetOMClass_Inheritance(&$script)
+ {
+ $col = $this->getTable()->getChildrenColumn();
+ $script .= "
+ /**
+ * The returned Class will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * @param ResultSet \$rs ResultSet with pointer to record containing om class.
+ * @param int \$colnum Column to examine for OM class information (first is 1).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function getOMClass(ResultSet \$rs, \$colnum)
+ {
+ try {
";
- }
+ if ($col->isEnumeratedClasses()) {
+ $script .= "
+ \$omClass = null;
+ \$classKey = \$rs->getString(\$colnum - 1 + " . $col->getPosition() . ");
- /**
- * Adds a getOMClass() for non-abstract tables that do note use inheritance.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetOMClass_NoInheritance(&$script)
- {
- $script .= "
- /**
- * The class that the Peer will make instances of.
- *
- * This uses a dot-path notation which is tranalted into a path
- * relative to a location on the PHP include_path.
- * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
- *
- * @return string path.to.ClassName
- */
- public static function getOMClass()
- {
- return ".$this->getPeerClassname()."::CLASS_DEFAULT;
- }
+ switch(\$classKey) {
";
- }
-
- /**
- * Adds a getOMClass() signature for abstract tables that do not have inheritance.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetOMClass_NoInheritance_Abstract(&$script)
- {
- $script .= "
- /**
- * The class that the Peer will make instances of.
- *
- * This method must be overridden by the stub subclass, because
- * ".$this->getTable()->getPhpName()." is declared abstract in the schema.
- */
- abstract public static function getOMClass();
+ foreach ($col->getChildren() as $child) {
+ $script .= "
+ case self::CLASSKEY_".strtoupper($child->getKey()).":
+ \$omClass = self::CLASSNAME_".strtoupper($child->getKey()).";
+ break;
";
- }
+ } /* foreach */
+ $script .= "
+ default:
+ \$omClass = self::CLASS_DEFAULT;
+";
+ $script .= "
+ } // switch
+";
+ } else { /* if not enumerated */
+ $script .= "
+ \$omClass = Propel::import(\$rs->getString(\$colnum - 1 + ".$col->getPosition()."));
+";
+ }
+ $script .= "
+ } catch (Exception \$e) {
+ throw new PropelException('Unable to get OM class.', \$e);
+ }
+ return \$omClass;
+ }
+";
+ }
- /**
- * Adds the doInsert() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoInsert(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Method perform an INSERT on the database, given a ".$table->getPhpName()." or Criteria object.
- *
- * @param mixed \$values Criteria or ".$table->getPhpName()." object containing data that is used to create the INSERT statement.
- * @param Connection \$con the connection to use
- * @return mixed The new primary key.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doInsert(\$values, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
+ /**
+ * Adds a getOMClass() signature for abstract tables that have inheritance.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetOMClass_Inheritance_Abstract(&$script)
+ {
+ $script .= "
+ /**
+ * The returned Class will contain objects of the default type or
+ * objects that inherit from the default.
+ *
+ * This method must be overridden by the stub subclass, because
+ * ".$this->getTable()->getPhpName()." is declared abstract in the schema.
+ *
+ * @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.
+ */
+ abstract public static function getOMClass();
+";
+ }
- if (\$values instanceof Criteria) {
- \$criteria = clone \$values; // rename for clarity
- } else {
- \$criteria = \$values->buildCriteria(); // build Criteria from ".$table->getPhpName()." object
- }
+ /**
+ * Adds a getOMClass() for non-abstract tables that do note use inheritance.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetOMClass_NoInheritance(&$script)
+ {
+ $script .= "
+ /**
+ * The class that the Peer will make instances of.
+ *
+ * This uses a dot-path notation which is tranalted into a path
+ * relative to a location on the PHP include_path.
+ * (e.g. path.to.MyClass -> 'path/to/MyClass.php')
+ *
+ * @return string path.to.ClassName
+ */
+ public static function getOMClass()
+ {
+ return ".$this->getPeerClassname()."::CLASS_DEFAULT;
+ }
+";
+ }
+
+ /**
+ * Adds a getOMClass() signature for abstract tables that do not have inheritance.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetOMClass_NoInheritance_Abstract(&$script)
+ {
+ $script .= "
+ /**
+ * The class that the Peer will make instances of.
+ *
+ * This method must be overridden by the stub subclass, because
+ * ".$this->getTable()->getPhpName()." is declared abstract in the schema.
+ */
+ abstract public static function getOMClass();
+";
+ }
+
+ /**
+ * Adds the doInsert() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoInsert(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Method perform an INSERT on the database, given a ".$table->getPhpName()." or Criteria object.
+ *
+ * @param mixed \$values Criteria or ".$table->getPhpName()." object containing data that is used to create the INSERT statement.
+ * @param Connection \$con the connection to use
+ * @return mixed The new primary key.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doInsert(\$values, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ if (\$values instanceof Criteria) {
+ \$criteria = clone \$values; // rename for clarity
+ } else {
+ \$criteria = \$values->buildCriteria(); // build Criteria from ".$table->getPhpName()." object
+ }
";
- foreach ($table->getColumns() as $col) {
- $cfc = $col->getPhpName();
- if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none") {
- $script .= "
- \$criteria->remove(".$this->getColumnConstant($col)."); // remove pkey col since this table uses auto-increment
+ foreach ($table->getColumns() as $col) {
+ $cfc = $col->getPhpName();
+ if ($col->isPrimaryKey() && $col->isAutoIncrement() && $table->getIdMethod() != "none") {
+ $script .= "
+ \$criteria->remove(".$this->getColumnConstant($col)."); // remove pkey col since this table uses auto-increment
";
- }
- }
- $script .= "
+ }
+ }
+ $script .= "
- // Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ // Set the correct dbName
+ \$criteria->setDbName(self::DATABASE_NAME);
- try {
- // use transaction because \$criteria could contain info
- // for more than one table (I guess, conceivably)
- \$con->begin();
- \$pk = ".$this->basePeerClassname."::doInsert(\$criteria, \$con);
- \$con->commit();
- } catch(PropelException \$e) {
- \$con->rollback();
- throw \$e;
- }
+ try {
+ // use transaction because \$criteria could contain info
+ // for more than one table (I guess, conceivably)
+ \$con->begin();
+ \$pk = ".$this->basePeerClassname."::doInsert(\$criteria, \$con);
+ \$con->commit();
+ } catch (PropelException \$e) {
+ \$con->rollback();
+ throw \$e;
+ }
- return \$pk;
- }
+ return \$pk;
+ }
";
- }
+ }
- /**
- * Adds the doUpdate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoUpdate(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Method perform an UPDATE on the database, given a ".$table->getPhpName()." or Criteria object.
- *
- * @param mixed \$values Criteria or ".$table->getPhpName()." object containing data that is used to create the UPDATE statement.
- * @param Connection \$con The connection to use (specify Connection object to exert more control over transactions).
- * @return int The number of affected rows (if supported by underlying database driver).
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doUpdate(\$values, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
+ /**
+ * Adds the doUpdate() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoUpdate(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Method perform an UPDATE on the database, given a ".$table->getPhpName()." or Criteria object.
+ *
+ * @param mixed \$values Criteria or ".$table->getPhpName()." object containing data create the UPDATE statement.
+ * @param Connection \$con The connection to use (specify Connection exert more control over transactions).
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doUpdate(\$values, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
- \$selectCriteria = new Criteria(self::DATABASE_NAME);
+ \$selectCriteria = new Criteria(self::DATABASE_NAME);
- if (\$values instanceof Criteria) {
- \$criteria = clone \$values; // rename for clarity
+ if (\$values instanceof Criteria) {
+ \$criteria = clone \$values; // rename for clarity
";
- foreach ($table->getColumns() as $col) {
- if($col->isPrimaryKey()) {
- $script .= "
- \$comparison = \$criteria->getComparison(".$this->getColumnConstant($col).");
- \$selectCriteria->add(".$this->getColumnConstant($col).", \$criteria->remove(".$this->getColumnConstant($col)."), \$comparison);
+ foreach ($table->getColumns() as $col) {
+ if($col->isPrimaryKey()) {
+ $script .= "
+ \$comparison = \$criteria->getComparison(".$this->getColumnConstant($col).");
+ \$selectCriteria->add(".$this->getColumnConstant($col).", \$criteria->remove(".$this->getColumnConstant($col)."), \$comparison);
";
- } /* if col is prim key */
- } /* foreach */
+ } /* if col is prim key */
+ } /* foreach */
- $script .= "
- } else { // \$values is ".$table->getPhpName()." object
- \$criteria = \$values->buildCriteria(); // gets full criteria
- \$selectCriteria = \$values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
- }
+ $script .= "
+ } else {
+ \$criteria = \$values->buildCriteria(); // gets full criteria
+ \$selectCriteria = \$values->buildPkeyCriteria(); // gets criteria w/ primary key(s)
+ }
- // set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ // set the correct dbName
+ \$criteria->setDbName(self::DATABASE_NAME);
- return {$this->basePeerClassname}::doUpdate(\$selectCriteria, \$criteria, \$con);
- }
+ return {$this->basePeerClassname}::doUpdate(\$selectCriteria, \$criteria, \$con);
+ }
";
- }
+ }
- /**
- * Adds the doDeleteAll() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoDeleteAll(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Method to DELETE all rows from the ".$table->getName()." table.
- *
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- public static function doDeleteAll(\$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
- \$affectedRows = 0; // initialize var to track total num of affected rows
- try {
- // use transaction because \$criteria could contain info
- // for more than one table or we could emulating ON DELETE CASCADE, etc.
- \$con->begin();
- ";
- if ($this->isDeleteCascadeEmulationNeeded()) {
- $script .="\$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(new Criteria(), \$con);
- ";
- }
- if ($this->isDeleteSetNullEmulationNeeded()) {
- $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(new Criteria(), \$con);
- ";
- }
- $script .= "\$affectedRows += BasePeer::doDeleteAll(".$this->getPeerClassname()."::TABLE_NAME, \$con);
- \$con->commit();
- return \$affectedRows;
- } catch (PropelException \$e) {
- \$con->rollback();
- throw \$e;
- }
- }
+ /**
+ * Adds the doDeleteAll() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoDeleteAll(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Method to DELETE all rows from the ".$table->getName()." table.
+ *
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ public static function doDeleteAll(\$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
+ \$affectedRows = 0; // initialize var to track total num of affected rows
+ try {
+ // use transaction because \$criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ \$con->begin();
+ ";
+ if ($this->isDeleteCascadeEmulationNeeded()) {
+ $script .="\$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(new Criteria(), \$con);
+ ";
+ }
+ if ($this->isDeleteSetNullEmulationNeeded()) {
+ $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(new Criteria(), \$con);
+ ";
+ }
+ $script .= "\$affectedRows += BasePeer::doDeleteAll(".$this->getPeerClassname()."::TABLE_NAME, \$con);
+ \$con->commit();
+ return \$affectedRows;
+ } catch (PropelException \$e) {
+ \$con->rollback();
+ throw \$e;
+ }
+ }
";
- }
+ }
- /**
- * Adds the doDelete() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoDelete(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Method perform a DELETE on the database, given a ".$table->getPhpName()." or Criteria object OR a primary key value.
- *
- * @param mixed \$values Criteria or ".$table->getPhpName()." object or primary key or array of primary keys
- * which is used to create the DELETE statement
- * @param Connection \$con the connection to use
- * @return int The number of affected rows (if supported by underlying database driver). This includes CASCADE-related rows
- * if supported by native driver or if emulated using Propel.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doDelete(\$values, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME);
- }
+ /**
+ * Adds the doDelete() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoDelete(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Method perform a DELETE on the database, given a ".$table->getPhpName()." or Criteria object OR a primary key value.
+ *
+ * @param mixed \$values Criteria or ".$table->getPhpName()." object or primary key or array of primary keys
+ * which is used to create the DELETE statement
+ * @param Connection \$con the connection to use
+ * @return int The number of affected rows (if supported by underlying database driver).
+ * This includes CASCADE-related rows
+ * if supported by native driver or if emulated using Propel.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doDelete(\$values, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME);
+ }
- if (\$values instanceof Criteria) {
- \$criteria = clone \$values; // rename for clarity
- } elseif (\$values instanceof ".$table->getPhpName().") {
+ if (\$values instanceof Criteria) {
+ \$criteria = clone \$values; // rename for clarity
+ } elseif (\$values instanceof ".$table->getPhpName().") {
";
- if (count($table->getPrimaryKey()) > 0) {
- $script .= "
- \$criteria = \$values->buildPkeyCriteria();";
- } else {
- $script .= "
- \$criteria = \$values->buildCriteria();";
- }
+ if (count($table->getPrimaryKey()) > 0) {
+ $script .= "
+ \$criteria = \$values->buildPkeyCriteria();";
+ } else {
+ $script .= "
+ \$criteria = \$values->buildCriteria();";
+ }
- $script .= "
- } else {
- // it must be the primary key
- \$criteria = new Criteria(self::DATABASE_NAME);";
+ $script .= "
+ } else {
+ // it must be the primary key
+ \$criteria = new Criteria(self::DATABASE_NAME);";
- if (count($table->getPrimaryKey()) === 1) {
- $pkey = $table->getPrimaryKey();
- $col = array_shift($pkey);
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", (array) \$values, Criteria::IN);";
- } else {
- $script .= "
- // primary key is composite; we therefore, expect
- // the primary key passed to be an array of pkey
- // values
- if(count(\$values) == count(\$values, COUNT_RECURSIVE))
- {
- // array is not multi-dimensional
- \$values = array(\$values);
- }
- \$vals = array();
- foreach(\$values as \$value)
- {
+ if (count($table->getPrimaryKey()) === 1) {
+ $pkey = $table->getPrimaryKey();
+ $col = array_shift($pkey);
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", (array) \$values, Criteria::IN);";
+ } else {
+ $script .= "
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey
+ // values
+ if (count(\$values) == count(\$values, COUNT_RECURSIVE)) {
+ // array is not multi-dimensional
+ \$values = array(\$values);
+ }
+ \$vals = array();
+ foreach (\$values as \$value) {
";
- $i=0;
- foreach($table->getPrimaryKey() as $col) {
- $script .= "
- \$vals[$i][] = \$value[$i];";
- $i++;
- }
- $script .= "
- }
+ $i=0;
+ foreach($table->getPrimaryKey() as $col) {
+ $script .= "
+ \$vals[$i][] = \$value[$i];";
+ $i++;
+ }
+ $script .= "
+ }
";
- $i=0;
- foreach($table->getPrimaryKey() as $col) {
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", \$vals[$i], Criteria::IN);";
- $i++;
- }
- } /* if count(table->getPrimaryKeys()) */
+ $i=0;
+ foreach($table->getPrimaryKey() as $col) {
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", \$vals[$i], Criteria::IN);";
+ $i++;
+ }
+ } /* if count(table->getPrimaryKeys()) */
- $script .= "
- }
+ $script .= "
+ }
- // Set the correct dbName
- \$criteria->setDbName(self::DATABASE_NAME);
+ // Set the correct dbName
+ \$criteria->setDbName(self::DATABASE_NAME);
- \$affectedRows = 0; // initialize var to track total num of affected rows
+ \$affectedRows = 0; // initialize var to track total num of affected rows
- try {
- // use transaction because \$criteria could contain info
- // for more than one table or we could emulating ON DELETE CASCADE, etc.
- \$con->begin();
- ";
-
- if ($this->isDeleteCascadeEmulationNeeded()) {
- $script .= "\$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(\$criteria, \$con);";
- }
- if ($this->isDeleteSetNullEmulationNeeded()) {
- $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(\$criteria, \$con);";
- }
-
- $script .= "
- \$affectedRows += {$this->basePeerClassname}::doDelete(\$criteria, \$con);
- \$con->commit();
- return \$affectedRows;
- } catch (PropelException \$e) {
- \$con->rollback();
- throw \$e;
- }
- }
-";
- }
-
- /**
- * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoOnDeleteCascade(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria \$criteria
- * @param Connection \$con
- * @return int The number of affected rows (if supported by underlying database driver).
- */
- protected static function doOnDeleteCascade(Criteria \$criteria, Connection \$con)
- {
- // initialize var to track total num of affected rows
- \$affectedRows = 0;
-
- // first find the objects that are implicated by the \$criteria
- \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
- foreach(\$objects as \$obj) {
+ try {
+ // use transaction because \$criteria could contain info
+ // for more than one table or we could emulating ON DELETE CASCADE, etc.
+ \$con->begin();
";
- foreach ($table->getReferrers() as $fk) {
+ if ($this->isDeleteCascadeEmulationNeeded()) {
+ $script .= "\$affectedRows += ".$this->getPeerClassname()."::doOnDeleteCascade(\$criteria, \$con);";
+ }
+ if ($this->isDeleteSetNullEmulationNeeded()) {
+ $script .= $this->getPeerClassname() . "::doOnDeleteSetNull(\$criteria, \$con);";
+ }
- // $fk is the foreign key in the other table, so localTableName will
- // actually be the table name of other table
- $tblFK = $fk->getTable();
-
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
- $tblFKPackage = $joinedTablePeerBuilder->getStubPeerBuilder()->getPackage();
-
- 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 && $tblFK->getName() != $table->getName()) {
-
- // backwards on purpose
- $columnNamesF = $fk->getLocalColumns();
- $columnNamesL = $fk->getForeignColumns();
-
- $script .= "
-
- include_once '".$this->getFilePath($tblFKPackage, $tblFK->getPhpName())."';
-
- // delete related $fkClassName objects
- \$c = new Criteria();
- ";
- for($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) {
- $columnFK = $tblFK->getColumn($columnNamesF[$x]);
- $columnL = $table->getColumn($columnNamesL[$x]);
-
- $script .= "
- \$c->add(".$joinedTablePeerBuilder->getColumnConstant($columnFK) .", \$obj->get".$columnL->getPhpName()."());";
- }
-
- $script .= "
- \$affectedRows += ".$joinedTablePeerBuilder->getPeerClassname()."::doDelete(\$c, \$con);";
-
- } // if cascade && fkey table name != curr table name
-
- } // if not for ref only
- } // foreach foreign keys
- $script .= "
- }
- return \$affectedRows;
- }
+ $script .= "
+ \$affectedRows += {$this->basePeerClassname}::doDelete(\$criteria, \$con);
+ \$con->commit();
+ return \$affectedRows;
+ } catch (PropelException \$e) {
+ \$con->rollback();
+ throw \$e;
+ }
+ }
";
- } // end addDoOnDeleteCascade
+ }
- /**
- * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoOnDeleteSetNull(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * This is a method for emulating ON DELETE SET NULL DBs that don't support this
- * feature (like MySQL or SQLite).
- *
- * This method is not very speedy because it must perform a query first to get
- * the implicated records and then perform the deletes by calling those Peer classes.
- *
- * This method should be used within a transaction if possible.
- *
- * @param Criteria \$criteria
- * @param Connection \$con
- * @return void
- */
- protected static function doOnDeleteSetNull(Criteria \$criteria, Connection \$con)
- {
+ /**
+ * Adds the doOnDeleteCascade() method, which provides ON DELETE CASCADE emulation.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoOnDeleteCascade(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * This is a method for emulating ON DELETE CASCADE for DBs that don't support this
+ * feature (like MySQL or SQLite).
+ *
+ * This method is not very speedy because it must perform a query first to get
+ * the implicated records and then perform the deletes by calling those Peer classes.
+ *
+ * This method should be used within a transaction if possible.
+ *
+ * @param Criteria \$criteria
+ * @param Connection \$con
+ * @return int The number of affected rows (if supported by underlying database driver).
+ */
+ protected static function doOnDeleteCascade(Criteria \$criteria, Connection \$con)
+ {
+ // initialize var to track total num of affected rows
+ \$affectedRows = 0;
- // first find the objects that are implicated by the \$criteria
- \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
- foreach(\$objects as \$obj) {
+ // first find the objects that are implicated by the \$criteria
+ \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
+ foreach(\$objects as \$obj) {
";
- // This logic is almost exactly the same as that in doOnDeleteCascade()
- // it may make sense to refactor this, provided that thigns don't
- // get too complicated.
+ foreach ($table->getReferrers() as $fk) {
- foreach ($table->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();
- // $fk is the foreign key in the other table, so localTableName will
- // actually be the table name of other table
- $tblFK = $fk->getTable();
- $refTablePeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
+ $tblFKPackage = $joinedTablePeerBuilder->getStubPeerBuilder()->getPackage();
- 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.)
+ 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();
+ $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()) {
+ // 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 && $tblFK->getName() != $table->getName()) {
- // backwards on purpose
- $columnNamesF = $fk->getLocalColumns();
- $columnNamesL = $fk->getForeignColumns(); // should be same num as foreign
- $script .= "
- // set fkey col in related $fkClassName rows to NULL
- \$selectCriteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);
- \$updateValues = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);";
+ // backwards on purpose
+ $columnNamesF = $fk->getLocalColumns();
+ $columnNamesL = $fk->getForeignColumns();
- for ($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) {
- $columnFK = $tblFK->getColumn($columnNamesF[$x]);
- $columnL = $table->getColumn($columnNamesL[$x]);
- $script .= "
- \$selectCriteria->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", \$obj->get".$columnL->getPhpName()."());
- \$updateValues->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", null);
+ $script .= "
+
+ include_once '".$this->getFilePath($tblFKPackage, $tblFK->getPhpName())."';
+
+ // delete related $fkClassName objects
+ \$c = new Criteria();
+ ";
+ for($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) {
+ $columnFK = $tblFK->getColumn($columnNamesF[$x]);
+ $columnL = $table->getColumn($columnNamesL[$x]);
+
+ $script .= "
+ \$c->add(".$joinedTablePeerBuilder->getColumnConstant($columnFK) .", \$obj->get".$columnL->getPhpName()."());";
+ }
+
+ $script .= "
+ \$affectedRows += ".$joinedTablePeerBuilder->getPeerClassname()."::doDelete(\$c, \$con);";
+
+ } // if cascade && fkey table name != curr table name
+
+ } // if not for ref only
+ } // foreach foreign keys
+ $script .= "
+ }
+ return \$affectedRows;
+ }
";
- }
+ } // end addDoOnDeleteCascade
- $script .= "
- {$this->basePeerClassname}::doUpdate(\$selectCriteria, \$updateValues, \$con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
-";
- } // if setnull && fkey table name != curr table name
- } // if not for ref only
- } // foreach foreign keys
+ /**
+ * Adds the doOnDeleteSetNull() method, which provides ON DELETE SET NULL emulation.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoOnDeleteSetNull(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * This is a method for emulating ON DELETE SET NULL DBs that don't support this
+ * feature (like MySQL or SQLite).
+ *
+ * This method is not very speedy because it must perform a query first to get
+ * the implicated records and then perform the deletes by calling those Peer classes.
+ *
+ * This method should be used within a transaction if possible.
+ *
+ * @param Criteria \$criteria
+ * @param Connection \$con
+ * @return void
+ */
+ protected static function doOnDeleteSetNull(Criteria \$criteria, Connection \$con)
+ {
- $script .= "
- }
- }
-";
- }
-
- /**
- * Adds the doValidate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoValidate(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Validates all modified columns of given ".$table->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 ".$table->getPhpName()." \$obj The object to validate.
- * @param mixed \$cols Column name or array of column names.
- *
- * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
- */
- public static function doValidate(".$table->getPhpName()." \$obj, \$cols = null)
- {
- \$columns = array();
-
- if (\$cols) {
- \$dbMap = Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME);
- \$tableMap = \$dbMap->getTable(".$this->getPeerClassname()."::TABLE_NAME);
-
- if (! is_array(\$cols)) {
- \$cols = array(\$cols);
- }
-
- foreach(\$cols as \$colName) {
- if (\$tableMap->containsColumn(\$colName)) {
- \$get = 'get' . \$tableMap->getColumn(\$colName)->getPhpName();
- \$columns[\$colName] = \$obj->\$get();
- }
- }
- } else {
-";
- foreach ($table->getValidators() as $val) {
- $col = $val->getColumn();
- if (!$col->isAutoIncrement()) {
- $script .= "
- if (\$obj->isNew() || \$obj->isColumnModified(".$this->getColumnConstant($col)."))
- \$columns[".$this->getColumnConstant($col)."] = \$obj->get".$col->getPhpName()."();
-";
- } // if
- } // foreach
-
- $script .= "
- }
-
- return {$this->basePeerClassname}::doValidate(".$this->getPeerClassname()."::DATABASE_NAME, ".$this->getPeerClassname()."::TABLE_NAME, \$columns);
- }
-";
- } // end addDoValidate()
-
- /**
- * Adds the retrieveByPK method for tables with single-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRetrieveByPK_SinglePK(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Retrieve a single object by pkey.
- *
- * @param mixed \$pk the primary key.
- * @param Connection \$con the connection to use
- * @return " . $table->getPhpName() . "
- */
- public static function ".$this->getRetrieveMethodName()."(\$pk, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
-
- \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);
-";
- if (count($table->getPrimaryKey()) === 1) {
- $pkey = $table->getPrimaryKey();
- $col = array_shift($pkey);
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", \$pk);
-";
- } else {
- // primary key is composite; we therefore, expect
- // the primary key passed to be an array of pkey
- // values
- $i=0;
- foreach($table->getPrimaryKey() as $col) {
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", \$pk[$i]);";
- $i++;
- }
- } /* if count(table.PrimaryKeys) */
- $script .= "
-
- \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
-
- return !empty(\$v) > 0 ? \$v[0] : null;
- }
-";
- }
-
- /**
- * Adds the retrieveByPKs method for tables with single-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRetrieveByPKs_SinglePK(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Retrieve multiple objects by pkey.
- *
- * @param array \$pks List of primary keys
- * @param Connection \$con the connection to use
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function ".$this->getRetrieveMethodName()."s(\$pks, \$con = null)
- {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
-
- \$objs = null;
- if (empty(\$pks)) {
- \$objs = array();
- } else {
- \$criteria = new Criteria();";
- if (count($table->getPrimaryKey()) == 1) {
- $k1 = $table->getPrimaryKey();
- $script .= "
- \$criteria->add(".$this->getColumnConstant($k1[0]).", \$pks, Criteria::IN);";
- } else {
- $script .= "
- foreach(\$pks as \$pk) {";
- $i = 0;
- foreach($table->getPrimaryKey() as $col) {
- $script .= "
- \$c{$i} = \$criteria->getNewCriterion(".$this->getPeerClassname($col).", \$pk[$i], Criteria::EQUAL);";
- $j = $i - 1;
- if ($i > 0) {
- $script .= "
- \$c{$j}->addAnd(\$c{$i});";
- } /* if $i > 0 */
- $i++;
- } /* foreach */
-
- $script .= "
-
- \$criteria->addOr(\$c0);
- }";
- } /* if count prim keys == 1 */
- $script .= "
- \$objs = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
- }
- return \$objs;
- }
-";
- }
-
- /**
- * Adds the retrieveByPK method for tables with multi-column primary key.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRetrieveByPK_MultiPK(&$script)
- {
- $table = $this->getTable();
- $script .= "
- /**
- * Retrieve object using using composite pkey values.
- * ";
- foreach ($table->getPrimaryKey() as $col) {
- $clo = strtolower($col->getName());
- $cptype = $col->getPhpNative();
- $script .= "@param $cptype $".$clo."
- ";
- }
- $script .= "
- * @param Connection \$con
- * @return ".$table->getPhpName()."
- */
- public static function ".$this->getRetrieveMethodName()."(";
- $co = 0;
- foreach ($table->getPrimaryKey() as $col) {
- $clo = strtolower($col->getName());
- $script .= ($co++ ? "," : "") . " $".$clo;
- } /* foreach */
- $script .= ", \$con = null) {
- if (\$con === null) {
- \$con = Propel::getConnection(self::DATABASE_NAME);
- }
- \$criteria = new Criteria();";
- foreach ($table->getPrimaryKey() as $col) {
- $clo = strtolower($col->getName());
- $script .= "
- \$criteria->add(".$this->getColumnConstant($col).", $".$clo.");";
- }
- $script .= "
- \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
-
- return !empty(\$v) ? \$v[0] : null;
- }";
- }
-
- /**
- * Adds the getTableMap() method which is a convenience method for apps to get DB metadata.
- * @param string &$script The script will be modified in this method.
- */
- protected function addGetTableMap(&$script)
- {
- $script .= "
- /**
- * 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.
- */
- public static function getTableMap()
- {
- return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
- }
+ // first find the objects that are implicated by the \$criteria
+ \$objects = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
+ foreach(\$objects as \$obj) {
";
- }
+ // This logic is almost exactly the same as that in doOnDeleteCascade()
+ // it may make sense to refactor this, provided that thigns don't
+ // get too complicated.
+
+ foreach ($table->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();
+ $refTablePeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
+
+ 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
+ $script .= "
+ // set fkey col in related $fkClassName rows to NULL
+ \$selectCriteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);
+ \$updateValues = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);";
+
+ for ($x=0,$xlen=count($columnNamesF); $x < $xlen; $x++) {
+ $columnFK = $tblFK->getColumn($columnNamesF[$x]);
+ $columnL = $table->getColumn($columnNamesL[$x]);
+ $script .= "
+ \$selectCriteria->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", \$obj->get".$columnL->getPhpName()."());
+ \$updateValues->add(".$refTablePeerBuilder->getColumnConstant($columnFK).", null);
+";
+ }
+
+ $script .= "
+ {$this->basePeerClassname}::doUpdate(\$selectCriteria, \$updateValues, \$con); // use BasePeer because generated Peer doUpdate() methods only update using pkey
+";
+ } // if setnull && fkey table name != curr table name
+ } // if not for ref only
+ } // foreach foreign keys
+
+ $script .= "
+ }
+ }
+";
+ }
+
+ /**
+ * Adds the doValidate() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoValidate(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Validates all modified columns of given ".$table->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 ".$table->getPhpName()." \$obj The object to validate.
+ * @param mixed \$cols Column name or array of column names.
+ *
+ * @return mixed TRUE if all columns are valid or the error message of the first invalid column.
+ */
+ public static function doValidate(".$table->getPhpName()." \$obj, \$cols = null)
+ {
+ \$columns = array();
+
+ if (\$cols) {
+ \$dbMap = Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME);
+ \$tableMap = \$dbMap->getTable(".$this->getPeerClassname()."::TABLE_NAME);
+
+ if (! is_array(\$cols)) {
+ \$cols = array(\$cols);
+ }
+
+ foreach (\$cols as \$colName) {
+ if (\$tableMap->containsColumn(\$colName)) {
+ \$get = 'get' . \$tableMap->getColumn(\$colName)->getPhpName();
+ \$columns[\$colName] = \$obj->\$get();
+ }
+ }
+ } else {
+";
+ foreach ($table->getValidators() as $val) {
+ $col = $val->getColumn();
+ if (!$col->isAutoIncrement()) {
+ $script .= "
+ if (\$obj->isNew() || \$obj->isColumnModified(".$this->getColumnConstant($col)."))
+ \$columns[".$this->getColumnConstant($col)."] = \$obj->get".$col->getPhpName()."();
+";
+ } // if
+ } // foreach
+
+ $script .= "
+ }
+
+ return {$this->basePeerClassname}::doValidate(".$this->getPeerClassname()."::DATABASE_NAME, ".$this->getPeerClassname()."::TABLE_NAME, \$columns);
+ }
+";
+ } // end addDoValidate()
+
+ /**
+ * Adds the retrieveByPK method for tables with single-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRetrieveByPK_SinglePK(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Retrieve a single object by pkey.
+ *
+ * @param mixed \$pk the primary key.
+ * @param Connection \$con the connection to use
+ * @return " . $table->getPhpName() . "
+ */
+ public static function ".$this->getRetrieveMethodName()."(\$pk, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ \$criteria = new Criteria(".$this->getPeerClassname()."::DATABASE_NAME);
+";
+ if (count($table->getPrimaryKey()) === 1) {
+ $pkey = $table->getPrimaryKey();
+ $col = array_shift($pkey);
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", \$pk);
+";
+ } else {
+ // primary key is composite; we therefore, expect
+ // the primary key passed to be an array of pkey
+ // values
+ $i=0;
+ foreach($table->getPrimaryKey() as $col) {
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", \$pk[$i]);";
+ $i++;
+ }
+ } /* if count(table.PrimaryKeys) */
+ $script .= "
+
+ \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
+
+ return !empty(\$v) > 0 ? \$v[0] : null;
+ }
+";
+ }
+
+ /**
+ * Adds the retrieveByPKs method for tables with single-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRetrieveByPKs_SinglePK(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Retrieve multiple objects by pkey.
+ *
+ * @param array \$pks List of primary keys
+ * @param Connection \$con the connection to use
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function ".$this->getRetrieveMethodName()."s(\$pks, \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
+
+ \$objs = null;
+ if (empty(\$pks)) {
+ \$objs = array();
+ } else {
+ \$criteria = new Criteria();";
+ if (count($table->getPrimaryKey()) == 1) {
+ $k1 = $table->getPrimaryKey();
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($k1[0]).", \$pks, Criteria::IN);";
+ } else {
+ $script .= "
+ foreach(\$pks as \$pk) {";
+ $i = 0;
+ foreach($table->getPrimaryKey() as $col) {
+ $script .= "
+ \$c{$i} = \$criteria->getNewCriterion(".$this->getPeerClassname($col).", \$pk[$i], Criteria::EQUAL);";
+ $j = $i - 1;
+ if ($i > 0) {
+ $script .= "
+ \$c{$j}->addAnd(\$c{$i});";
+ } /* if $i > 0 */
+ $i++;
+ } /* foreach */
+
+ $script .= "
+
+ \$criteria->addOr(\$c0);
+ }";
+ } /* if count prim keys == 1 */
+ $script .= "
+ \$objs = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
+ }
+ return \$objs;
+ }
+";
+ }
+
+ /**
+ * Adds the retrieveByPK method for tables with multi-column primary key.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRetrieveByPK_MultiPK(&$script)
+ {
+ $table = $this->getTable();
+ $script .= "
+ /**
+ * Retrieve object using using composite pkey values.
+ ";
+ foreach ($table->getPrimaryKey() as $col) {
+ $clo = strtolower($col->getName());
+ $cptype = $col->getPhpNative();
+ $script .= "* @param $cptype $".$clo."
+ ";
+ }
+ $script .= " * @param Connection \$con
+ * @return ".$table->getPhpName()."
+ */
+ public static function ".$this->getRetrieveMethodName()."(";
+ $co = 0;
+ foreach ($table->getPrimaryKey() as $col) {
+ $clo = strtolower($col->getName());
+ $script .= ($co++ ? ", " : "") . "$".$clo;
+ } /* foreach */
+ $script .= ", \$con = null)
+ {
+ if (\$con === null) {
+ \$con = Propel::getConnection(self::DATABASE_NAME);
+ }
+ \$criteria = new Criteria();";
+ foreach ($table->getPrimaryKey() as $col) {
+ $clo = strtolower($col->getName());
+ $script .= "
+ \$criteria->add(".$this->getColumnConstant($col).", $".$clo.");";
+ }
+ $script .= "
+ \$v = ".$this->getPeerClassname()."::doSelect(\$criteria, \$con);
+
+ return !empty(\$v) ? \$v[0] : null;
+ }";
+ }
+
+ /**
+ * Adds the getTableMap() method which is a convenience method for apps to get DB metadata.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addGetTableMap(&$script)
+ {
+ $script .= "
+ /**
+ * 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.
+ */
+ public static function getTableMap()
+ {
+ return Propel::getDatabaseMap(self::DATABASE_NAME)->getTable(self::TABLE_NAME);
+ }
+";
+
+ }
} // PHP5BasicPeerBuilder
diff --git a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php
index c66ec70f0..3235ede66 100755
--- a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php
+++ b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php
@@ -34,1240 +34,1241 @@ require_once 'propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php';
*/
class PHP5ComplexObjectBuilder extends PHP5BasicObjectBuilder {
- /**
- * Adds additional attributes used for complex object model.
- * @param string &$script The script will be modified in this method.
- * @see addFKAttributes()
- * @see addRefFKAttributes()
- * @see addAlreadyInSaveAttribute()
- * @see addAlreadyInValidationAttribute()
- */
- protected function addAttributes(&$script)
- {
- $table = $this->getTable();
- parent::addAttributes($script);
+ /**
+ * Adds additional attributes used for complex object model.
+ * @param string &$script The script will be modified in this method.
+ * @see addFKAttributes()
+ * @see addRefFKAttributes()
+ * @see addAlreadyInSaveAttribute()
+ * @see addAlreadyInValidationAttribute()
+ */
+ protected function addAttributes(&$script)
+ {
+ $table = $this->getTable();
+ parent::addAttributes($script);
- foreach ($table->getForeignKeys() as $fk) {
- $this->addFKAttributes($script, $fk);
- }
+ foreach ($table->getForeignKeys() as $fk) {
+ $this->addFKAttributes($script, $fk);
+ }
- foreach($table->getReferrers() as $refFK) {
- // if ($refFK->getTable()->getName() != $table->getName()) {
- $this->addRefFKAttributes($script, $refFK);
- // }
- }
+ foreach($table->getReferrers() as $refFK) {
+ // if ($refFK->getTable()->getName() != $table->getName()) {
+ $this->addRefFKAttributes($script, $refFK);
+ // }
+ }
- $this->addAlreadyInSaveAttribute($script);
- $this->addAlreadyInValidationAttribute($script);
- }
+ $this->addAlreadyInSaveAttribute($script);
+ $this->addAlreadyInValidationAttribute($script);
+ }
- /**
- * Specifies the methods that are added as part of the basic OM class.
- * This can be overridden by subclasses that wish to add more methods.
- * @param string &$script The script will be modified in this method.
- * @see PHP5BasicObjectBuilder::addClassBody()
- */
- protected function addClassBody(&$script)
- {
- $table = $this->getTable();
- parent::addClassBody($script);
+ /**
+ * Specifies the methods that are added as part of the basic OM class.
+ * This can be overridden by subclasses that wish to add more methods.
+ * @param string &$script The script will be modified in this method.
+ * @see PHP5BasicObjectBuilder::addClassBody()
+ */
+ protected function addClassBody(&$script)
+ {
+ $table = $this->getTable();
+ parent::addClassBody($script);
- $this->addFKMethods($script);
- $this->addRefFKMethods($script);
+ $this->addFKMethods($script);
+ $this->addRefFKMethods($script);
- }
+ }
- /**
- * Adds the close of mutator (setter) method for a column.
- * This method overrides the method from PHP5BasicObjectBuilder in order to
- * account for updating related objects.
- * @param string &$script The script will be modified in this method.
- * @param Column $col The current column.
- * @see PHP5BasicObjectBuilder::addMutatorClose()
- */
- protected function addMutatorClose(&$script, Column $col)
- {
- $table = $this->getTable();
- $cfc=$col->getPhpName();
- $clo=strtolower($col->getName());
+ /**
+ * Adds the close of mutator (setter) method for a column.
+ * This method overrides the method from PHP5BasicObjectBuilder in order to
+ * account for updating related objects.
+ * @param string &$script The script will be modified in this method.
+ * @param Column $col The current column.
+ * @see PHP5BasicObjectBuilder::addMutatorClose()
+ */
+ protected function addMutatorClose(&$script, Column $col)
+ {
+ $table = $this->getTable();
+ $cfc=$col->getPhpName();
+ $clo=strtolower($col->getName());
- if ($col->isForeignKey()) {
+ if ($col->isForeignKey()) {
- $tblFK = $table->getDatabase()->getTable($col->getRelatedTableName());
- $colFK = $tblFK->getColumn($col->getRelatedColumnName());
+ $tblFK = $table->getDatabase()->getTable($col->getRelatedTableName());
+ $colFK = $tblFK->getColumn($col->getRelatedColumnName());
- $varName = $this->getFKVarName($col->getForeignKey());
+ $varName = $this->getFKVarName($col->getForeignKey());
- $script .= "
- if (\$this->$varName !== null && \$this->".$varName."->get".$colFK->getPhpName()."() !== \$v) {
- \$this->$varName = null;
- }
+ $script .= "
+ if (\$this->$varName !== null && \$this->".$varName."->get".$colFK->getPhpName()."() !== \$v) {
+ \$this->$varName = null;
+ }
";
- } /* if col is foreign key */
+ } /* if col is foreign key */
- foreach ($col->getReferrers() as $fk) {
+ foreach ($col->getReferrers() as $fk) {
- $tblFK = $this->getDatabase()->getTable($fk->getForeignTableName());
+ $tblFK = $this->getDatabase()->getTable($fk->getForeignTableName());
- if ( $tblFK->getName() != $table->getName() ) {
+ if ( $tblFK->getName() != $table->getName() ) {
- $collName = $this->getRefFKCollVarName($fk);
+ $collName = $this->getRefFKCollVarName($fk);
- $tblFK = $table->getDatabase()->getTable($col->getRelatedTableName());
- $colFK = $tblFK->getColumn($col->getRelatedColumnName());
+ $tblFK = $table->getDatabase()->getTable($col->getRelatedTableName());
+ $colFK = $tblFK->getColumn($col->getRelatedColumnName());
- $script .= "
+ $script .= "
- // update associated ".$tblFK->getPhpName()."
- if (\$this->$collName !== null) {
- foreach(\$this->$collName as \$referrerObject) {
- \$referrerObject->set".$colFK->getPhpName()."(\$v);
- }
- }
+ // update associated ".$tblFK->getPhpName()."
+ if (\$this->$collName !== null) {
+ foreach(\$this->$collName as \$referrerObject) {
+ \$referrerObject->set".$colFK->getPhpName()."(\$v);
+ }
+ }
";
- } // if
- } // foreach
+ } // if
+ } // foreach
- $script .= "
- } // set$cfc()
+ $script .= "
+ } // set$cfc()
";
- } // addMutatorClose()
+ } // addMutatorClose()
- /**
- * Adds the methods related to validating, saving and deleting the object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addManipulationMethods(&$script)
- {
- $this->addDelete($script);
- $this->addSave($script);
- $this->addDoSave($script);
- }
+ /**
+ * Adds the methods related to validating, saving and deleting the object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addManipulationMethods(&$script)
+ {
+ $this->addDelete($script);
+ $this->addSave($script);
+ $this->addDoSave($script);
+ }
- /**
- * Adds the methods related to validationg the object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidationMethods(&$script)
- {
- parent::addValidationMethods($script);
- $this->addDoValidate($script);
- }
+ /**
+ * Adds the methods related to validationg the object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addValidationMethods(&$script)
+ {
+ parent::addValidationMethods($script);
+ $this->addDoValidate($script);
+ }
- /**
- * Convenience method to get the foreign Table object for an fkey.
- * @return Table
- */
- protected function getForeignTable(ForeignKey $fk)
- {
- return $this->getTable()->getDatabase()->getTable($fk->getForeignTableName());
- }
+ /**
+ * Convenience method to get the foreign Table object for an fkey.
+ * @return Table
+ */
+ protected function getForeignTable(ForeignKey $fk)
+ {
+ return $this->getTable()->getDatabase()->getTable($fk->getForeignTableName());
+ }
- /**
- * Gets the PHP method name affix to be used for fkeys for the current table (not referrers to this table).
- *
- * The difference between this method and the getRefFKPhpNameAffix() method is that in this method the
- * classname in the affix is the foreign table classname.
- *
- * @param ForeignKey $fk The local FK that we need a name for.
- * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj()
- * @return string
- */
- public function getFKPhpNameAffix(ForeignKey $fk, $plural = false)
- {
- $className = $this->getForeignTable($fk)->getPhpName();
- return $className . ($plural ? 's' : '') . $this->getRelatedBySuffix($fk);
- }
+ /**
+ * Gets the PHP method name affix to be used for fkeys for the current table (not referrers to this table).
+ *
+ * The difference between this method and the getRefFKPhpNameAffix() method is that in this method the
+ * classname in the affix is the foreign table classname.
+ *
+ * @param ForeignKey $fk The local FK that we need a name for.
+ * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj()
+ * @return string
+ */
+ public function getFKPhpNameAffix(ForeignKey $fk, $plural = false)
+ {
+ $className = $this->getForeignTable($fk)->getPhpName();
+ return $className . ($plural ? 's' : '') . $this->getRelatedBySuffix($fk);
+ }
- /**
- * Gets the PHP method name affix to be used for referencing foreign key methods and variable names (e.g. set????(), $coll???).
- *
- * The difference between this method and the getFKPhpNameAffix() method is that in this method the
- * classname in the affix is the classname of the local fkey table.
- *
- * @param ForeignKey $fk The referrer FK that we need a name for.
- * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj()
- * @return string
- */
- public function getRefFKPhpNameAffix(ForeignKey $fk, $plural = false)
- {
- $className = $fk->getTable()->getPhpName();
- return $className . ($plural ? 's' : '') . $this->getRelatedBySuffix($fk);
- }
+ /**
+ * Gets the PHP method name affix to be used for referencing foreign key methods and variable names (e.g. set????(), $coll???).
+ *
+ * The difference between this method and the getFKPhpNameAffix() method is that in this method the
+ * classname in the affix is the classname of the local fkey table.
+ *
+ * @param ForeignKey $fk The referrer FK that we need a name for.
+ * @param boolean $plural Whether the php name should be plural (e.g. initRelatedObjs() vs. addRelatedObj()
+ * @return string
+ */
+ public function getRefFKPhpNameAffix(ForeignKey $fk, $plural = false)
+ {
+ $className = $fk->getTable()->getPhpName();
+ return $className . ($plural ? 's' : '') . $this->getRelatedBySuffix($fk);
+ }
- /**
- * Gets the "RelatedBy*" suffix (if needed) that is attached to method and variable names.
- *
- * The related by suffix is based on the local columns of the foreign key. If there is more than
- * one column in a table that points to the same foreign table, then a 'RelatedByLocalColName' suffix
- * will be appended.
- *
- * @return string
- */
- protected function getRelatedBySuffix(ForeignKey $fk)
- {
- $relCol = "";
- foreach ($fk->getLocalColumns() as $columnName) {
- $column = $fk->getTable()->getColumn($columnName);
- if (!$column) {
- $e = new Exception("Could not fetch column: $columnName in table " . $fk->getTable()->getName());
- print $e;
- throw $e;
- }
- if ($column->isMultipleFK() || $fk->getForeignTableName() == $fk->getTable()->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.
- $relCol .= $column->getPhpName();
- }
- }
+ /**
+ * Gets the "RelatedBy*" suffix (if needed) that is attached to method and variable names.
+ *
+ * The related by suffix is based on the local columns of the foreign key. If there is more than
+ * one column in a table that points to the same foreign table, then a 'RelatedByLocalColName' suffix
+ * will be appended.
+ *
+ * @return string
+ */
+ protected function getRelatedBySuffix(ForeignKey $fk)
+ {
+ $relCol = "";
+ foreach ($fk->getLocalColumns() as $columnName) {
+ $column = $fk->getTable()->getColumn($columnName);
+ if (!$column) {
+ $e = new Exception("Could not fetch column: $columnName in table " . $fk->getTable()->getName());
+ print $e;
+ throw $e;
+ }
+ if ($column->isMultipleFK() || $fk->getForeignTableName() == $fk->getTable()->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.
+ $relCol .= $column->getPhpName();
+ }
+ }
- if ($relCol != "") {
- $relCol = "RelatedBy" . $relCol;
- }
+ if ($relCol != "") {
+ $relCol = "RelatedBy" . $relCol;
+ }
- return $relCol;
- }
+ return $relCol;
+ }
- protected function getFKVarName(ForeignKey $fk)
- {
- return 'a' . $this->getFKPhpNameAffix($fk, $plural = false);
- }
+ protected function getFKVarName(ForeignKey $fk)
+ {
+ return 'a' . $this->getFKPhpNameAffix($fk, $plural = false);
+ }
- protected function getRefFKCollVarName(ForeignKey $fk)
- {
- return 'coll' . $this->getRefFKPhpNameAffix($fk, $plural = true);
- }
+ protected function getRefFKCollVarName(ForeignKey $fk)
+ {
+ return 'coll' . $this->getRefFKPhpNameAffix($fk, $plural = true);
+ }
- protected function getRefFKLastCriteriaVarName(ForeignKey $fk)
- {
- return 'last' . $this->getRefFKPhpNameAffix($fk, $plural = false) . 'Criteria';
- }
+ protected function getRefFKLastCriteriaVarName(ForeignKey $fk)
+ {
+ return 'last' . $this->getRefFKPhpNameAffix($fk, $plural = false) . 'Criteria';
+ }
- // ----------------------------------------------------------------
- //
- // F K M E T H O D S
- //
- // ----------------------------------------------------------------
+ // ----------------------------------------------------------------
+ //
+ // F K M E T H O D S
+ //
+ // ----------------------------------------------------------------
- /**
- * Adds the methods that get & set objects related by foreign key to the current object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addFKMethods(&$script)
- {
- foreach ($this->getTable()->getForeignKeys() as $fk) {
- $this->addFKMutator($script, $fk);
- $this->addFKAccessor($script, $fk);
- } // foreach fk
- }
+ /**
+ * Adds the methods that get & set objects related by foreign key to the current object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addFKMethods(&$script)
+ {
+ foreach ($this->getTable()->getForeignKeys() as $fk) {
+ $this->addFKMutator($script, $fk);
+ $this->addFKAccessor($script, $fk);
+ } // foreach fk
+ }
- /**
- * Adds the class attributes that are needed to store fkey related objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addFKAttributes(&$script, ForeignKey $fk)
- {
- $className = $this->getForeignTable($fk)->getPhpName();
- $varName = $this->getFKVarName($fk);
+ /**
+ * Adds the class attributes that are needed to store fkey related objects.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addFKAttributes(&$script, ForeignKey $fk)
+ {
+ $className = $this->getForeignTable($fk)->getPhpName();
+ $varName = $this->getFKVarName($fk);
- $script .= "
- /**
- * @var $className
- */
- protected $".$varName.";
+ $script .= "
+ /**
+ * @var $className
+ */
+ protected $".$varName.";
";
- }
+ }
- /**
- * Adds the mutator (setter) method for setting an fkey related object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addFKMutator(&$script, ForeignKey $fk)
- {
- $table = $this->getTable();
- $tblFK = $this->getForeignTable($fk);
- $className = $this->getForeignTable($fk)->getPhpName();
- $varName = $this->getFKVarName($fk);
+ /**
+ * Adds the mutator (setter) method for setting an fkey related object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addFKMutator(&$script, ForeignKey $fk)
+ {
+ $table = $this->getTable();
+ $tblFK = $this->getForeignTable($fk);
+ $className = $this->getForeignTable($fk)->getPhpName();
+ $varName = $this->getFKVarName($fk);
- $script .= "
- /**
- * Declares an association between this object and a $className object.
- *
- * @param $className \$v
- * @return void
- * @throws PropelException
- */
- public function set".$this->getFKPhpNameAffix($fk, $plural = false)."(\$v)
- {
+ $script .= "
+ /**
+ * Declares an association between this object and a $className object.
+ *
+ * @param $className \$v
+ * @return void
+ * @throws PropelException
+ */
+ public function set".$this->getFKPhpNameAffix($fk, $plural = false)."(\$v)
+ {
";
- foreach ($fk->getLocalColumns() as $columnName) {
- $column = $table->getColumn($columnName);
- $lfmap = $fk->getLocalForeignMapping();
- $colFKName = $lfmap[$columnName];
- $colFK = $tblFK->getColumn($colFKName);
- $script .= "
+ foreach ($fk->getLocalColumns() as $columnName) {
+ $column = $table->getColumn($columnName);
+ $lfmap = $fk->getLocalForeignMapping();
+ $colFKName = $lfmap[$columnName];
+ $colFK = $tblFK->getColumn($colFKName);
+ $script .= "
- if (\$v === null) {
- \$this->set".$column->getPhpName()."(".var_export($column->getDefaultValue(), true).");
- } else {
- \$this->set".$column->getPhpName()."(\$v->get".$colFK->getPhpName()."());
- }
+ if (\$v === null) {
+ \$this->set".$column->getPhpName()."(".var_export($column->getDefaultValue(), true).");
+ } else {
+ \$this->set".$column->getPhpName()."(\$v->get".$colFK->getPhpName()."());
+ }
";
- } /* foreach local col */
+ } /* foreach local col */
- $script .= "
+ $script .= "
- \$this->$varName = \$v;
- }
+ \$this->$varName = \$v;
+ }
";
- }
+ }
- /**
- * Adds the accessor (getter) method for getting an fkey related object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addFKAccessor(&$script, ForeignKey $fk)
- {
- $table = $this->getTable();
+ /**
+ * Adds the accessor (getter) method for getting an fkey related object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addFKAccessor(&$script, ForeignKey $fk)
+ {
+ $table = $this->getTable();
- $className = $this->getForeignTable($fk)->getPhpName();
- $varName = $this->getFKVarName($fk);
+ $className = $this->getForeignTable($fk)->getPhpName();
+ $varName = $this->getFKVarName($fk);
- $and = "";
- $comma = "";
- $conditional = "";
- $arglist = "";
- $argsize = 0;
- foreach ($fk->getLocalColumns() as $columnName) {
- $column = $table->getColumn($columnName);
- $cptype = $column->getPhpNative();
- $clo = strtolower($column->getName());
+ $and = "";
+ $comma = "";
+ $conditional = "";
+ $arglist = "";
+ $argsize = 0;
+ foreach ($fk->getLocalColumns() as $columnName) {
+ $column = $table->getColumn($columnName);
+ $cptype = $column->getPhpNative();
+ $clo = strtolower($column->getName());
- // FIXME: is this correct? what about negative numbers?
- 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;
- }
+ // FIXME: is this correct? what about negative numbers?
+ 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 = $this->getFKPhpNameAffix($fk, $plural = true);
+ $pCollName = $this->getFKPhpNameAffix($fk, $plural = true);
- $fkPeerBuilder = OMBuilder::getNewPeerBuilder($this->getForeignTable($fk));
+ $fkPeerBuilder = OMBuilder::getNewPeerBuilder($this->getForeignTable($fk));
- $script .= "
+ $script .= "
- /**
- * Get the associated $className object
- *
- * @param Connection Optional Connection object.
- * @return $className The associated $className object.
- * @throws PropelException
- */
- public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(\$con = null)
- {
- // include the related Peer class
- include_once '".$fkPeerBuilder->getClassFilePath()."';
+ /**
+ * Get the associated $className object
+ *
+ * @param Connection Optional Connection object.
+ * @return $className The associated $className object.
+ * @throws PropelException
+ */
+ public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(\$con = null)
+ {
+ // include the related Peer class
+ include_once '".$fkPeerBuilder->getClassFilePath()."';
- if (\$this->$varName === null && ($conditional)) {
+ if (\$this->$varName === null && ($conditional)) {
";
- $script .= "
- \$this->$varName = ".$fkPeerBuilder->getPeerClassname()."::".$fkPeerBuilder->getRetrieveMethodName()."($arglist, \$con);
+ $script .= "
+ \$this->$varName = ".$fkPeerBuilder->getPeerClassname()."::".$fkPeerBuilder->getRetrieveMethodName()."($arglist, \$con);
- /* 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 = ".$fkPeerBuilder->getPeerClassname()."::retrieveByPK($arglist, \$con);
- \$obj->add$pCollName(\$this);
- */
- }
- return \$this->$varName;
- }
+ /* 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 = ".$fkPeerBuilder->getPeerClassname()."::retrieveByPK($arglist, \$con);
+ \$obj->add$pCollName(\$this);
+ */
+ }
+ return \$this->$varName;
+ }
";
- } // addFKAccessor
+ } // addFKAccessor
- /**
- * Adds a convenience method for setting a related object by specifying the primary key.
- * This can be used in conjunction with the getPrimaryKey() for systems where nothing is known
- * about the actual objects being related.
- * @param string &$script The script will be modified in this method.
- */
- protected function addFKByKeyMutator(&$script, ForeignKey $fk)
- {
- $table = $this->getTable();
+ /**
+ * Adds a convenience method for setting a related object by specifying the primary key.
+ * This can be used in conjunction with the getPrimaryKey() for systems where nothing is known
+ * about the actual objects being related.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addFKByKeyMutator(&$script, ForeignKey $fk)
+ {
+ $table = $this->getTable();
- #$className = $this->getForeignTable($fk)->getPhpName();
- $methodAffix = $this->getFKPhpNameAffix($fk);
- #$varName = $this->getFKVarName($fk);
+ #$className = $this->getForeignTable($fk)->getPhpName();
+ $methodAffix = $this->getFKPhpNameAffix($fk);
+ #$varName = $this->getFKVarName($fk);
- $script .= "
- /**
- * Provides convenient way to set a relationship based on a
- * key. e.g.
- * \$bar->setFooKey(\$foo->getPrimaryKey())
- *";
- if (count($fk->getLocalColumns()) > 1) {
- $script .= "
- * Note: It is important that the xml schema used to create this class
- * maintains consistency in the order of related columns between
- * ".$table->getName()." and ". $tblFK->getName().".
- * If for some reason this is impossible, this method should be
- * overridden in ".$table->getPhpName().".";
- }
- $script .= "
- * @return void
- * @throws PropelException
- */
- public function set".$methodAffix."Key(\$key)
- {
+ $script .= "
+ /**
+ * Provides convenient way to set a relationship based on a
+ * key. e.g.
+ * \$bar->setFooKey(\$foo->getPrimaryKey())
+ *";
+ if (count($fk->getLocalColumns()) > 1) {
+ $script .= "
+ * Note: It is important that the xml schema used to create this class
+ * maintains consistency in the order of related columns between
+ * ".$table->getName()." and ". $tblFK->getName().".
+ * If for some reason this is impossible, this method should be
+ * overridden in ".$table->getPhpName().".";
+ }
+ $script .= "
+ * @return void
+ * @throws PropelException
+ */
+ public function set".$methodAffix."Key(\$key)
+ {
";
- if (count($fk->getLocalColumns()) > 1) {
- $i = 0;
- foreach ($fk->getLocalColumns() as $colName) {
- $col = $table->getColumn($colName);
- $fktype = $col->getPhpNative();
- $script .= "
- \$this->set".$col->getPhpName()."( ($fktype) \$key[$i] );
+ if (count($fk->getLocalColumns()) > 1) {
+ $i = 0;
+ foreach ($fk->getLocalColumns() as $colName) {
+ $col = $table->getColumn($colName);
+ $fktype = $col->getPhpNative();
+ $script .= "
+ \$this->set".$col->getPhpName()."( ($fktype) \$key[$i] );
";
- $i++;
- } /* foreach */
- } else {
- $lcols = $fk->getLocalColumns();
- $colName = $lcols[0];
- $col = $table->getColumn($colName);
- $fktype = $col->getPhpNative();
- $script .= "
- \$this->set".$col->getPhpName()."( ($fktype) \$key);
+ $i++;
+ } /* foreach */
+ } else {
+ $lcols = $fk->getLocalColumns();
+ $colName = $lcols[0];
+ $col = $table->getColumn($colName);
+ $fktype = $col->getPhpNative();
+ $script .= "
+ \$this->set".$col->getPhpName()."( ($fktype) \$key);
";
- }
- $script .= "
- }
+ }
+ $script .= "
+ }
";
- } // addFKByKeyMutator()
+ } // addFKByKeyMutator()
- /**
- * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK)
- {
- $table = $this->getTable();
- $tblFK = $refFK->getTable();
+ /**
+ * Adds the method that fetches fkey-related (referencing) objects but also joins in data from another table.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKGetJoinMethods(&$script, ForeignKey $refFK)
+ {
+ $table = $this->getTable();
+ $tblFK = $refFK->getTable();
- $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true);
- $collName = $this->getRefFKCollVarName($refFK);
- $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
+ $relCol = $this->getRefFKPhpNameAffix($refFK, $plural=true);
+ $collName = $this->getRefFKCollVarName($refFK);
+ $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
- $fkPeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
+ $fkPeerBuilder = OMBuilder::getNewPeerBuilder($tblFK);
- $lastTable = "";
- foreach ($tblFK->getForeignKeys() as $fk2) {
+ $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.
+ // Add join methods if the fk2 table is not this table or
+ // the fk2 table references this table multiple times.
- $doJoinGet = true;
+ $doJoinGet = true;
- if ( $fk2->getForeignTableName() == $table->getName() ) {
- $doJoinGet = false;
- }
+ if ( $fk2->getForeignTableName() == $table->getName() ) {
+ $doJoinGet = false;
+ }
- foreach ($fk2->getLocalColumns() as $columnName) {
- $column = $tblFK->getColumn($columnName);
- if ($column->isMultipleFK()) {
- $doJoinGet = true;
- }
- }
+ foreach ($fk2->getLocalColumns() as $columnName) {
+ $column = $tblFK->getColumn($columnName);
+ if ($column->isMultipleFK()) {
+ $doJoinGet = true;
+ }
+ }
- $tblFK2 = $this->getForeignTable($fk2);
- $doJoinGet = !$tblFK2->isForReferenceOnly();
+ $tblFK2 = $this->getForeignTable($fk2);
+ $doJoinGet = !$tblFK2->isForReferenceOnly();
- // it doesn't make sense to join in rows from the curent table, since we are fetching
- // objects related to *this* table (i.e. the joined rows will all be the same row as current object)
- if ($this->getTable()->getPhpName() == $tblFK2->getPhpName()) {
- $doJoinGet = false;
- }
+ // it doesn't make sense to join in rows from the curent table, since we are fetching
+ // objects related to *this* table (i.e. the joined rows will all be the same row as current object)
+ if ($this->getTable()->getPhpName() == $tblFK2->getPhpName()) {
+ $doJoinGet = false;
+ }
- $relCol2 = $this->getFKPhpNameAffix($fk2, $plural = false);
+ $relCol2 = $this->getFKPhpNameAffix($fk2, $plural = false);
- if ( $this->getRelatedBySuffix($refFK) != "" &&
- ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) {
- $doJoinGet = false;
- }
+ if ( $this->getRelatedBySuffix($refFK) != "" &&
+ ($this->getRelatedBySuffix($refFK) == $this->getRelatedBySuffix($fk2))) {
+ $doJoinGet = false;
+ }
- if ($doJoinGet) {
- $script .= "
+ if ($doJoinGet) {
+ $script .= "
- /**
- * If this collection has already been initialized with
- * an identical criteria, it returns the collection.
- * Otherwise if this ".$table->getPhpName()." is new, it will return
- * an empty collection; or if this ".$table->getPhpName()." has previously
- * been saved, it will retrieve related $relCol 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 ".$table->getPhpName().".
- */
- public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null)
- {
- // include the Peer class
- include_once '".$fkPeerBuilder->getClassFilePath()."';
- if (\$criteria === null) {
- \$criteria = new Criteria();
- }
- elseif (\$criteria instanceof Criteria)
- {
- \$criteria = clone \$criteria;
- }
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this ".$table->getPhpName()." is new, it will return
+ * an empty collection; or if this ".$table->getPhpName()." has previously
+ * been saved, it will retrieve related $relCol 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 ".$table->getPhpName().".
+ */
+ public function get".$relCol."Join".$relCol2."(\$criteria = null, \$con = null)
+ {
+ // include the Peer class
+ include_once '".$fkPeerBuilder->getClassFilePath()."';
+ if (\$criteria === null) {
+ \$criteria = new Criteria();
+ }
+ elseif (\$criteria instanceof Criteria)
+ {
+ \$criteria = clone \$criteria;
+ }
- if (\$this->$collName === null) {
- if (\$this->isNew()) {
- \$this->$collName = array();
- } else {
+ if (\$this->$collName === null) {
+ if (\$this->isNew()) {
+ \$this->$collName = array();
+ } else {
";
- foreach ($refFK->getForeignColumns() as $columnName) {
- $column = $table->getColumn($columnName);
- $flMap = $refFK->getForeignLocalMapping();
- $colFKName = $flMap[$columnName];
- $colFK = $tblFK->getColumn($colFKName);
- if ($colFK === null) {
- $e = new Exception("Column $colFKName not found in " . $tblFK->getName());
- print $e;
- throw $e;
- }
- $script .= "
- \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
+ foreach ($refFK->getForeignColumns() as $columnName) {
+ $column = $table->getColumn($columnName);
+ $flMap = $refFK->getForeignLocalMapping();
+ $colFKName = $flMap[$columnName];
+ $colFK = $tblFK->getColumn($colFKName);
+ if ($colFK === null) {
+ $e = new Exception("Column $colFKName not found in " . $tblFK->getName());
+ print $e;
+ throw $e;
+ }
+ $script .= "
+ \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
";
- } // end foreach ($fk->getForeignColumns()
+ } // end foreach ($fk->getForeignColumns()
- $script .= "
- \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$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.
+ $script .= "
+ \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$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.
";
- foreach ($refFK->getForeignColumns() as $columnName) {
- $column = $table->getColumn($columnName);
- $flMap = $refFK->getForeignLocalMapping();
- $colFKName = $flMap[$columnName];
- $colFK = $tblFK->getColumn($colFKName);
- $script .= "
- \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
+ foreach ($refFK->getForeignColumns() as $columnName) {
+ $column = $table->getColumn($columnName);
+ $flMap = $refFK->getForeignLocalMapping();
+ $colFKName = $flMap[$columnName];
+ $colFK = $tblFK->getColumn($colFKName);
+ $script .= "
+ \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
";
- } /* end foreach ($fk->getForeignColumns() */
+ } /* end foreach ($fk->getForeignColumns() */
- $script .= "
- if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) {
- \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$criteria, \$con);
- }
- }
- \$this->$lastCriteriaName = \$criteria;
+ $script .= "
+ if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) {
+ \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelectJoin$relCol2(\$criteria, \$con);
+ }
+ }
+ \$this->$lastCriteriaName = \$criteria;
- return \$this->$collName;
- }
+ return \$this->$collName;
+ }
";
- } /* end if($doJoinGet) */
+ } /* end if($doJoinGet) */
- } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */
+ } /* end foreach ($tblFK->getForeignKeys() as $fk2) { */
- } // function
+ } // function
- // ----------------------------------------------------------------
- //
- // R E F E R R E R F K M E T H O D S
- //
- // ----------------------------------------------------------------
+ // ----------------------------------------------------------------
+ //
+ // R E F E R R E R F K M E T H O D S
+ //
+ // ----------------------------------------------------------------
- /**
- * Adds the attributes used to store objects that have referrer fkey relationships to this object.
- * protected collVarName;
- * private lastVarNameCriteria = null;
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKAttributes(&$script, ForeignKey $refFK)
- {
- $collName = $this->getRefFKCollVarName($refFK);
- $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
+ /**
+ * Adds the attributes used to store objects that have referrer fkey relationships to this object.
+ * protected collVarName;
+ * private lastVarNameCriteria = null;
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKAttributes(&$script, ForeignKey $refFK)
+ {
+ $collName = $this->getRefFKCollVarName($refFK);
+ $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
- $script .= "
- /**
- * Collection to store aggregation of $collName.
- * @var array
- */
- protected $".$collName.";
+ $script .= "
+ /**
+ * Collection to store aggregation of $collName.
+ * @var array
+ */
+ protected $".$collName.";
- /**
- * The criteria used to select the current contents of $collName.
- * @var Criteria
- */
- protected \$".$lastCriteriaName." = null;
+ /**
+ * The criteria used to select the current contents of $collName.
+ * @var Criteria
+ */
+ protected \$".$lastCriteriaName." = null;
";
- }
+ }
- /**
- * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKMethods(&$script)
- {
- foreach($this->getTable()->getReferrers() as $refFK) {
- // if ( $refFK->getTable()->getName() != $this->getTable()->getName() ) {
- $this->addRefFKInit($script, $refFK);
- $this->addRefFKGet($script, $refFK);
- $this->addRefFKCount($script, $refFK);
- $this->addRefFKAdd($script, $refFK);
- $this->addRefFKGetJoinMethods($script, $refFK);
- // }
- }
- }
+ /**
+ * Adds the methods for retrieving, initializing, adding objects that are related to this one by foreign keys.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKMethods(&$script)
+ {
+ foreach($this->getTable()->getReferrers() as $refFK) {
+ // if ( $refFK->getTable()->getName() != $this->getTable()->getName() ) {
+ $this->addRefFKInit($script, $refFK);
+ $this->addRefFKGet($script, $refFK);
+ $this->addRefFKCount($script, $refFK);
+ $this->addRefFKAdd($script, $refFK);
+ $this->addRefFKGetJoinMethods($script, $refFK);
+ // }
+ }
+ }
- /**
- * Adds the method that initializes the referrer fkey collection.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKInit(&$script, ForeignKey $refFK) {
+ /**
+ * Adds the method that initializes the referrer fkey collection.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKInit(&$script, ForeignKey $refFK) {
- $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
- $collName = $this->getRefFKCollVarName($refFK);
+ $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
+ $collName = $this->getRefFKCollVarName($refFK);
- $script .= "
- /**
- * Temporary storage of $collName 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$relCol()
- {
- if (\$this->$collName === null) {
- \$this->$collName = array();
- }
- }
+ $script .= "
+ /**
+ * Temporary storage of $collName 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$relCol()
+ {
+ if (\$this->$collName === null) {
+ \$this->$collName = array();
+ }
+ }
";
- } // addRefererInit()
+ } // addRefererInit()
- /**
- * Adds the method that adds an object into the referrer fkey collection.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKAdd(&$script, ForeignKey $refFK)
- {
- $tblFK = $refFK->getTable();
- $className = $refFK->getTable()->getPhpName();
+ /**
+ * Adds the method that adds an object into the referrer fkey collection.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKAdd(&$script, ForeignKey $refFK)
+ {
+ $tblFK = $refFK->getTable();
+ $className = $refFK->getTable()->getPhpName();
- $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($refFK->getTable());
+ $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($refFK->getTable());
- $script .= "
- /**
- * Method called to associate a ".$tblFK->getPhpName()." object to this object
- * through the $className foreign key attribute
- *
- * @param $className \$l $className
- * @return void
- * @throws PropelException
- */
- public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$l)
- {
- \$this->coll".$this->getRefFKPhpNameAffix($refFK, $plural = true)."[] = \$l;
- \$l->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this);
- }
+ $script .= "
+ /**
+ * Method called to associate a ".$tblFK->getPhpName()." object to this object
+ * through the $className foreign key attribute
+ *
+ * @param $className \$l $className
+ * @return void
+ * @throws PropelException
+ */
+ public function add".$this->getRefFKPhpNameAffix($refFK, $plural = false)."($className \$l)
+ {
+ \$this->coll".$this->getRefFKPhpNameAffix($refFK, $plural = true)."[] = \$l;
+ \$l->set".$this->getFKPhpNameAffix($refFK, $plural = false)."(\$this);
+ }
";
- } // addRefererAdd
+ } // addRefererAdd
- /**
- * Adds the method that returns the size of the referrer fkey collection.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKCount(&$script, ForeignKey $refFK)
- {
- $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
+ /**
+ * Adds the method that returns the size of the referrer fkey collection.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKCount(&$script, ForeignKey $refFK)
+ {
+ $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
- $fkPeerBuilder = OMBuilder::getNewPeerBuilder($refFK->getTable());
+ $fkPeerBuilder = OMBuilder::getNewPeerBuilder($refFK->getTable());
- $script .= "
- /**
- * Returns the number of related $relCol.
- *
- * @param Criteria \$criteria
- * @param boolean \$distinct
- * @param Connection \$con
- * @throws PropelException
- */
- public function count$relCol(\$criteria = null, \$distinct = false, \$con = null)
- {
- // include the Peer class
- include_once '".$fkPeerBuilder->getClassFilePath()."';
- if (\$criteria === null) {
- \$criteria = new Criteria();
- }
- elseif (\$criteria instanceof Criteria)
- {
- \$criteria = clone \$criteria;
- }
+ $script .= "
+ /**
+ * Returns the number of related $relCol.
+ *
+ * @param Criteria \$criteria
+ * @param boolean \$distinct
+ * @param Connection \$con
+ * @throws PropelException
+ */
+ public function count$relCol(\$criteria = null, \$distinct = false, \$con = null)
+ {
+ // include the Peer class
+ include_once '".$fkPeerBuilder->getClassFilePath()."';
+ if (\$criteria === null) {
+ \$criteria = new Criteria();
+ }
+ elseif (\$criteria instanceof Criteria)
+ {
+ \$criteria = clone \$criteria;
+ }
";
- foreach ($refFK->getForeignColumns() as $columnName) {
- $column = $this->getTable()->getColumn($columnName);
- $flmap = $refFK->getForeignLocalMapping();
- $colFKName = $flmap[$columnName];
- $colFK = $refFK->getTable()->getColumn($colFKName);
- $script .= "
- \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
+ foreach ($refFK->getForeignColumns() as $columnName) {
+ $column = $this->getTable()->getColumn($columnName);
+ $flmap = $refFK->getForeignLocalMapping();
+ $colFKName = $flmap[$columnName];
+ $colFK = $refFK->getTable()->getColumn($colFKName);
+ $script .= "
+ \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$column->getPhpName()."());
";
- } // end foreach ($fk->getForeignColumns()
- $script .="
- return ".$fkPeerBuilder->getPeerClassname()."::doCount(\$criteria, \$distinct, \$con);
- }
+ } // end foreach ($fk->getForeignColumns()
+ $script .="
+ return ".$fkPeerBuilder->getPeerClassname()."::doCount(\$criteria, \$distinct, \$con);
+ }
";
- } // addRefererCount
+ } // addRefererCount
- /**
- * Adds the method that returns the referrer fkey collection.
- * @param string &$script The script will be modified in this method.
- */
- protected function addRefFKGet(&$script, ForeignKey $refFK)
- {
- $table = $this->getTable();
- $tblFK = $refFK->getTable();
+ /**
+ * Adds the method that returns the referrer fkey collection.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addRefFKGet(&$script, ForeignKey $refFK)
+ {
+ $table = $this->getTable();
+ $tblFK = $refFK->getTable();
- $fkPeerBuilder = OMBuilder::getNewPeerBuilder($refFK->getTable());
- $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
+ $fkPeerBuilder = OMBuilder::getNewPeerBuilder($refFK->getTable());
+ $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = true);
- $collName = $this->getRefFKCollVarName($refFK);
- $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
+ $collName = $this->getRefFKCollVarName($refFK);
+ $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK);
- $script .= "
- /**
- * If this collection has already been initialized with
- * an identical criteria, it returns the collection.
- * Otherwise if this ".$table->getPhpName()." has previously
- * been saved, it will retrieve related $relCol from storage.
- * If this ".$table->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$relCol(\$criteria = null, \$con = null)
- {
- // include the Peer class
- include_once '".$fkPeerBuilder->getClassFilePath()."';
- if (\$criteria === null) {
- \$criteria = new Criteria();
- }
- elseif (\$criteria instanceof Criteria)
- {
- \$criteria = clone \$criteria;
- }
+ $script .= "
+ /**
+ * If this collection has already been initialized with
+ * an identical criteria, it returns the collection.
+ * Otherwise if this ".$table->getPhpName()." has previously
+ * been saved, it will retrieve related $relCol from storage.
+ * If this ".$table->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$relCol(\$criteria = null, \$con = null)
+ {
+ // include the Peer class
+ include_once '".$fkPeerBuilder->getClassFilePath()."';
+ if (\$criteria === null) {
+ \$criteria = new Criteria();
+ }
+ elseif (\$criteria instanceof Criteria)
+ {
+ \$criteria = clone \$criteria;
+ }
- if (\$this->$collName === null) {
- if (\$this->isNew()) {
- \$this->$collName = array();
- } else {
+ if (\$this->$collName === null) {
+ if (\$this->isNew()) {
+ \$this->$collName = array();
+ } else {
";
- foreach ($refFK->getLocalColumns() as $colFKName) {
- // $colFKName is local to the referring table (i.e. foreign to this table)
- $lfmap = $refFK->getLocalForeignMapping();
- $localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
- $colFK = $refFK->getTable()->getColumn($colFKName);
+ foreach ($refFK->getLocalColumns() as $colFKName) {
+ // $colFKName is local to the referring table (i.e. foreign to this table)
+ $lfmap = $refFK->getLocalForeignMapping();
+ $localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
+ $colFK = $refFK->getTable()->getColumn($colFKName);
- $script .= "
- \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$localColumn->getPhpName()."());
+ $script .= "
+ \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$localColumn->getPhpName()."());
";
- } // end foreach ($fk->getForeignColumns()
+ } // end foreach ($fk->getForeignColumns()
- $script .= "
- ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria);
- \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::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.
+ $script .= "
+ ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria);
+ \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::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.
";
- foreach ($refFK->getLocalColumns() as $colFKName) {
- // $colFKName is local to the referring table (i.e. foreign to this table)
- $lfmap = $refFK->getLocalForeignMapping();
- $localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
- $colFK = $refFK->getTable()->getColumn($colFKName);
- $script .= "
+ foreach ($refFK->getLocalColumns() as $colFKName) {
+ // $colFKName is local to the referring table (i.e. foreign to this table)
+ $lfmap = $refFK->getLocalForeignMapping();
+ $localColumn = $this->getTable()->getColumn($lfmap[$colFKName]);
+ $colFK = $refFK->getTable()->getColumn($colFKName);
+ $script .= "
- \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$localColumn->getPhpName()."());
+ \$criteria->add(".$fkPeerBuilder->getColumnConstant($colFK).", \$this->get".$localColumn->getPhpName()."());
";
- } // foreach ($fk->getForeignColumns()
+ } // foreach ($fk->getForeignColumns()
$script .= "
- ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria);
- if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) {
- \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelect(\$criteria, \$con);
- }
- }
- }
- \$this->$lastCriteriaName = \$criteria;
- return \$this->$collName;
- }
+ ".$fkPeerBuilder->getPeerClassname()."::addSelectColumns(\$criteria);
+ if (!isset(\$this->$lastCriteriaName) || !\$this->".$lastCriteriaName."->equals(\$criteria)) {
+ \$this->$collName = ".$fkPeerBuilder->getPeerClassname()."::doSelect(\$criteria, \$con);
+ }
+ }
+ }
+ \$this->$lastCriteriaName = \$criteria;
+ return \$this->$collName;
+ }
";
- } // addRefererGet()
+ } // addRefererGet()
- // ----------------------------------------------------------------
- //
- // M A N I P U L A T I O N M E T H O D S
- //
- // ----------------------------------------------------------------
+ // ----------------------------------------------------------------
+ //
+ // M A N I P U L A T I O N M E T H O D S
+ //
+ // ----------------------------------------------------------------
- /**
- * Adds the workhourse doSave() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSave(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the workhourse doSave() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSave(&$script)
+ {
+ $table = $this->getTable();
- $script .= "
- /**
- * Stores the object in the database.
- *
- * If the object is new, it inserts it; otherwise an update is performed.
- * All related objects are also updated in this method.
- *
- * @param Connection \$con
- * @return int The number of rows affected by this insert/update and any referring fk objects' save() operations.
- * @throws PropelException
- * @see save()
- */
- protected function doSave(\$con)
- {
- \$affectedRows = 0; // initialize var to track total num of affected rows
- if (!\$this->alreadyInSave) {
- \$this->alreadyInSave = true;
+ $script .= "
+ /**
+ * Stores the object in the database.
+ *
+ * If the object is new, it inserts it; otherwise an update is performed.
+ * All related objects are also updated in this method.
+ *
+ * @param Connection \$con
+ * @return int The number of rows affected by this insert/update and any referring
+ * @throws PropelException
+ * @see save()
+ */
+ protected function doSave(\$con)
+ {
+ \$affectedRows = 0; // initialize var to track total num of affected rows
+ if (!\$this->alreadyInSave) {
+ \$this->alreadyInSave = true;
";
- if (count($table->getForeignKeys())) {
+ if (count($table->getForeignKeys())) {
- $script .= "
+ $script .= "
- // 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.
+ // 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.
";
- foreach($table->getForeignKeys() as $fk)
- {
- $aVarName = $this->getFKVarName($fk);
- $script .= "
- if (\$this->$aVarName !== null) {
- if (\$this->".$aVarName."->isModified()) {
- \$affectedRows += \$this->".$aVarName."->save(\$con);
- }
- \$this->set".$this->getFKPhpNameAffix($fk, $plural = false)."(\$this->$aVarName);
- }
+ foreach($table->getForeignKeys() as $fk)
+ {
+ $aVarName = $this->getFKVarName($fk);
+ $script .= "
+ if (\$this->$aVarName !== null) {
+ if (\$this->".$aVarName."->isModified()) {
+ \$affectedRows += \$this->".$aVarName."->save(\$con);
+ }
+ \$this->set".$this->getFKPhpNameAffix($fk, $plural = false)."(\$this->$aVarName);
+ }
";
- } // foreach foreign k
- } // if (count(foreign keys))
+ } // foreach foreign k
+ } // if (count(foreign keys))
- $script .= "
+ $script .= "
- // If this object has been modified, then save it to the database.
- if (\$this->isModified()";
+ // If this object has been modified, then save it to the database.
+ if (\$this->isModified()";
- /*
- FIXME: this doesn't work right now because the BasePeer::doInsert() method
- expects to be passed a Criteria object that contains columns (which tell BasePeer
- which table is being updated)
- if ($table->hasAutoIncrementPrimaryKey()) {
- $script .= " || \$this->isNew()";
- }
- */
+ /*
+ FIXME: this doesn't work right now because the BasePeer::doInsert() method
+ expects to be passed a Criteria object that contains columns (which tell BasePeer
+ which table is being updated)
+ if ($table->hasAutoIncrementPrimaryKey()) {
+ $script .= " || \$this->isNew()";
+ }
+ */
- $script .= ") {
- if (\$this->isNew()) {
- \$pk = ".$this->getPeerClassname()."::doInsert(\$this, \$con);
- \$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
- // should always be true here (even though technically
- // BasePeer::doInsert() can insert multiple rows).
+ $script .= ") {
+ if (\$this->isNew()) {
+ \$pk = ".$this->getPeerClassname()."::doInsert(\$this, \$con);
+ \$affectedRows += 1; // we are assuming that there is only 1 row per doInsert() which
+ // should always be true here (even though technically
+ // BasePeer::doInsert() can insert multiple rows).
";
- if ($table->getIdMethod() != IDMethod::NO_ID_METHOD) {
+ if ($table->getIdMethod() != IDMethod::NO_ID_METHOD) {
- if (count($pks = $table->getPrimaryKey())) {
- foreach ($pks as $pk) {
- if ($pk->isAutoIncrement()) {
- $script .= "
- \$this->set".$pk->getPhpName()."(\$pk); //[IMV] update autoincrement primary key
+ if (count($pks = $table->getPrimaryKey())) {
+ foreach ($pks as $pk) {
+ if ($pk->isAutoIncrement()) {
+ $script .= "
+ \$this->set".$pk->getPhpName()."(\$pk); //[IMV] update autoincrement primary key
";
- }
- }
- }
- } // if (id method != "none")
+ }
+ }
+ }
+ } // if (id method != "none")
- $script .= "
- \$this->setNew(false);
- } else {
- \$affectedRows += ".$this->getPeerClassname()."::doUpdate(\$this, \$con);
- }
- \$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
- }
+ $script .= "
+ \$this->setNew(false);
+ } else {
+ \$affectedRows += ".$this->getPeerClassname()."::doUpdate(\$this, \$con);
+ }
+ \$this->resetModified(); // [HL] After being saved an object is no longer 'modified'
+ }
";
- foreach ($table->getReferrers() as $fk) {
- $collName = $this->getRefFKCollVarName($fk);
- //HL: commenting out self-referrential check below
- // it seems to work as expected and is desireable since we are also enabling the copy()ing of these related rows
- //if ( $fk->getTable()->getName() != $table->getName() ) {
- $script .= "
- if (\$this->$collName !== null) {
- foreach(\$this->$collName as \$referrerFK) {
- if (!\$referrerFK->isDeleted()) {
- \$affectedRows += \$referrerFK->save(\$con);
- }
- }
- }
+ foreach ($table->getReferrers() as $fk) {
+ $collName = $this->getRefFKCollVarName($fk);
+ //HL: commenting out self-referrential check below
+ // it seems to work as expected and is desireable since we are also enabling the copy()ing of these related rows
+ //if ( $fk->getTable()->getName() != $table->getName() ) {
+ $script .= "
+ if (\$this->$collName !== null) {
+ foreach(\$this->$collName as \$referrerFK) {
+ if (!\$referrerFK->isDeleted()) {
+ \$affectedRows += \$referrerFK->save(\$con);
+ }
+ }
+ }
";
- //HL: commenting out close of self-referrential check
- //} /* if tableFK != table */
- } /* foreach getReferrers() */
- $script .= "
- \$this->alreadyInSave = false;
- }
- return \$affectedRows;
- } // doSave()
+ //HL: commenting out close of self-referrential check
+ //} /* if tableFK != table */
+ } /* foreach getReferrers() */
+ $script .= "
+ \$this->alreadyInSave = false;
+ }
+ return \$affectedRows;
+ } // doSave()
";
- }
+ }
- /**
- * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAlreadyInSaveAttribute(&$script)
- {
- $script .= "
- /**
- * Flag to prevent endless save loop, if this object is referenced
- * by another object which falls in this transaction.
- * @var boolean
- */
- protected \$alreadyInSave = false;
+ /**
+ * Adds the $alreadyInSave attribute, which prevents attempting to re-save the same object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addAlreadyInSaveAttribute(&$script)
+ {
+ $script .= "
+ /**
+ * Flag to prevent endless save loop, if this object is referenced
+ * by another object which falls in this transaction.
+ * @var boolean
+ */
+ protected \$alreadyInSave = false;
";
- }
+ }
- /**
- * Adds the save() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addSave(&$script)
- {
- $script .= "
- /**
- * 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 int The number of rows affected by this insert/update and any referring fk objects' save() operations.
- * @throws PropelException
- * @see doSave()
- */
- public function save(\$con = null)
- {
- if (\$this->isDeleted()) {
- throw new PropelException(\"You cannot save an object that has been deleted.\");
- }
+ /**
+ * Adds the save() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addSave(&$script)
+ {
+ $script .= "
+ /**
+ * 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 int The number of rows affected by this insert/update
+ * @throws PropelException
+ * @see doSave()
+ */
+ 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(".$this->getPeerClassname()."::DATABASE_NAME);
- }
+ if (\$con === null) {
+ \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME);
+ }
- try {
- \$con->begin();
- \$affectedRows = \$this->doSave(\$con);
- \$con->commit();
- return \$affectedRows;
- } catch (PropelException \$e) {
- \$con->rollback();
- throw \$e;
- }
- }
+ try {
+ \$con->begin();
+ \$affectedRows = \$this->doSave(\$con);
+ \$con->commit();
+ return \$affectedRows;
+ } catch (PropelException \$e) {
+ \$con->rollback();
+ throw \$e;
+ }
+ }
";
- }
+ }
- /**
- * Adds the $alreadyInValidation attribute, which prevents attempting to re-validate the same object.
- * @param string &$script The script will be modified in this method.
- */
- protected function addAlreadyInValidationAttribute(&$script)
- {
- $script .= "
- /**
- * Flag to prevent endless validation loop, if this object is referenced
- * by another object which falls in this transaction.
- * @var boolean
- */
- protected \$alreadyInValidation = false;
+ /**
+ * Adds the $alreadyInValidation attribute, which prevents attempting to re-validate the same object.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addAlreadyInValidationAttribute(&$script)
+ {
+ $script .= "
+ /**
+ * Flag to prevent endless validation loop, if this object is referenced
+ * by another object which falls in this transaction.
+ * @var boolean
+ */
+ protected \$alreadyInValidation = false;
";
- }
+ }
- /**
- * Adds the validate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addValidate(&$script)
- {
- $script .= "
- /**
- * Validates the objects modified field values and 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 boolean Whether all columns pass validation.
- * @see doValidate()
- * @see getValidationFailures()
- */
- public function validate(\$columns = null)
- {
- \$res = \$this->doValidate(\$columns);
- if (\$res === true) {
- \$this->validationFailures = array();
- return true;
- } else {
- \$this->validationFailures = \$res;
- return false;
- }
- }
+ /**
+ * Adds the validate() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addValidate(&$script)
+ {
+ $script .= "
+ /**
+ * Validates the objects modified field values and 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 boolean Whether all columns pass validation.
+ * @see doValidate()
+ * @see getValidationFailures()
+ */
+ public function validate(\$columns = null)
+ {
+ \$res = \$this->doValidate(\$columns);
+ if (\$res === true) {
+ \$this->validationFailures = array();
+ return true;
+ } else {
+ \$this->validationFailures = \$res;
+ return false;
+ }
+ }
";
- } // addValidate()
+ } // addValidate()
- /**
- * Adds the workhourse doValidate() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoValidate(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the workhourse doValidate() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoValidate(&$script)
+ {
+ $table = $this->getTable();
- $script .= "
- /**
- * 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.
- *
- * @param array \$columns Array of column names to validate.
- * @return mixed true if all validations pass; array of ValidationFailed objets otherwise.
- */
- protected function doValidate(\$columns = null)
- {
- if (!\$this->alreadyInValidation) {
- \$this->alreadyInValidation = true;
- \$retval = null;
+ $script .= "
+ /**
+ * 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.
+ *
+ * @param array \$columns Array of column names to validate.
+ * @return mixed true if all validations pass;
+ array of ValidationFailed objects otherwise.
+ */
+ protected function doValidate(\$columns = null)
+ {
+ if (!\$this->alreadyInValidation) {
+ \$this->alreadyInValidation = true;
+ \$retval = null;
- \$failureMap = array();
+ \$failureMap = array();
";
- if (count($table->getForeignKeys()) != 0) {
- $script .= "
+ if (count($table->getForeignKeys()) != 0) {
+ $script .= "
- // 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.
+ // 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.
";
- foreach($table->getForeignKeys() as $fk) {
- $aVarName = $this->getFKVarName($fk);
- $script .= "
- if (\$this->".$aVarName." !== null) {
- if (!\$this->".$aVarName."->validate(\$columns)) {
- \$failureMap = array_merge(\$failureMap, \$this->".$aVarName."->getValidationFailures());
- }
- }
+ foreach($table->getForeignKeys() as $fk) {
+ $aVarName = $this->getFKVarName($fk);
+ $script .= "
+ if (\$this->".$aVarName." !== null) {
+ if (!\$this->".$aVarName."->validate(\$columns)) {
+ \$failureMap = array_merge(\$failureMap, \$this->".$aVarName."->getValidationFailures());
+ }
+ }
";
- } /* for() */
- } /* if count(fkeys) */
+ } /* for() */
+ } /* if count(fkeys) */
- $script .= "
+ $script .= "
- if ((\$retval = ".$this->getPeerClassname()."::doValidate(\$this, \$columns)) !== true) {
- \$failureMap = array_merge(\$failureMap, \$retval);
- }
+ if ((\$retval = ".$this->getPeerClassname()."::doValidate(\$this, \$columns)) !== true) {
+ \$failureMap = array_merge(\$failureMap, \$retval);
+ }
";
- foreach ($table->getReferrers() as $fk) {
- $tblFK = $fk->getTable();
- if ( $tblFK->getName() != $table->getName() ) {
- $collName = $this->getRefFKCollVarName($fk);
- $script .= "
- if (\$this->$collName !== null) {
- foreach(\$this->$collName as \$referrerFK) {
- if (!\$referrerFK->validate(\$columns)) {
- \$failureMap = array_merge(\$failureMap, \$referrerFK->getValidationFailures());
- }
- }
- }
+ foreach ($table->getReferrers() as $fk) {
+ $tblFK = $fk->getTable();
+ if ( $tblFK->getName() != $table->getName() ) {
+ $collName = $this->getRefFKCollVarName($fk);
+ $script .= "
+ if (\$this->$collName !== null) {
+ foreach(\$this->$collName as \$referrerFK) {
+ if (!\$referrerFK->validate(\$columns)) {
+ \$failureMap = array_merge(\$failureMap, \$referrerFK->getValidationFailures());
+ }
+ }
+ }
";
- } /* if tableFK !+ table */
- } /* foreach getReferrers() */
+ } /* if tableFK !+ table */
+ } /* foreach getReferrers() */
- $script .= "
+ $script .= "
- \$this->alreadyInValidation = false;
- }
+ \$this->alreadyInValidation = false;
+ }
- return (!empty(\$failureMap) ? \$failureMap : true);
- }
+ return (!empty(\$failureMap) ? \$failureMap : true);
+ }
";
- } // addDoValidate()
+ } // addDoValidate()
- /**
- * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addCopy(&$script)
- {
- $this->addCopyInto($script);
+ /**
+ * Adds the copy() method, which (in complex OM) includes the $deepCopy param for making copies of related objects.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addCopy(&$script)
+ {
+ $this->addCopyInto($script);
- $table = $this->getTable();
+ $table = $this->getTable();
- $script .= "
- /**
- * 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 ".$table->getPhpName()." Clone of current object.
- * @throws PropelException
- */
- public function copy(\$deepCopy = false)
- {
- // we use get_class(), because this might be a subclass
- \$clazz = get_class(\$this);
- \$copyObj = new \$clazz();
- \$this->copyInto(\$copyObj, \$deepCopy);
- return \$copyObj;
- }
+ $script .= "
+ /**
+ * 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 ".$table->getPhpName()." Clone of current object.
+ * @throws PropelException
+ */
+ public function copy(\$deepCopy = false)
+ {
+ // we use get_class(), because this might be a subclass
+ \$clazz = get_class(\$this);
+ \$copyObj = new \$clazz();
+ \$this->copyInto(\$copyObj, \$deepCopy);
+ return \$copyObj;
+ }
";
- } // addCopy()
+ } // addCopy()
- /**
- * Adds the copyInto() method, which takes an object and sets contents to match current object.
- * In complex OM this method includes the $deepCopy param for making copies of related objects.
- * @param string &$script The script will be modified in this method.
- */
- protected function addCopyInto(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the copyInto() method, which takes an object and sets contents to match current object.
+ * In complex OM this method includes the $deepCopy param for making copies of related objects.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addCopyInto(&$script)
+ {
+ $table = $this->getTable();
- $script .= "
- /**
- * Sets contents of passed object to values from current object.
- *
- * If desired, this method can also make copies of all associated (fkey referrers)
- * objects.
- *
- * @param object \$copyObj An object of ".$table->getPhpName()." (or compatible) type.
- * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
- * @throws PropelException
- */
- public function copyInto(\$copyObj, \$deepCopy = false)
- {
+ $script .= "
+ /**
+ * Sets contents of passed object to values from current object.
+ *
+ * If desired, this method can also make copies of all associated (fkey referrers)
+ * objects.
+ *
+ * @param object \$copyObj An object of ".$table->getPhpName()." (or compatible) type.
+ * @param boolean \$deepCopy Whether to also copy all rows that refer (by fkey) to the current row.
+ * @throws PropelException
+ */
+ public function copyInto(\$copyObj, \$deepCopy = false)
+ {
";
- $pkcols = array();
- foreach ($table->getColumns() as $pkcol) {
- if ($pkcol->isPrimaryKey()) {
- $pkcols[] = $pkcol->getName();
- }
- }
+ $pkcols = array();
+ foreach ($table->getColumns() as $pkcol) {
+ if ($pkcol->isPrimaryKey()) {
+ $pkcols[] = $pkcol->getName();
+ }
+ }
- foreach ($table->getColumns() as $col) {
- if (!in_array($col->getName(), $pkcols)) {
- $script .= "
- \$copyObj->set".$col->getPhpName()."(\$this->".strtolower($col->getName()).");
+ foreach ($table->getColumns() as $col) {
+ if (!in_array($col->getName(), $pkcols)) {
+ $script .= "
+ \$copyObj->set".$col->getPhpName()."(\$this->".strtolower($col->getName()).");
";
- }
- } // foreach
+ }
+ } // foreach
- // Avoid useless code by checking to see if there are any referrers
- // to this table:
- if (count($table->getReferrers()) > 0) {
- $script .= "
+ // Avoid useless code by checking to see if there are any referrers
+ // to this table:
+ if (count($table->getReferrers()) > 0) {
+ $script .= "
- if (\$deepCopy) {
- // important: temporarily setNew(false) because this affects the behavior of
- // the getter/setter methods for fkey referrer objects.
- \$copyObj->setNew(false);
+ if (\$deepCopy) {
+ // important: temporarily setNew(false) because this affects the behavior of
+ // the getter/setter methods for fkey referrer objects.
+ \$copyObj->setNew(false);
";
- foreach ($table->getReferrers() as $fk) {
- // Continue if $this and $copyObj are the same class and have the same primary key
- // to avoid endless loops
- $script .= "
- foreach(\$this->get".$this->getRefFKPhpNameAffix($fk, true)."() as \$relObj) {";
- if ($table->getName() === $fk->getTableName()) {
- $script .= "
- if(\$this->getPrimaryKey() === \$relObj->getPrimaryKey()) {
- continue;
- }
+ foreach ($table->getReferrers() as $fk) {
+ // Continue if $this and $copyObj are the same class and have the same primary key
+ // to avoid endless loops
+ $script .= "
+ foreach(\$this->get".$this->getRefFKPhpNameAffix($fk, true)."() as \$relObj) {";
+ if ($table->getName() === $fk->getTableName()) {
+ $script .= "
+ if(\$this->getPrimaryKey() === \$relObj->getPrimaryKey()) {
+ continue;
+ }
";
- }
- $script .= "
- \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy));
- }
+ }
+ $script .= "
+ \$copyObj->add".$this->getRefFKPhpNameAffix($fk)."(\$relObj->copy(\$deepCopy));
+ }
";
- // HL: commenting out close of self-referential check
- // } /* if tblFK != table */
- } /* foreach */
- $script .= "
- } // if (\$deepCopy)
+ // HL: commenting out close of self-referential check
+ // } /* if tblFK != table */
+ } /* foreach */
+ $script .= "
+ } // if (\$deepCopy)
";
- } /* if (count referrers > 0 ) */
+ } /* if (count referrers > 0 ) */
- $script .= "
+ $script .= "
- \$copyObj->setNew(true);
+ \$copyObj->setNew(true);
";
- foreach ($table->getColumns() as $col) {
- if ($col->isPrimaryKey()) {
- $coldefval = $col->getPhpDefaultValue();
- $coldefval = var_export($coldefval, true);
- $script .= "
- \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a pkey column, so set to default value
+ foreach ($table->getColumns() as $col) {
+ if ($col->isPrimaryKey()) {
+ $coldefval = $col->getPhpDefaultValue();
+ $coldefval = var_export($coldefval, true);
+ $script .= "
+ \$copyObj->set".$col->getPhpName() ."($coldefval); // this is a pkey column, so set to default value
";
- } // if col->isPrimaryKey
- } // foreach
- $script .= "
- }
+ } // if col->isPrimaryKey
+ } // foreach
+ $script .= "
+ }
";
- } // addCopyInto()
+ } // addCopyInto()
} // PHP5ComplexObjectBuilder
diff --git a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php
index d2738c9fb..348c38e1e 100755
--- a/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php
+++ b/gulliver/thirdparty/propel-generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php
@@ -33,834 +33,834 @@ require_once 'propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php';
*/
class PHP5ComplexPeerBuilder extends PHP5BasicPeerBuilder {
- /**
- * Adds the complex OM methods to the base addSelectMethods() function.
- * @param string &$script The script will be modified in this method.
- * @see PeerBuilder::addSelectMethods()
- */
- protected function addSelectMethods(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the complex OM methods to the base addSelectMethods() function.
+ * @param string &$script The script will be modified in this method.
+ * @see PeerBuilder::addSelectMethods()
+ */
+ protected function addSelectMethods(&$script)
+ {
+ $table = $this->getTable();
- parent::addSelectMethods($script);
+ parent::addSelectMethods($script);
- $this->addDoCountJoin($script);
- $this->addDoSelectJoin($script);
+ $this->addDoCountJoin($script);
+ $this->addDoSelectJoin($script);
- $countFK = count($table->getForeignKeys());
+ $countFK = count($table->getForeignKeys());
- $includeJoinAll = true;
+ $includeJoinAll = true;
- foreach ($this->getTable()->getForeignKeys() as $fk) {
- $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
- if ($tblFK->isForReferenceOnly()) {
- $includeJoinAll = false;
- }
- }
+ foreach ($this->getTable()->getForeignKeys() as $fk) {
+ $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
+ if ($tblFK->isForReferenceOnly()) {
+ $includeJoinAll = false;
+ }
+ }
- if ($includeJoinAll) {
- if($countFK > 0) {
- $this->addDoCountJoinAll($script);
- $this->addDoSelectJoinAll($script);
- }
- if ($countFK > 1) {
- $this->addDoCountJoinAllExcept($script);
- $this->addDoSelectJoinAllExcept($script);
- }
- }
+ if ($includeJoinAll) {
+ if($countFK > 0) {
+ $this->addDoCountJoinAll($script);
+ $this->addDoSelectJoinAll($script);
+ }
+ if ($countFK > 1) {
+ $this->addDoCountJoinAllExcept($script);
+ $this->addDoSelectJoinAllExcept($script);
+ }
+ }
- }
+ }
- /**
- * Adds the doSelectJoin*() methods.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelectJoin(&$script)
- {
- $table = $this->getTable();
- $className = $table->getPhpName();
- $countFK = count($table->getForeignKeys());
+ /**
+ * Adds the doSelectJoin*() methods.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelectJoin(&$script)
+ {
+ $table = $this->getTable();
+ $className = $table->getPhpName();
+ $countFK = count($table->getForeignKeys());
- if ($countFK >= 1) {
+ if ($countFK >= 1) {
- foreach ($table->getForeignKeys() as $fk) {
+ foreach ($table->getForeignKeys() as $fk) {
- $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- if (!$joinTable->isForReferenceOnly()) {
+ if (!$joinTable->isForReferenceOnly()) {
- // FIXME - look into removing this next condition; it may not
- // be necessary:
- // --- IT is necessary because there needs to be a system for
- // aliasing the table if it is the same table.
- if ( $fk->getForeignTableName() != $table->getName() ) {
+ // FIXME - look into removing this next condition; it may not
+ // be necessary:
+ // --- IT is necessary because there needs to be a system for
+ // aliasing the table if it is the same table.
+ if ( $fk->getForeignTableName() != $table->getName() ) {
- /*
- REPLACED BY USING THE ObjectBuilder objects below
+ /*
+ REPLACED BY USING THE ObjectBuilder objects below
- // check to see if we need to add something to the method name.
- // For example if there are multiple columns that reference the same
- // table, then we have to have a methd name like doSelectJoinBooksByBookId
- $partJoinName = "";
- foreach ($fk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- // this second part is not currently ever true (right?)
- if ($column->isMultipleFK() || $fk->getForeignTableName() == $table->getName()) {
- $partJoinName = $partJoinName . $column->getPhpName();
- }
- }
+ // check to see if we need to add something to the method name.
+ // For example if there are multiple columns that reference the same
+ // table, then we have to have a methd name like doSelectJoinBooksByBookId
+ $partJoinName = "";
+ foreach ($fk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ // this second part is not currently ever true (right?)
+ if ($column->isMultipleFK() || $fk->getForeignTableName() == $table->getName()) {
+ $partJoinName = $partJoinName . $column->getPhpName();
+ }
+ }
- $joinClassName = $joinTable->getPhpName();
+ $joinClassName = $joinTable->getPhpName();
- if ($joinTable->getInterface()) {
- $interfaceName = $joinTable->getInterface();
- } else {
- $interfaceName = $joinTable->getPhpName();
- }
+ if ($joinTable->getInterface()) {
+ $interfaceName = $joinTable->getInterface();
+ } else {
+ $interfaceName = $joinTable->getPhpName();
+ }
- 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;
- }
- */
+ 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;
+ }
+ */
- $joinClassName = $joinTable->getPhpName();
+ $joinClassName = $joinTable->getPhpName();
- $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
- $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
+ $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $script .= "
+ $script .= "
- /**
- * Selects a collection of $className objects pre-filled with their $joinClassName objects.
- *
- * @return array Array of $className objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, \$con = null)
- {
- \$c = clone \$c;
+ /**
+ * Selects a collection of $className objects pre-filled with their $joinClassName objects.
+ *
+ * @return array Array of $className objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, \$con = null)
+ {
+ \$c = clone \$c;
- // Set the correct dbName if it has not been overridden
- if (\$c->getDbName() == Propel::getDefaultDB()) {
- \$c->setDbName(self::DATABASE_NAME);
- }
+ // Set the correct dbName if it has not been overridden
+ if (\$c->getDbName() == Propel::getDefaultDB()) {
+ \$c->setDbName(self::DATABASE_NAME);
+ }
- ".$this->getPeerClassname()."::addSelectColumns(\$c);
- \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
- ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
+ ".$this->getPeerClassname()."::addSelectColumns(\$c);
+ \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
+ ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
";
- $lfMap = $fk->getLocalForeignMapping();
- foreach ($fk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName] );
- $script .= "
- \$c->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");"; //CHECKME
- }
- $script .= "
- \$rs = ".$this->basePeerClassname."::doSelect(\$c, \$con);
- \$results = array();
+ $lfMap = $fk->getLocalForeignMapping();
+ foreach ($fk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName] );
+ $script .= "
+ \$c->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");"; //CHECKME
+ }
+ $script .= "
+ \$rs = ".$this->basePeerClassname."::doSelect(\$c, \$con);
+ \$results = array();
- while(\$rs->next()) {
+ while(\$rs->next()) {
";
- if ($table->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
+ if ($table->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
";
- } else {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass();
";
- }
- $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj1 = new \$cls();
- \$obj1->hydrate(\$rs);
+ }
+ $script .= "
+ \$cls = Propel::import(\$omClass);
+ \$obj1 = new \$cls();
+ \$obj1->hydrate(\$rs);
";
- if ($joinTable->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol);
+ if ($joinTable->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol);
";
- } else {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
";
- }
+ }
- $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj2 = new \$cls();
- \$obj2->hydrate(\$rs, \$startcol);
+ $script .= "
+ \$cls = Propel::import(\$omClass);
+ \$obj2 = new \$cls();
+ \$obj2->hydrate(\$rs, \$startcol);
- \$newObject = true;
- foreach(\$results as \$temp_obj1) {
- \$temp_obj2 = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(); //CHECKME
- if (\$temp_obj2->getPrimaryKey() === \$obj2->getPrimaryKey()) {
- \$newObject = false;
- // e.g. \$author->addBookRelatedByBookId()
- \$temp_obj2->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); //CHECKME
- break;
- }
- }
- if (\$newObject) {
- \$obj2->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = true)."();
- \$obj2->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); //CHECKME
- }
- \$results[] = \$obj1;
- }
- return \$results;
- }
+ \$newObject = true;
+ foreach(\$results as \$temp_obj1) {
+ \$temp_obj2 = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(); //CHECKME
+ if (\$temp_obj2->getPrimaryKey() === \$obj2->getPrimaryKey()) {
+ \$newObject = false;
+ // e.g. \$author->addBookRelatedByBookId()
+ \$temp_obj2->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); //CHECKME
+ break;
+ }
+ }
+ if (\$newObject) {
+ \$obj2->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = true)."();
+ \$obj2->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); //CHECKME
+ }
+ \$results[] = \$obj1;
+ }
+ return \$results;
+ }
";
- } // if fk table name != this table name
- } // if ! is reference only
- } // foreach column
- } // if count(fk) > 1
+ } // if fk table name != this table name
+ } // if ! is reference only
+ } // foreach column
+ } // if count(fk) > 1
- } // addDoSelectJoin()
+ } // addDoSelectJoin()
- /**
- * Adds the doCountJoin*() methods.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoCountJoin(&$script)
- {
- $table = $this->getTable();
- $className = $table->getPhpName();
- $countFK = count($table->getForeignKeys());
+ /**
+ * Adds the doCountJoin*() methods.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoCountJoin(&$script)
+ {
+ $table = $this->getTable();
+ $className = $table->getPhpName();
+ $countFK = count($table->getForeignKeys());
- if ($countFK >= 1) {
+ if ($countFK >= 1) {
- foreach ($table->getForeignKeys() as $fk) {
+ foreach ($table->getForeignKeys() as $fk) {
- $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- if (!$joinTable->isForReferenceOnly()) {
+ if (!$joinTable->isForReferenceOnly()) {
- if ( $fk->getForeignTableName() != $table->getName() ) {
+ if ( $fk->getForeignTableName() != $table->getName() ) {
- $joinClassName = $joinTable->getPhpName();
+ $joinClassName = $joinTable->getPhpName();
- $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
- $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
+ $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $script .= "
+ $script .= "
- /**
- * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table
- *
- * @param Criteria \$c
- * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
- * @param Connection \$con
- * @return int Number of matching rows.
- */
- public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, \$con = null)
- {
- // we're going to modify criteria, so copy it first
- \$criteria = clone \$criteria;
+ /**
+ * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table
+ *
+ * @param Criteria \$c
+ * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
+ * @param Connection \$con
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoin".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, \$con = null)
+ {
+ // we're going to modify criteria, so copy it first
+ \$criteria = clone \$criteria;
- // clear out anything that might confuse the ORDER BY clause
- \$criteria->clearSelectColumns()->clearOrderByColumns();
- if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
- } else {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
- }
+ // clear out anything that might confuse the ORDER BY clause
+ \$criteria->clearSelectColumns()->clearOrderByColumns();
+ if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
+ } else {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
+ }
- // just in case we're grouping: add those columns to the select statement
- foreach(\$criteria->getGroupByColumns() as \$column)
- {
- \$criteria->addSelectColumn(\$column);
- }
+ // just in case we're grouping: add those columns to the select statement
+ foreach(\$criteria->getGroupByColumns() as \$column)
+ {
+ \$criteria->addSelectColumn(\$column);
+ }
";
- $lfMap = $fk->getLocalForeignMapping();
- foreach ($fk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName] );
- $script .= "
- \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
+ $lfMap = $fk->getLocalForeignMapping();
+ foreach ($fk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName] );
+ $script .= "
+ \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
";
- }
- $script .= "
- \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
- if (\$rs->next()) {
- return \$rs->getInt(1);
- } else {
- // no rows returned; we infer that means 0 matches.
- return 0;
- }
- }
+ }
+ $script .= "
+ \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
+ if (\$rs->next()) {
+ return \$rs->getInt(1);
+ } else {
+ // no rows returned; we infer that means 0 matches.
+ return 0;
+ }
+ }
";
- } // if fk table name != this table name
- } // if ! is reference only
- } // foreach column
- } // if count(fk) > 1
+ } // if fk table name != this table name
+ } // if ! is reference only
+ } // foreach column
+ } // if count(fk) > 1
- } // addDoCountJoin()
+ } // addDoCountJoin()
- /**
- * Adds the doSelectJoinAll() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelectJoinAll(&$script)
- {
- $table = $this->getTable();
- $className = $table->getPhpName();
+ /**
+ * Adds the doSelectJoinAll() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelectJoinAll(&$script)
+ {
+ $table = $this->getTable();
+ $className = $table->getPhpName();
- $script .= "
+ $script .= "
- /**
- * Selects a collection of $className objects pre-filled with all related objects.
- *
- * @return array Array of $className objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAll(Criteria \$c, \$con = null)
- {
- \$c = clone \$c;
+ /**
+ * Selects a collection of $className objects pre-filled with all related objects.
+ *
+ * @return array Array of $className objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAll(Criteria \$c, \$con = null)
+ {
+ \$c = clone \$c;
- // Set the correct dbName if it has not been overridden
- if (\$c->getDbName() == Propel::getDefaultDB()) {
- \$c->setDbName(self::DATABASE_NAME);
- }
+ // Set the correct dbName if it has not been overridden
+ if (\$c->getDbName() == Propel::getDefaultDB()) {
+ \$c->setDbName(self::DATABASE_NAME);
+ }
- ".$this->getPeerClassname()."::addSelectColumns(\$c);
- \$startcol2 = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
+ ".$this->getPeerClassname()."::addSelectColumns(\$c);
+ \$startcol2 = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
";
- $index = 2;
- foreach ($table->getForeignKeys() as $fk) {
- // want to cover this case, but the code is not there yet.
- // FIXME: why "is the code not there yet" ?
- if ( $fk->getForeignTableName() != $table->getName() ) {
- $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- $joinClassName = $joinTable->getPhpName();
- $new_index = $index + 1;
+ $index = 2;
+ foreach ($table->getForeignKeys() as $fk) {
+ // want to cover this case, but the code is not there yet.
+ // FIXME: why "is the code not there yet" ?
+ if ( $fk->getForeignTableName() != $table->getName() ) {
+ $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $joinClassName = $joinTable->getPhpName();
+ $new_index = $index + 1;
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $script .= "
- ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
- \$startcol$new_index = \$startcol$index + ".$joinedTablePeerBuilder->getPeerClassname()."::NUM_COLUMNS;
+ $script .= "
+ ".$joinedTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
+ \$startcol$new_index = \$startcol$index + ".$joinedTablePeerBuilder->getPeerClassname()."::NUM_COLUMNS;
";
- $index = $new_index;
+ $index = $new_index;
- } // if fk->getForeignTableName != table->getName
- } // foreach [sub] foreign keys
+ } // if fk->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());
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ 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());
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $joinClassName = $joinTable->getPhpName();
- $lfMap = $fk->getLocalForeignMapping();
- foreach ($fk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
- $script .= "
- \$c->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
+ $joinClassName = $joinTable->getPhpName();
+ $lfMap = $fk->getLocalForeignMapping();
+ foreach ($fk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
+ $script .= "
+ \$c->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
";
- }
- }
- }
+ }
+ }
+ }
- $script .= "
- \$rs = ".$this->basePeerClassname."::doSelect(\$c, \$con);
- \$results = array();
+ $script .= "
+ \$rs = ".$this->basePeerClassname."::doSelect(\$c, \$con);
+ \$results = array();
- while(\$rs->next()) {
+ while(\$rs->next()) {
";
- if ($table->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
+ if ($table->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
";
- } else {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass();
";
- }
+ }
- $script .= "
+ $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj1 = new \$cls();
- \$obj1->hydrate(\$rs);
+ \$cls = Propel::import(\$omClass);
+ \$obj1 = new \$cls();
+ \$obj1->hydrate(\$rs);
";
- $index = 1;
- foreach ($table->getForeignKeys() as $fk ) {
+ $index = 1;
+ foreach ($table->getForeignKeys() as $fk ) {
- // want to cover this case, but the code is not there yet.
- // FIXME -- why not? -because we'd have to alias the tables in the JOIN
- if ( $fk->getForeignTableName() != $table->getName() ) {
+ // want to cover this case, but the code is not there yet.
+ // FIXME -- why not? -because we'd have to alias the tables in the JOIN
+ if ( $fk->getForeignTableName() != $table->getName() ) {
- $joinTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- $joinClassName = $joinTable->getPhpName();
- $interfaceName = $joinTable->getPhpName();
- if($joinTable->getInterface()) {
- $interfaceName = $joinTable->getInterface();
- }
+ $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();
- }
- }
+ /*
+ $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;
- }
- */
+ if ($partJoinName == "") {
+ $joinString = $interfaceName;
+ $collThisTable = "${className}s";
+ $collThisTableMs = $className;
+ } else {
+ $joinString= $interfaceName."RelatedBy" . $partJoinName;
+ $collThisTable= $className . "sRelatedBy" . $partJoinName;
+ $collThisTableMs= $className . "RelatedBy" . $partJoinName;
+ }
+ */
- $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
- $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
+ $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $index++;
+ $index++;
- $script .= "
+ $script .= "
- // Add objects for joined $joinClassName rows
- ";
- if ($joinTable->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol$index);
+ // Add objects for joined $joinClassName rows
+ ";
+ if ($joinTable->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol$index);
";
- } else {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
";
- } /* $joinTable->getChildrenColumn() */
+ } /* $joinTable->getChildrenColumn() */
- $script .= "
+ $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj".$index." = new \$cls();
- \$obj".$index."->hydrate(\$rs, \$startcol$index);
+ \$cls = Propel::import(\$omClass);
+ \$obj".$index." = new \$cls();
+ \$obj".$index."->hydrate(\$rs, \$startcol$index);
- \$newObject = true;
- for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) {
- \$temp_obj1 = \$results[\$j];
- \$temp_obj$index = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(); // CHECKME
- if (\$temp_obj".$index."->getPrimaryKey() === \$obj".$index."->getPrimaryKey()) {
- \$newObject = false;
- \$temp_obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); // CHECKME
- break;
- }
- }
+ \$newObject = true;
+ for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) {
+ \$temp_obj1 = \$results[\$j];
+ \$temp_obj$index = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(); // CHECKME
+ if (\$temp_obj".$index."->getPrimaryKey() === \$obj".$index."->getPrimaryKey()) {
+ \$newObject = false;
+ \$temp_obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1); // CHECKME
+ break;
+ }
+ }
- if (\$newObject) {
- \$obj".$index."->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = true)."();
- \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1);
- }
+ if (\$newObject) {
+ \$obj".$index."->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = true)."();
+ \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($fk, $plural = false)."(\$obj1);
+ }
";
- } // $fk->getForeignTableName() != $table->getName()
- } //foreach foreign key
+ } // $fk->getForeignTableName() != $table->getName()
+ } //foreach foreign key
- $script .= "
- \$results[] = \$obj1;
- }
- return \$results;
- }
+ $script .= "
+ \$results[] = \$obj1;
+ }
+ return \$results;
+ }
";
- } // end addDoSelectJoinAll()
+ } // end addDoSelectJoinAll()
- /**
- * Adds the doCountJoinAll() method.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoCountJoinAll(&$script)
- {
- $table = $this->getTable();
- $className = $table->getPhpName();
+ /**
+ * Adds the doCountJoinAll() method.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoCountJoinAll(&$script)
+ {
+ $table = $this->getTable();
+ $className = $table->getPhpName();
- $script .= "
+ $script .= "
- /**
- * Returns the number of rows matching criteria, joining all related tables
- *
- * @param Criteria \$c
- * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
- * @param Connection \$con
- * @return int Number of matching rows.
- */
- public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, \$con = null)
- {
- \$criteria = clone \$criteria;
+ /**
+ * Returns the number of rows matching criteria, joining all related tables
+ *
+ * @param Criteria \$c
+ * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
+ * @param Connection \$con
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, \$con = null)
+ {
+ \$criteria = clone \$criteria;
- // clear out anything that might confuse the ORDER BY clause
- \$criteria->clearSelectColumns()->clearOrderByColumns();
- if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
- } else {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
- }
+ // clear out anything that might confuse the ORDER BY clause
+ \$criteria->clearSelectColumns()->clearOrderByColumns();
+ if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
+ } else {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
+ }
- // just in case we're grouping: add those columns to the select statement
- foreach(\$criteria->getGroupByColumns() as \$column)
- {
- \$criteria->addSelectColumn(\$column);
- }
+ // just in case we're grouping: add those columns to the select statement
+ foreach(\$criteria->getGroupByColumns() as \$column)
+ {
+ \$criteria->addSelectColumn(\$column);
+ }
";
- 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());
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ 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());
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $joinClassName = $joinTable->getPhpName();
- $lfMap = $fk->getLocalForeignMapping();
- foreach ($fk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
- $script .= "
- \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
+ $joinClassName = $joinTable->getPhpName();
+ $lfMap = $fk->getLocalForeignMapping();
+ foreach ($fk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
+ $script .= "
+ \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinedTablePeerBuilder->getColumnConstant($columnFk).");
";
- }
- } // if fk->getForeignTableName != table->getName
- } // foreach [sub] foreign keys
+ }
+ } // if fk->getForeignTableName != table->getName
+ } // foreach [sub] foreign keys
- $script .= "
- \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
- if (\$rs->next()) {
- return \$rs->getInt(1);
- } else {
- // no rows returned; we infer that means 0 matches.
- return 0;
- }
- }
+ $script .= "
+ \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
+ if (\$rs->next()) {
+ return \$rs->getInt(1);
+ } else {
+ // no rows returned; we infer that means 0 matches.
+ return 0;
+ }
+ }
";
- } // end addDoCountJoinAll()
+ } // end addDoCountJoinAll()
- /**
- * Adds the doSelectJoinAllExcept*() methods.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoSelectJoinAllExcept(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the doSelectJoinAllExcept*() methods.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoSelectJoinAllExcept(&$script)
+ {
+ $table = $this->getTable();
- // ------------------------------------------------------------------------
- // doSelectJoinAllExcept*()
- // ------------------------------------------------------------------------
+ // ------------------------------------------------------------------------
+ // doSelectJoinAllExcept*()
+ // ------------------------------------------------------------------------
- // 2) create a bunch of doSelectJoinAllExcept*() methods
- // -- these were existing in original Torque, so we should keep them for compatibility
+ // 2) create a bunch of doSelectJoinAllExcept*() methods
+ // -- these were existing in original Torque, so we should keep them for compatibility
- $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over
- // getForeignKeys() will cause this to only execute one time.
- foreach ($fkeys as $fk ) {
+ $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over
+ // getForeignKeys() will cause this to only execute one time.
+ foreach ($fkeys as $fk ) {
- $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
- $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- $excludedClassName = $excludedTable->getPhpName();
+ $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $excludedClassName = $excludedTable->getPhpName();
- /*
- $relatedByCol = "";
- foreach ($fk->getLocalColumns() as $columnName) {
- $column = $table->getColumn($columnName);
- if ($column->isMultipleFK()) {
- $relatedByCol .= $column->getPhpName();
- }
- }
+ /*
+ $relatedByCol = "";
+ foreach ($fk->getLocalColumns() as $columnName) {
+ $column = $table->getColumn($columnName);
+ if ($column->isMultipleFK()) {
+ $relatedByCol .= $column->getPhpName();
+ }
+ }
- if ($relatedByCol == "") {
- $excludeString = $excludedClassName;
- $collThisTable = "${className}s";
- $collThisTableMs = $className;
- } else {
- $excludeString = $excludedClassName . "RelatedBy" . $relatedByCol;
- $collThisTable = $className . "sRelatedBy" . $relatedByCol;
- $collThisTableMs = $className . "RelatedBy" . $relatedByCol;
- }
- */
+ if ($relatedByCol == "") {
+ $excludeString = $excludedClassName;
+ $collThisTable = "${className}s";
+ $collThisTableMs = $className;
+ } else {
+ $excludeString = $excludedClassName . "RelatedBy" . $relatedByCol;
+ $collThisTable = $className . "sRelatedBy" . $relatedByCol;
+ $collThisTableMs = $className . "RelatedBy" . $relatedByCol;
+ }
+ */
- $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
- $excludedTableObjectBuilder = OMBuilder::getNewObjectBuilder($excludedTable);
- $excludedTablePeerBuilder = OMBuilder::getNewPeerBuilder($excludedTable);
+ $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
+ $excludedTableObjectBuilder = OMBuilder::getNewObjectBuilder($excludedTable);
+ $excludedTablePeerBuilder = OMBuilder::getNewPeerBuilder($excludedTable);
- $script .= "
+ $script .= "
- /**
- * Selects a collection of ".$table->getPhpName()." objects pre-filled with all related objects except ".$thisTableObjectBuilder->getFKPhpNameAffix($fk).".
- *
- * @return array Array of ".$table->getPhpName()." objects.
- * @throws PropelException Any exceptions caught during processing will be
- * rethrown wrapped into a PropelException.
- */
- public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, \$con = null)
- {
- \$c = clone \$c;
+ /**
+ * Selects a collection of ".$table->getPhpName()." objects pre-filled with all related objects except ".$thisTableObjectBuilder->getFKPhpNameAffix($fk).".
+ *
+ * @return array Array of ".$table->getPhpName()." objects.
+ * @throws PropelException Any exceptions caught during processing will be
+ * rethrown wrapped into a PropelException.
+ */
+ public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, \$con = null)
+ {
+ \$c = clone \$c;
- // Set the correct dbName if it has not been overridden
- // \$c->getDbName() will return the same object if not set to another value
- // so == check is okay and faster
- if (\$c->getDbName() == Propel::getDefaultDB()) {
- \$c->setDbName(self::DATABASE_NAME);
- }
+ // Set the correct dbName if it has not been overridden
+ // \$c->getDbName() will return the same object if not set to another value
+ // so == check is okay and faster
+ if (\$c->getDbName() == Propel::getDefaultDB()) {
+ \$c->setDbName(self::DATABASE_NAME);
+ }
- ".$this->getPeerClassname()."::addSelectColumns(\$c);
- \$startcol2 = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
+ ".$this->getPeerClassname()."::addSelectColumns(\$c);
+ \$startcol2 = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;
";
- $index = 2;
- foreach ($table->getForeignKeys() as $subfk) {
- // want to cover this case, but the code is not there yet.
- // FIXME - why not?
- if ( !($subfk->getForeignTableName() == $table->getName())) {
- $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
- $joinClassName = $joinTable->getPhpName();
- $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $index = 2;
+ foreach ($table->getForeignKeys() as $subfk) {
+ // want to cover this case, but the code is not there yet.
+ // FIXME - why not?
+ if ( !($subfk->getForeignTableName() == $table->getName())) {
+ $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
+ $joinClassName = $joinTable->getPhpName();
+ $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- if ($joinClassName != $excludedClassName) {
- $new_index = $index + 1;
- $script .= "
- ".$joinTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
- \$startcol$new_index = \$startcol$index + ".$joinTablePeerBuilder->getPeerClassname()."::NUM_COLUMNS;
+ if ($joinClassName != $excludedClassName) {
+ $new_index = $index + 1;
+ $script .= "
+ ".$joinTablePeerBuilder->getPeerClassname()."::addSelectColumns(\$c);
+ \$startcol$new_index = \$startcol$index + ".$joinTablePeerBuilder->getPeerClassname()."::NUM_COLUMNS;
";
- $index = $new_index;
- } // if joinClassName not excludeClassName
- } // if subfk is not curr table
- } // foreach [sub] foreign keys
+ $index = $new_index;
+ } // if joinClassName not excludeClassName
+ } // if subfk is not curr table
+ } // foreach [sub] foreign keys
- foreach ($table->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();
- $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ foreach ($table->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();
+ $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- if($joinClassName != $excludedClassName)
- {
- $lfMap = $subfk->getLocalForeignMapping();
- foreach ($subfk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
- $script .= "
- \$c->addJoin(".$this->getColumnConstant($column).", ".$joinTablePeerBuilder->getColumnConstant($columnFk).");
+ if($joinClassName != $excludedClassName)
+ {
+ $lfMap = $subfk->getLocalForeignMapping();
+ foreach ($subfk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
+ $script .= "
+ \$c->addJoin(".$this->getColumnConstant($column).", ".$joinTablePeerBuilder->getColumnConstant($columnFk).");
";
- }
- }
- }
- } // foreach fkeys
- $script .= "
+ }
+ }
+ }
+ } // foreach fkeys
+ $script .= "
- \$rs = ".$this->basePeerClassname ."::doSelect(\$c, \$con);
- \$results = array();
+ \$rs = ".$this->basePeerClassname ."::doSelect(\$c, \$con);
+ \$results = array();
- while(\$rs->next()) {
+ while(\$rs->next()) {
";
- if ($table->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
+ if ($table->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass(\$rs, 1);
";
- } else {
- $script .= "
- \$omClass = ".$this->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$this->getPeerClassname()."::getOMClass();
";
- }
+ }
- $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj1 = new \$cls();
- \$obj1->hydrate(\$rs);
+ $script .= "
+ \$cls = Propel::import(\$omClass);
+ \$obj1 = new \$cls();
+ \$obj1->hydrate(\$rs);
";
- $index = 1;
- foreach ($table->getForeignKeys() as $subfk ) {
- // want to cover this case, but the code is not there yet.
- if ( $subfk->getForeignTableName() != $table->getName() ) {
+ $index = 1;
+ foreach ($table->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();
- }
+ $joinTable = $table->getDatabase()->getTable($subfk->getForeignTableName());
+ $joinClassName = $joinTable->getPhpName();
+ $interfaceName = $joinTable->getPhpName();
+ if($joinTable->getInterface()) {
+ $interfaceName = $joinTable->getInterface();
+ }
- if ($joinClassName != $excludedClassName) {
+ if ($joinClassName != $excludedClassName) {
- /*
- $partJoinName = "";
- foreach ($subfk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- if ($column->isMultipleFK()) {
- $partJoinName .= $column->getPhpName();
- }
- }
+ /*
+ $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;
- }
- */
+ if ($partJoinName == "") {
+ $joinString = $interfaceName;
+ $collThisTable = "${className}s";
+ $collThisTableMs = $className;
+ } else {
+ $joinString= $interfaceName."RelatedBy" . $partJoinName;
+ $collThisTable= $className . "sRelatedBy" . $partJoinName;
+ $collThisTableMs= $className . "RelatedBy" . $partJoinName;
+ }
+ */
- $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
- $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ $joinedTableObjectBuilder = OMBuilder::getNewObjectBuilder($joinTable);
+ $joinedTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- $index++;
+ $index++;
- if ($joinTable->getChildrenColumn()) {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol$index);
+ if ($joinTable->getChildrenColumn()) {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$rs, \$startcol$index);
";
- } else {
- $script .= "
- \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
+ } else {
+ $script .= "
+ \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();
";
- } /* $joinTable->getChildrenColumn() */
+ } /* $joinTable->getChildrenColumn() */
- $script .= "
+ $script .= "
- \$cls = Propel::import(\$omClass);
- \$obj$index = new \$cls();
- \$obj".$index."->hydrate(\$rs, \$startcol$index);
+ \$cls = Propel::import(\$omClass);
+ \$obj$index = new \$cls();
+ \$obj".$index."->hydrate(\$rs, \$startcol$index);
- \$newObject = true;
- for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) {
- \$temp_obj1 = \$results[\$j];
- \$temp_obj$index = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($subfk, $plural=false)."(); //CHECKME
- if (\$temp_obj".$index."->getPrimaryKey() === \$obj".$index."->getPrimaryKey()) {
- \$newObject = false;
- \$temp_obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=false)."(\$obj1);
- break;
- }
- }
+ \$newObject = true;
+ for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) {
+ \$temp_obj1 = \$results[\$j];
+ \$temp_obj$index = \$temp_obj1->get".$thisTableObjectBuilder->getFKPhpNameAffix($subfk, $plural=false)."(); //CHECKME
+ if (\$temp_obj".$index."->getPrimaryKey() === \$obj".$index."->getPrimaryKey()) {
+ \$newObject = false;
+ \$temp_obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=false)."(\$obj1);
+ break;
+ }
+ }
- if (\$newObject) {
- \$obj".$index."->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=true)."();
- \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=false)."(\$obj1);
- }
+ if (\$newObject) {
+ \$obj".$index."->init".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=true)."();
+ \$obj".$index."->add".$joinedTableObjectBuilder->getRefFKPhpNameAffix($subfk, $plural=false)."(\$obj1);
+ }
";
- } // if ($joinClassName != $excludedClassName) {
- } // $subfk->getForeignTableName() != $table->getName()
- } // foreach
- $script .= "
- \$results[] = \$obj1;
- }
- return \$results;
- }
+ } // if ($joinClassName != $excludedClassName) {
+ } // $subfk->getForeignTableName() != $table->getName()
+ } // foreach
+ $script .= "
+ \$results[] = \$obj1;
+ }
+ return \$results;
+ }
";
- } // foreach fk
+ } // foreach fk
- } // addDoSelectJoinAllExcept
+ } // addDoSelectJoinAllExcept
- /**
- * Adds the doCountJoinAllExcept*() methods.
- * @param string &$script The script will be modified in this method.
- */
- protected function addDoCountJoinAllExcept(&$script)
- {
- $table = $this->getTable();
+ /**
+ * Adds the doCountJoinAllExcept*() methods.
+ * @param string &$script The script will be modified in this method.
+ */
+ protected function addDoCountJoinAllExcept(&$script)
+ {
+ $table = $this->getTable();
- $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over
- // getForeignKeys() will cause this to only execute one time.
- foreach ($fkeys as $fk ) {
+ $fkeys = $table->getForeignKeys(); // this sep assignment is necessary otherwise sub-loops over
+ // getForeignKeys() will cause this to only execute one time.
+ foreach ($fkeys as $fk ) {
- $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $tblFK = $table->getDatabase()->getTable($fk->getForeignTableName());
- $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());
- $excludedClassName = $excludedTable->getPhpName();
+ $excludedTable = $table->getDatabase()->getTable($fk->getForeignTableName());
+ $excludedClassName = $excludedTable->getPhpName();
- $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
- $excludedTableObjectBuilder = OMBuilder::getNewObjectBuilder($excludedTable);
- $excludedTablePeerBuilder = OMBuilder::getNewPeerBuilder($excludedTable);
+ $thisTableObjectBuilder = OMBuilder::getNewObjectBuilder($table);
+ $excludedTableObjectBuilder = OMBuilder::getNewObjectBuilder($excludedTable);
+ $excludedTablePeerBuilder = OMBuilder::getNewPeerBuilder($excludedTable);
- $script .= "
+ $script .= "
- /**
- * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table
- *
- * @param Criteria \$c
- * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
- * @param Connection \$con
- * @return int Number of matching rows.
- */
- public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, \$con = null)
- {
- // we're going to modify criteria, so copy it first
- \$criteria = clone \$criteria;
+ /**
+ * Returns the number of rows matching criteria, joining the related ".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)." table
+ *
+ * @param Criteria \$c
+ * @param boolean \$distinct Whether to select only distinct columns (You can also set DISTINCT modifier in Criteria).
+ * @param Connection \$con
+ * @return int Number of matching rows.
+ */
+ public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, \$con = null)
+ {
+ // we're going to modify criteria, so copy it first
+ \$criteria = clone \$criteria;
- // clear out anything that might confuse the ORDER BY clause
- \$criteria->clearSelectColumns()->clearOrderByColumns();
- if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
- } else {
- \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
- }
+ // clear out anything that might confuse the ORDER BY clause
+ \$criteria->clearSelectColumns()->clearOrderByColumns();
+ if (\$distinct || in_array(Criteria::DISTINCT, \$criteria->getSelectModifiers())) {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT_DISTINCT);
+ } else {
+ \$criteria->addSelectColumn(".$this->getPeerClassname()."::COUNT);
+ }
- // just in case we're grouping: add those columns to the select statement
- foreach(\$criteria->getGroupByColumns() as \$column)
- {
- \$criteria->addSelectColumn(\$column);
- }
+ // just in case we're grouping: add those columns to the select statement
+ foreach(\$criteria->getGroupByColumns() as \$column)
+ {
+ \$criteria->addSelectColumn(\$column);
+ }
";
- foreach ($table->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();
- $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
+ foreach ($table->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();
+ $joinTablePeerBuilder = OMBuilder::getNewPeerBuilder($joinTable);
- if($joinClassName != $excludedClassName)
- {
- $lfMap = $subfk->getLocalForeignMapping();
- foreach ($subfk->getLocalColumns() as $columnName ) {
- $column = $table->getColumn($columnName);
- $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
- $script .= "
- \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinTablePeerBuilder->getColumnConstant($columnFk).");
+ if($joinClassName != $excludedClassName)
+ {
+ $lfMap = $subfk->getLocalForeignMapping();
+ foreach ($subfk->getLocalColumns() as $columnName ) {
+ $column = $table->getColumn($columnName);
+ $columnFk = $joinTable->getColumn( $lfMap[$columnName]);
+ $script .= "
+ \$criteria->addJoin(".$this->getColumnConstant($column).", ".$joinTablePeerBuilder->getColumnConstant($columnFk).");
";
- }
- }
- }
- } // foreach fkeys
- $script .= "
- \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
- if (\$rs->next()) {
- return \$rs->getInt(1);
- } else {
- // no rows returned; we infer that means 0 matches.
- return 0;
- }
- }
+ }
+ }
+ }
+ } // foreach fkeys
+ $script .= "
+ \$rs = ".$this->getPeerClassname()."::doSelectRS(\$criteria, \$con);
+ if (\$rs->next()) {
+ return \$rs->getInt(1);
+ } else {
+ // no rows returned; we infer that means 0 matches.
+ return 0;
+ }
+ }
";
- } // foreach fk
+ } // foreach fk
- } // addDoCountJoinAllExcept
+ } // addDoCountJoinAllExcept
} // PHP5ComplexPeerBuilder