Changeset 409
- Timestamp:
- 15.06.2006 21:40:50 (4 years ago)
- Location:
- trunk/generator/classes/propel/engine
- Files:
-
- 7 modified
-
builder/om/PeerBuilder.php (modified) (1 diff)
-
builder/om/php5/PHP5BasicObjectBuilder.php (modified) (5 diffs)
-
builder/om/php5/PHP5BasicPeerBuilder.php (modified) (7 diffs)
-
builder/om/php5/PHP5ComplexObjectBuilder.php (modified) (7 diffs)
-
builder/om/php5/PHP5ComplexPeerBuilder.php (modified) (9 diffs)
-
database/model/ForeignKey.php (modified) (2 diffs)
-
database/model/Table.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/generator/classes/propel/engine/builder/om/PeerBuilder.php
r387 r409 56 56 $this->addDoCount($script); 57 57 58 // consider refactoring the doSelect stuff 59 // into a top-level method 58 // TODO - consider refactoring the doSelect stuff into a top-level method 60 59 $this->addDoSelectOne($script); 61 60 $this->addDoSelect($script); 62 $this->addDoSelectRS($script); // <-- there's Creole code in here63 $this->add PopulateObjects($script); // <-- there's Creole code in here64 61 $this->addDoSelectRS($script); 62 $this->addGetPrimaryKeyHash($script); 63 $this->addPopulateObjects($script); 65 64 } 66 65 -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5BasicObjectBuilder.php
r387 r409 321 321 */ 322 322 public function get$cfc(\$format = ".var_export($defaultfmt, true).""; 323 if ($col->isLazyLoad()) $script .= ", \$con = null";323 if ($col->isLazyLoad()) $script .= ", PDO \$con = null"; 324 324 $script .= ") 325 325 { … … 373 373 */ 374 374 public function get$cfc("; 375 if ($col->isLazyLoad()) $script .= " \$con = null";375 if ($col->isLazyLoad()) $script .= "PDO \$con = null"; 376 376 $script .= ") 377 377 { … … 413 413 * @throws PropelException - any underlying error will be wrapped and re-thrown. 414 414 */ 415 protected function load$cfc( \$con = null)415 protected function load$cfc(PDO \$con = null) 416 416 { 417 417 \$c = \$this->buildPkeyCriteria(); … … 909 909 * @see BaseObject::isDeleted() 910 910 */ 911 public function delete( \$con = null)911 public function delete(PDO \$con = null) 912 912 { 913 913 if (\$this->isDeleted()) { … … 970 970 * @throws PropelException 971 971 */ 972 public function save( \$con = null)972 public function save(PDO \$con = null) 973 973 { 974 974 \$affectedRows = 0; // initialize var to track total num of affected rows -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5BasicPeerBuilder.php
r398 r409 151 151 $script .= " 152 152 /** 153 * An identiy map to hold any loaded instances of ".$this->getObjectClassname()." objects. 154 * This must be public so that other peer classes can access this when hydrating from JOIN 155 * queries. 156 * @var array ".$this->getObjectClassname()."[] 157 */ 158 public static \$instances = array(); 159 160 /** 153 161 * The MapBuilder instance for this peer. 154 162 * @var MapBuilder 155 163 */ 156 private static \$mapBuilder = null; 157 "; 158 164 private static \$mapBuilder = null; 165 166 "; 167 159 168 $this->addFieldNamesAttribute($script); 160 169 $this->addFieldKeysAttribute($script); … … 499 508 * @param object \$queryOrCriteria Query or Criteria object used to create the SELECT statement. 500 509 * @param PDO \$con 501 * @return ".$this->get Table()->getPhpName()."510 * @return ".$this->getObjectClassname()." 502 511 * @throws PropelException Any exceptions caught during processing will be 503 512 * rethrown wrapped into a PropelException. … … 586 595 // BasePeer returns a PDOStatement 587 596 return ".$this->basePeerClassname."::doSelect(\$query, \$con); 588 }"; 589 } 590 597 } 598 "; 599 } 600 601 /** 602 * Adds method to get a version of the primary key that can be used as a unique key for identifier map. 603 * @param string &$script The script will be modified in this method. 604 */ 605 protected function addGetPrimaryKeyHash(&$script) 606 { 607 $script .= " 608 /** 609 * Retrieves a string version of the primary key that can be used to uniquely identify a row in this table. 610 * 611 * For tables with a single-column primary key, that simple pkey value will be returned. For tables with 612 * a multi-column primary key, a serialize()d version of the primary key will be returned. 613 * 614 * @param array \$row PDO resultset row. 615 * @param int \$startcol The 0-based offset for reading from the resultset row. 616 * @return string 617 */ 618 public static function getPrimaryKeyHash(\$row, \$startcol = 0) 619 {"; 620 621 // We have to iterate through all the columns so that we know the offset of the primary 622 // key columns. 623 $n = 0; 624 foreach($this->getTable()->getColumns() as $col) { 625 if(!$col->isLazyLoad()) { 626 if ($col->isPrimaryKey()) { 627 $pk[] = "\$row[\$startcol + $n]"; 628 } 629 $n++; 630 } 631 } 632 633 // the general case is a single column 634 if (count($pk) == 1) { 635 $script .= " 636 return (string) ".$pk[0].";"; 637 } else { 638 $script .= " 639 return serialize(".implode(',', $pk).");"; 640 } 641 642 $script .= " 643 } 644 "; 645 } // addGetPrimaryKeyHash 646 591 647 /** 592 648 * Adds the populateObjects() method. … … 618 674 // populate the object(s) 619 675 while(\$row = \$stmt->fetch(PDO::FETCH_NUM)) { 676 \$key = ".$this->getPeerClassname()."::getPrimaryKeyHash(\$row, 0); 677 if (isset(self::\$instances[\$key])) { 678 \$results[] = self::\$instances[\$key]; 679 } else { 620 680 "; 621 681 if ($table->getChildrenColumn()) { 622 682 $script .= " 623 // class must be set each time from the record row624 \$cls = Propel::import(".$this->getPeerClassname()."::getOMClass(\$row, 0));625 \$obj = new \$cls();626 \$obj->hydrate(\$row);627 \$results[] = \$obj;628 ";683 // class must be set each time from the record row 684 \$cls = Propel::import(".$this->getPeerClassname()."::getOMClass(\$row, 0)); 685 \$obj = new \$cls(); 686 \$obj->hydrate(\$row); 687 \$results[] = \$obj; 688 self::\$instances[\$key] = \$obj;"; 629 689 } else { 630 690 $script .= " 631 \$obj = new \$cls(); 632 \$obj->hydrate(\$row); 633 \$results[] = \$obj; 634 "; 635 } 636 $script .= " 691 \$obj = new \$cls(); 692 \$obj->hydrate(\$row); 693 \$results[] = \$obj; 694 self::\$instances[\$key] = \$obj;"; 695 } 696 $script .= " 697 } // if key exists 637 698 } 638 699 return \$results; … … 1216 1277 public static function ".$this->getRetrieveMethodName()."(\$pk, PDO \$con = null) 1217 1278 { 1218 if (\$con === null) { 1219 \$con = Propel::getConnection(self::DATABASE_NAME); 1220 } 1221 1222 \$criteria = " .$this->getPeerClassname()."::createCriteria(); 1279 // shortcut to avoid calling doSelect() when we already know it's in the identity map 1280 \$key = (string) \$pk; 1281 if (isset(self::\$instances[\$key])) { 1282 return self::\$instances[\$key]; 1283 } else { 1284 if (\$con === null) { 1285 \$con = Propel::getConnection(self::DATABASE_NAME); 1286 } 1287 1288 \$criteria = " .$this->getPeerClassname()."::createCriteria(); 1223 1289 "; 1224 1290 $pkey = $table->getPrimaryKey(); 1225 1291 $col = array_shift($pkey); 1226 1292 $script .= " 1227 \$criteria->add(new EqualExpr(".$this->getColumnConstant($col).", \$pk)); 1228 "; 1229 $script .= " 1230 1231 \$v = ".$this->getPeerClassname()."::doSelect(new Query(\$criteria), \$con); 1232 1233 return !empty(\$v) > 0 ? \$v[0] : null; 1293 \$criteria->add(new EqualExpr(".$this->getColumnConstant($col).", \$pk)); 1294 "; 1295 $script .= " 1296 1297 \$v = ".$this->getPeerClassname()."::doSelectOne(new Query(\$criteria), \$con); 1298 if (\$v) { // only set the map, if it's an actual object 1299 self::\$instances[\$key] = \$v; 1300 } 1301 return \$v; 1302 } 1234 1303 } 1235 1304 "; … … 1298 1367 */ 1299 1368 public static function ".$this->getRetrieveMethodName()."("; 1300 $co = 0; 1369 1370 $params = array(); 1301 1371 foreach ($table->getPrimaryKey() as $col) { 1302 1372 $clo = strtolower($col->getName()); 1303 $ script .= ($co++ ? "," : "") . "$".$clo;1373 $params[] = "\$".$clo; 1304 1374 } /* foreach */ 1305 $script .= ", \$con = null) { 1306 if (\$con === null) { 1307 \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME); 1308 } 1309 \$criteria = ".$this->getPeerClassname()."::createCriteria();"; 1375 1376 $script .= implode(', ', $params); 1377 1378 $script .= ", PDO \$con = null) 1379 { 1380 \$key = serialize(".implode(',',$params)."); 1381 if (isset(self::\$instances[\$key])) { 1382 return self::\$instances[\$key]; 1383 } else { 1384 if (\$con === null) { 1385 \$con = Propel::getConnection(".$this->getPeerClassname()."::DATABASE_NAME); 1386 } 1387 \$criteria = ".$this->getPeerClassname()."::createCriteria();"; 1310 1388 foreach ($table->getPrimaryKey() as $col) { 1311 1389 $clo = strtolower($col->getName()); 1312 1390 $script .= " 1313 \$criteria->add(new EqualExpr(".$this->getColumnConstant($col).", $".$clo."));"; 1314 } 1315 $script .= " 1316 \$v = ".$this->getPeerClassname()."::doSelect(new Query(\$criteria), \$con); 1317 1318 return !empty(\$v) ? \$v[0] : null; 1391 \$criteria->add(new EqualExpr(".$this->getColumnConstant($col).", $".$clo."));"; 1392 } 1393 $script .= " 1394 \$v = ".$this->getPeerClassname()."::doSelectOne(new Query(\$criteria), \$con); 1395 if (\$v) { // only set the map, if it's an actual object 1396 self::\$instances[\$key] = \$v; 1397 } 1398 return \$v; 1399 } 1319 1400 }"; 1320 1401 } … … 1336 1417 public static function getTableMap() 1337 1418 { 1338 return Propel::getDatabaseMap( self::DATABASE_NAME)->getTable(self::TABLE_NAME);1419 return Propel::getDatabaseMap(".$this->getPeerClassname()."::DATABASE_NAME)->getTable(".$this->getPeerClassname()."::TABLE_NAME); 1339 1420 } 1340 1421 "; -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5ComplexObjectBuilder.php
r406 r409 375 375 * @throws PropelException 376 376 */ 377 public function get".$this->getFKPhpNameAffix($fk, $plural = false)."( \$con = null)377 public function get".$this->getFKPhpNameAffix($fk, $plural = false)."(PDO \$con = null) 378 378 { 379 379 // include the related Peer class … … 524 524 * actually need in ".$table->getPhpName().". 525 525 */ 526 public function get".$relCol."Join".$relCol2."( \$criteria = null,\$con = null)526 public function get".$relCol."Join".$relCol2."(Query \$query = null, PDO \$con = null) 527 527 { 528 528 // include the Peer class … … 630 630 { 631 631 foreach($this->getTable()->getReferrers() as $refFK) { 632 // if ( $refFK->getTable()->getName() != $this->getTable()->getName() ) { 632 // if ( $refFK->getTable()->getName() != $this->getTable()->getName() ) 633 if ($refFK->isLocalPrimaryKey()) { 634 $this->addPKRefFKGet($script, $refFK); 635 } else { 633 636 $this->addRefFKInit($script, $refFK); 634 637 $this->addRefFKGet($script, $refFK); … … 636 639 $this->addRefFKAdd($script, $refFK); 637 640 $this->addRefFKGetJoinMethods($script, $refFK); 641 } 638 642 // } 639 643 } … … 712 716 * @throws PropelException 713 717 */ 714 public function count$relCol( \$criteria= null, \$distinct = false, \$con = null)718 public function count$relCol(Query \$query = null, \$distinct = false, \$con = null) 715 719 { 716 720 // include the Peer class … … 833 837 } // addRefererGet() 834 838 839 /** 840 * Adds the special-case method that returns a single referrer-related object, for cases 841 * where the foreign key columns are also the primary key of the foreign table. 842 * 843 * @param string &$script The script will be modified in this method. 844 */ 845 protected function addPKRefFKGet(&$script, ForeignKey $refFK) 846 { 847 $table = $this->getTable(); 848 $tblFK = $refFK->getTable(); 849 850 $fkPeerBuilder = OMBuilder::getNewPeerBuilder($refFK->getTable()); 851 $relCol = $this->getRefFKPhpNameAffix($refFK, $plural = false); 852 853 $collName = $this->getRefFKCollVarName($refFK); 854 $lastCriteriaName = $this->getRefFKLastCriteriaVarName($refFK); 855 856 $script .= " 857 /** 858 * Gets a single ".$tblFK->getName()." object, which is related in a one-to-one relationship to this object. 859 * @param PDO \$con 860 * @throws PropelException 861 */ 862 public function get$relCol(PDO \$con = null) 863 { 864 // include the Peer class 865 include_once '".$fkPeerBuilder->getStubPeerBuilder()->getClassFilePath()."'; 866 "; 867 868 $lfmap = $refFK->getLocalForeignMapping(); 869 870 // remember: this object represents the foreign table, 871 // so we need foreign columns of the reffk to know the local columns 872 // that we need to set :) 873 874 $localcols = $refFK->getForeignColumns(); 875 876 // we know that at least every column in the primary key of the foreign table 877 // is represented in this foreign key 878 879 $params = array(); 880 foreach ($tblFK->getPrimaryKey() as $col) { 881 882 $localColumn = $table->getColumn($lfmap[$col->getName()]); 883 $params[] = "\$this->get".$localColumn->getPhpName()."()"; 884 } 885 886 $script .= " 887 return ".$fkPeerBuilder->getPeerClassname()."::retrieveByPK(".implode(", ", $params).", \$con); 888 } 889 "; 890 891 } // addPKRefFKGet() 835 892 836 893 … … 994 1051 * @see doSave() 995 1052 */ 996 public function save( \$con = null)1053 public function save(PDO \$con = null) 997 1054 { 998 1055 if (\$this->isDeleted()) { -
trunk/generator/classes/propel/engine/builder/om/php5/PHP5ComplexPeerBuilder.php
r384 r409 184 184 185 185 while(\$row = \$stmt->fetch(PDO::FETCH_NUM)) { 186 \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHash(\$row, 0); 187 if (isset(self::\$instances[\$key1])) { 188 \$obj1 = self::\$instances[\$key1]; 189 } else { 186 190 "; 187 191 if ($table->getChildrenColumn()) { 188 192 $script .= " 189 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0);193 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); 190 194 "; 191 195 } else { 192 196 $script .= " 193 \$omClass = ".$this->getPeerClassname()."::getOMClass();197 \$omClass = ".$this->getPeerClassname()."::getOMClass(); 194 198 "; 195 199 } 196 200 $script .= " 197 \$cls = Propel::import(\$omClass); 198 \$obj1 = new \$cls(); 199 \$obj1->hydrate(\$row); 201 \$cls = Propel::import(\$omClass); 202 \$obj1 = new \$cls(); 203 \$obj1->hydrate(\$row); 204 self::\$instances[\$key1] = \$obj1; 205 } // if obj1 already loaded 206 207 \$key2 = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHash(\$row, \$startcol); 208 if (isset(".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key2])) { 209 \$obj2 = ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key2]; 210 } else { 200 211 "; 201 212 if ($joinTable->getChildrenColumn()) { 202 213 $script .= " 203 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol);214 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol); 204 215 "; 205 216 } else { 206 217 $script .= " 207 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();218 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); 208 219 "; 209 220 } 210 221 211 222 $script .= " 212 \$cls = Propel::import(\$omClass); 213 \$obj2 = new \$cls(); 214 \$obj2->hydrate(\$row, \$startcol); 215 223 \$cls = Propel::import(\$omClass); 224 \$obj2 = new \$cls(); 225 \$obj2->hydrate(\$row, \$startcol); 226 ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key2] = \$obj2; 227 } // if obj2 already loaded 228 229 // FIXME -- this needs to be updated for identity map 230 // 216 231 \$newObject = true; 217 232 foreach(\$results as \$temp_obj1) { … … 338 353 * rethrown wrapped into a PropelException. 339 354 */ 340 public static function doSelectJoinAll(Criteria \$c, \$con = null)355 public static function doSelectJoinAll(Criteria \$c, PDO \$con = null) 341 356 { 342 357 \$c = clone \$c; … … 394 409 395 410 while(\$row = \$stmt->fetch(PDO::FETCH_NUM)) { 411 \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHash(\$row, 0); 412 if (isset(self::\$instances[\$key1])) { 413 \$obj1 = self::\$instances[\$key1]; 414 } else { 396 415 "; 397 416 398 417 if ($table->getChildrenColumn()) { 399 418 $script .= " 400 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0);419 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); 401 420 "; 402 421 } else { 403 422 $script .= " 404 \$omClass = ".$this->getPeerClassname()."::getOMClass();423 \$omClass = ".$this->getPeerClassname()."::getOMClass(); 405 424 "; 406 425 } 407 426 408 427 $script .= " 409 410 \$cls = Propel::import(\$omClass); 411 \$obj1 = new \$cls(); 412 \$obj1->hydrate(\$row); 428 429 \$cls = Propel::import(\$omClass); 430 \$obj1 = new \$cls(); 431 \$obj1->hydrate(\$row); 432 self::\$instances[\$key1] = \$obj1; 433 } // if obj1 already loaded 413 434 "; 414 435 … … 455 476 456 477 $script .= " 457 458 // Add objects for joined $joinClassName rows 478 // Add objects for joined $joinClassName rows 479 480 \$key$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHash(\$row, \$startcol$index); 481 if (isset(".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index])) { 482 \$obj$index = ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index]; 483 } else { 459 484 "; 460 485 if ($joinTable->getChildrenColumn()) { 461 486 $script .= " 462 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index);487 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index); 463 488 "; 464 489 } else { 465 490 $script .= " 466 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();491 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); 467 492 "; 468 493 } /* $joinTable->getChildrenColumn() */ 469 494 470 495 $script .= " 471 472 \$cls = Propel::import(\$omClass); 473 \$obj".$index." = new \$cls(); 474 \$obj".$index."->hydrate(\$row, \$startcol$index); 475 496 497 \$cls = Propel::import(\$omClass); 498 \$obj".$index." = new \$cls(); 499 \$obj".$index."->hydrate(\$row, \$startcol$index); 500 ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index] = \$obj$index; 501 } // if obj$index loaded 502 503 // FIXME - Fix this for new identity map system 476 504 \$newObject = true; 477 505 for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) { … … 522 550 * @return int Number of matching rows. 523 551 */ 524 public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, \$con = null)552 public static function doCountJoinAll(Criteria \$criteria, \$distinct = false, PDO \$con = null) 525 553 { 526 554 \$criteria = clone \$criteria; … … 628 656 * rethrown wrapped into a PropelException. 629 657 */ 630 public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, \$con = null)658 public static function doSelectJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$c, PDO \$con = null) 631 659 { 632 660 \$c = clone \$c; … … 688 716 689 717 while(\$row = \$stmt->fetch(PDO::FETCH_NUM)) { 718 \$key1 = ".$this->getPeerClassname()."::getPrimaryKeyHash(\$row, 0); 719 if (isset(self::\$instances[\$key1])) { 720 \$obj1 = self::\$instances[\$key1]; 721 } else { 690 722 "; 691 723 if ($table->getChildrenColumn()) { 692 724 $script .= " 693 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0);725 \$omClass = ".$this->getPeerClassname()."::getOMClass(\$row, 0); 694 726 "; 695 727 } else { 696 728 $script .= " 697 \$omClass = ".$this->getPeerClassname()."::getOMClass();729 \$omClass = ".$this->getPeerClassname()."::getOMClass(); 698 730 "; 699 731 } 700 732 701 733 $script .= " 702 \$cls = Propel::import(\$omClass); 703 \$obj1 = new \$cls(); 704 \$obj1->hydrate(\$row); 734 \$cls = Propel::import(\$omClass); 735 \$obj1 = new \$cls(); 736 \$obj1->hydrate(\$row); 737 self::\$instances[\$key1] = \$obj1; 738 } // if obj1 already loaded 705 739 "; 706 740 … … 743 777 744 778 $index++; 745 779 780 $script .= " 781 // Add objects for joined $joinClassName rows 782 783 \$key$index = ".$joinedTablePeerBuilder->getPeerClassname()."::getPrimaryKeyHash(\$row, \$startcol$index); 784 if (isset(".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index])) { 785 \$obj$index = ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index]; 786 } else { 787 "; 746 788 if ($joinTable->getChildrenColumn()) { 747 789 $script .= " 748 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index);790 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(\$row, \$startcol$index); 749 791 "; 750 792 } else { 751 793 $script .= " 752 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass();794 \$omClass = ".$joinedTablePeerBuilder->getPeerClassname()."::getOMClass(); 753 795 "; 754 796 } /* $joinTable->getChildrenColumn() */ 755 797 756 798 $script .= " 757 758 \$cls = Propel::import(\$omClass); 759 \$obj$index = new \$cls(); 760 \$obj".$index."->hydrate(\$row, \$startcol$index); 761 799 800 \$cls = Propel::import(\$omClass); 801 \$obj$index = new \$cls(); 802 \$obj".$index."->hydrate(\$row, \$startcol$index); 803 ".$joinedTablePeerBuilder->getPeerClassname()."::\$instances[\$key$index] = \$obj$index; 804 } // if \$obj$index already loaded 805 806 // FIXME - Fix this for new identity map system 762 807 \$newObject = true; 763 808 for (\$j=0, \$resCount=count(\$results); \$j < \$resCount; \$j++) { … … 820 865 * @return int Number of matching rows. 821 866 */ 822 public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, \$con = null)867 public static function doCountJoinAllExcept".$thisTableObjectBuilder->getFKPhpNameAffix($fk, $plural = false)."(Criteria \$criteria, \$distinct = false, PDO \$con = null) 823 868 { 824 869 // we're going to modify criteria, so copy it first -
trunk/generator/classes/propel/engine/database/model/ForeignKey.php
r371 r409 155 155 $this->foreignTableName = $tableName; 156 156 } 157 157 158 /** 159 * Gets the resolved foreign Table model object. 160 * @return Table 161 */ 162 public function getForeignTable() 163 { 164 return $this->getTable()->getDatabase()->getTable($this->getForeignTableName()); 165 } 166 158 167 /** 159 168 * Set the parent Table of the foreign key … … 254 263 return $h; 255 264 } 256 265 266 /** 267 * Whether this foreign key is also the primary key of the local table. 268 * 269 * @return boolean 270 */ 271 public function isLocalPrimaryKey() 272 { 273 $localCols = $this->getLocalColumns(); 274 275 $localPKColumnObjs = $this->getTable()->getPrimaryKey(); 276 277 $localPKCols = array(); 278 foreach($localPKColumnObjs as $lPKCol) { 279 $localPKCols[] = $lPKCol->getName(); 280 } 281 // 282 // print "Local key columns: \n"; 283 // print_r($localCols); 284 // 285 // print "Local table primary key columns: \n"; 286 // print_r($localPKCols); 287 288 return (!array_diff($localPKCols, $localCols)); 289 } 290 257 291 /** 258 292 * String representation of the foreign key. This is an xml representation. -
trunk/generator/classes/propel/engine/database/model/Table.php
r371 r409 1079 1079 * key for this table. 1080 1080 * 1081 * @return array A list of the primary key parts.1081 * @return array Column[] A list of the primary key parts. 1082 1082 */ 1083 1083 public function getPrimaryKey()