Changeset 7200
- Timestamp:
- 01/28/08 02:00:36 (10 months ago)
- Files:
-
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php (modified) (5 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/ClassTools.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/OMBuilder.php (modified) (3 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5PeerBuilder.php (modified) (2 diffs)
- branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/propel/builder/SfPeerBuilder.php
r7161 r7200 114 114 foreach ($tblFK->getColumns() as $col) 115 115 { 116 if (( "true" === strtolower($col->getAttribute('isCulture'))))116 if (('true' == trim(strtolower($col->getAttribute('isCulture'))))) 117 117 { 118 118 $culturePhpName = $col->getPhpName(); … … 160 160 161 161 ".$this->getPeerClassname()."::addSelectColumns(\$c); 162 \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS) + 1;162 \$startcol = (".$this->getPeerClassname()."::NUM_COLUMNS - ".$this->getPeerClassname()."::NUM_LAZY_LOAD_COLUMNS); 163 163 164 164 ".$i18nPeerClassName."::addSelectColumns(\$c); … … 167 167 \$c->add(".$cultureColumnName.", \$culture); 168 168 169 \$stmt = ".$this->basePeerClassname."::doSelect Stmt(\$c, \$con);169 \$stmt = ".$this->basePeerClassname."::doSelect(\$c, \$con); 170 170 \$results = array(); 171 171 … … 174 174 if ($table->getChildrenColumn()) { 175 175 $script .= " 176 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 1);176 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, \$startcol); 177 177 "; 178 178 } else { … … 182 182 } 183 183 $script .= " 184 \$cls = Propel::import (\$omClass);184 \$cls = Propel::importClass(\$omClass); 185 185 \$obj1 = new \$cls(); 186 186 \$obj1->hydrate(\$row); 187 187 \$obj1->setCulture(\$culture); 188 188 "; 189 //if ($i18nTable->getChildrenColumn()) {189 if ($i18nTable->getChildrenColumn()) { 190 190 $script .= " 191 191 \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol); 192 192 "; 193 //} else {194 //$script .= "195 //\$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass();196 //";197 //}193 } else { 194 $script .= " 195 \$omClass = ".$i18nTablePeerBuilder->getPeerClassname()."::getOMClass(); 196 "; 197 } 198 198 199 199 $script .= " 200 \$cls = Propel::import (\$omClass);200 \$cls = Propel::importClass(\$omClass); 201 201 \$obj2 = new \$cls(); 202 202 \$obj2->hydrate(\$row, \$startcol); branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/ClassTools.php
r5248 r7200 1 1 <?php 2 2 /* 3 * $Id: ClassTools.php 521 2007-01-05 13:29:36Z heltem$3 * $Id: ClassTools.php 942 2008-01-27 21:08:52Z hans $ 4 4 * 5 5 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 25 25 * 26 26 * @author Hans Lellelid <hans@xmpl.org> 27 * @version $Revision: 521$27 * @version $Revision: 942 $ 28 28 * @package propel.engine.builder.om 29 29 */ … … 105 105 return $interface; 106 106 } 107 108 /** 109 * Gets a list of PHP reserved words. 110 * 111 * @return array string[] 112 */ 113 public static function getPhpReservedWords() 114 { 115 return array( 116 'and', 'or', 'xor', 'exception', '__FILE__', '__LINE__', 117 'array', 'as', 'break', 'case', 'class', 'const', 'continue', 118 'declare', 'default', 'die', 'do', 'echo', 'else', 'elseif', 'empty', 119 'enddeclare', 'endfor', 'endforeach', 'endif', 'endswitch', 'endwhile', 120 'eval', 'exit', 'extends', 'for', 'foreach', 'function', 'global', 121 'if', 'include', 'include_once', 'isset', 'list', 'new', 'print', 'require', 122 'require_once', 'return', 'static', 'switch', 'unset', 'use', 'var', 'while', 123 '__FUNCTION__', '__CLASS__', '__METHOD__', 'final', 'php_user_filter', 'interface', 124 'implements', 'extends', 'public', 'protected', 'private', 'abstract', 'clone', 'try', 'catch', 125 'throw', 'this', 'namespace' 126 ); 127 } 107 128 } branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/OMBuilder.php
r6294 r7200 2 2 3 3 /* 4 * $Id: OMBuilder.php 842 2007-12-02 16:28:20Z heltem$4 * $Id: OMBuilder.php 942 2008-01-27 21:08:52Z hans $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 325 325 public function build() 326 326 { 327 $this->validateModel(); 328 327 329 $script = "<" . "?php\n"; // intentional concatenation 328 330 $this->addIncludes($script); … … 332 334 return $script; 333 335 } 334 336 337 /** 338 * Validates the current table to make sure that it won't 339 * result in generated code that will not parse. 340 * 341 * This method may emit warnings for code which may cause problems 342 * and will throw exceptions for errors that will definitely cause 343 * problems. 344 */ 345 protected function validateModel() 346 { 347 // Validation is currently only implemented in the subclasses. 348 } 349 335 350 /** 336 351 * Creates a $obj = new Book(); code snippet. Can be used by frameworks, for instance, to branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5ObjectBuilder.php
r7119 r7200 2 2 3 3 /* 4 * $Id: PHP5ObjectBuilder.php 9 29 2008-01-18 15:17:50Z hans $4 * $Id: PHP5ObjectBuilder.php 942 2008-01-27 21:08:52Z hans $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 51 51 return $this->getBuildProperty('basePrefix') . $this->getStubObjectBuilder()->getUnprefixedClassname(); 52 52 } 53 53 54 /** 55 * Validates the current table to make sure that it won't 56 * result in generated code that will not parse. 57 * 58 * This method may emit warnings for code which may cause problems 59 * and will throw exceptions for errors that will definitely cause 60 * problems. 61 */ 62 protected function validateModel() 63 { 64 parent::validateModel(); 65 66 $table = $this->getTable(); 67 68 // Check to see whether any generated foreign key names 69 // will conflict with column names. 70 71 $colPhpNames = array(); 72 $fkPhpNames = array(); 73 74 foreach($table->getColumns() as $col) { 75 $colPhpNames[] = $col->getPhpName(); 76 } 77 78 foreach($table->getForeignKeys() as $fk) { 79 $fkPhpNames[] = $this->getFKPhpNameAffix($fk, $plural = false); 80 } 81 82 $intersect = array_intersect($colPhpNames, $fkPhpNames); 83 if (!empty($intersect)) { 84 throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with foreign key names (" . implode(", ", $intersect) . ")"); 85 } 86 87 // Check foreign keys to see if there are any foreign keys that 88 // are also matched with an inversed referencing foreign key 89 // (this is currently unsupported behavior) 90 // see: http://propel.phpdb.org/trac/ticket/549 91 92 foreach($table->getForeignKeys() as $fk) { 93 if ($fk->isMatchedByInverseFK()) { 94 throw new EngineException("The 1:1 relationship expressed by foreign key " . $fk->getName() . " is defined in both directions; Propel does not currently support this (if you must have both foreign key constraints, consider adding this constraint with a custom SQL file.)" ); 95 } 96 } 97 } 98 54 99 /** 55 100 * Returns the appropriate formatter (from platform) for a date/time column. branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/builder/om/php5/PHP5PeerBuilder.php
r7195 r7200 2 2 3 3 /* 4 * $Id: PHP5PeerBuilder.php 9 39 2008-01-25 14:19:29Z hans $4 * $Id: PHP5PeerBuilder.php 942 2008-01-27 21:08:52Z hans $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 34 34 class PHP5PeerBuilder extends PeerBuilder { 35 35 36 /** 37 * Validates the current table to make sure that it won't 38 * result in generated code that will not parse. 39 * 40 * This method may emit warnings for code which may cause problems 41 * and will throw exceptions for errors that will definitely cause 42 * problems. 43 */ 44 protected function validateModel() 45 { 46 parent::validateModel(); 47 48 $table = $this->getTable(); 49 50 // Check to see if any of the column constants are PHP reserved words. 51 $colConstants = array(); 52 53 foreach($table->getColumns() as $col) { 54 $colConstants[] = $this->getColumnName($col); 55 } 56 57 $reservedConstants = array_map('strtoupper', ClassTools::getPhpReservedWords()); 58 59 $intersect = array_intersect($reservedConstants, $colConstants); 60 if (!empty($intersect)) { 61 throw new EngineException("One or more of your column names for [" . $table->getName() . "] table conflict with a PHP reserved word (" . implode(", ", $intersect) . ")"); 62 } 63 } 64 36 65 /** 37 66 * Returns the name of the current class being built. branches/dwhittle/1.1/lib/plugins/sfPropelPlugin/lib/vendor/propel-generator/classes/propel/engine/database/model/Table.php
r7042 r7200 2 2 3 3 /* 4 * $Id: Table.php 9 08 2008-01-10 15:48:59Z hans $4 * $Id: Table.php 942 2008-01-27 21:08:52Z hans $ 5 5 * 6 6 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS … … 41 41 * @author Daniel Rall <dlr@collab.net> (Torque) 42 42 * @author Byron Foster <byron_foster@yahoo.com> (Torque) 43 * @version $Revision: 9 08$43 * @version $Revision: 942 $ 44 44 * @package propel.engine.database.model 45 45 */ … … 790 790 /** 791 791 * Returns an Array containing all the columns in the table 792 * @return array Column[] 792 793 */ 793 794 public function getColumns() … … 820 821 /** 821 822 * Returns an Array containing all the validators in the table 823 * @return array Validator[] 822 824 */ 823 825 public function getValidators() … … 827 829 828 830 /** 829 * Returns an Array containing all the FKs in the table 831 * Returns an Array containing all the FKs in the table. 832 * @return array ForeignKey[] 830 833 */ 831 834 public function getForeignKeys()