Changeset 423
- Timestamp:
- 11.07.2006 21:00:11 (4 years ago)
- Location:
- trunk/generator/classes/propel/engine/builder/om
- Files:
-
- 3 modified
-
OMBuilder.php (modified) (2 diffs)
-
php5/PHP5BasicPeerBuilder.php (modified) (3 diffs)
-
php5/PHP5ExtensionPeerBuilder.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/generator/classes/propel/engine/builder/om/OMBuilder.php
r186 r423 357 357 * 358 358 * @param Column $col The column we need a name for. 359 * @param string $ phpName The PHP Name of the peer class. The 'Peer' is appended automatically.359 * @param string $classname The Peer classname to use. 360 360 * 361 * @return string If $ phpName is provided, then will return {$phpName}Peer::COLUMN_NAME; if not, then uses current tableCOLUMN_NAME.361 * @return string If $classname is provided, then will return $classname::COLUMN_NAME; if not, then the peername is looked up for current table to yield $currTablePeer::COLUMN_NAME. 362 362 */ 363 public function getColumnConstant($col, $ phpName = null)363 public function getColumnConstant($col, $classname = null) 364 364 { 365 365 if ($col === null) { … … 368 368 throw $e; 369 369 } 370 $classname = $this->getPeerClassname($phpName); 370 371 if ($classname === null) { 372 $classname = $this->getPeerClassname(); 373 } 371 374 372 375 // was it overridden in schema.xml ? -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php
r417 r423 118 118 } // " . $this->getClassname() . " 119 119 "; 120 } 120 $this->addStaticMapBuilderRegistration($script); 121 } 122 123 /** 124 * Adds the static map builder registration code. 125 * @param string &$script The script will be modified in this method. 126 */ 127 protected function addStaticMapBuilderRegistration(&$script) 128 { 129 $table = $this->getTable(); 130 $mapBuilderFile = $this->getMapBuilderBuilder()->getClassFilePath(); 131 132 $script .= " 133 // This is the static code needed to register the MapBuilder for this table with the main Propel class. 134 // 135 // NOTE: This static code cannot call methods on the ".$this->getPeerClassname()." class, because it is not defined yet. 136 // If you need to use overridden methods, you can add this code to the bottom of the ".$this->getPeerClassname()." class: 137 // 138 // Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME)->addTableBuilder(".$this->getPeerClassname()."::TABLE_NAME, ".$this->getPeerClassname()."::getMapBuilder()); 139 // 140 // Doing so will effectively overwrite the registration below. 141 142 Propel::getDatabaseMap(".$this->getClassname()."::DATABASE_NAME)->addTableBuilder(".$this->getClassname()."::TABLE_NAME, ".$this->getClassname()."::getMapBuilder()); 143 144 "; 145 } 146 121 147 122 148 /** … … 208 234 BasePeer::TYPE_COLNAME => array ("; 209 235 foreach ($tableColumns as $col) { 210 $script .= $this->getColumnConstant($col ).", ";236 $script .= $this->getColumnConstant($col, 'self').", "; 211 237 } 212 238 $script .= "), … … 247 273 BasePeer::TYPE_COLNAME => array ("; 248 274 foreach ($tableColumns as $num => $col) { 249 $script .= $this->getColumnConstant($col )." => $num, ";275 $script .= $this->getColumnConstant($col, 'self')." => $num, "; 250 276 } 251 277 $script .= "), -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5ExtensionPeerBuilder.php
r372 r423 123 123 } // " . $this->getClassname() . " 124 124 "; 125 $this->addStaticMapBuilderRegistration($script);126 125 } 127 126 128 /**129 * Adds the static map builder registration code.130 * @param string &$script The script will be modified in this method.131 */132 protected function addStaticMapBuilderRegistration(&$script)133 {134 $table = $this->getTable();135 $mapBuilderFile = $this->getMapBuilderBuilder()->getClassFilePath();136 137 $script .= "138 // static code to register the map builder for this table with the main Propel class139 try {140 Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME)->addTableBuilder(".$this->getPeerClassname()."::TABLE_NAME, ".$this->getPeerClassname()."::getMapBuilder());141 } catch (Exception \$e) {142 Propel::log('Could not register MapBuilder for ".$this->getPeerClassname()." with Propel: ' . \$e->getMessage(), Propel::LOG_ERR);143 }144 ";145 }146 127 147 128 } // PHP5ExtensionPeerBuilder