Ticket #3895: sfPropelFinder.php.patch
| File sfPropelFinder.php.patch, 1.5 kB (added by mrhyde, 6 months ago) |
|---|
-
plugins/sfPropelFinderPlugin/lib/sfPropelFinder.php
old new 943 943 944 944 protected function findRelation($phpName, $peerClass) 945 945 { 946 //first we need to build MapBuilder for related class 947 //so we can find TableMap in DatabaseMap 948 $mapBuilder = call_user_func(array($phpName.'Peer', 'getMapBuilder')); 949 if (!$mapBuilder->isBuilt()) 950 { 951 $mapBuilder->doBuild(); 952 } 953 $dbMap = Propel::getDatabaseMap(constant($peerClass.'::DATABASE_NAME')); 946 954 foreach ($this->getColumnsForPeerClass($peerClass) as $c) 947 955 { 948 956 if ($c->isForeignKey()) 949 957 { 950 if(sfInflector::camelize($c->getRelatedTableName()) == $phpName)958 try 951 959 { 952 return array( 953 constant($peerClass.'::'.$c->getColumnName()), 954 $c->getRelatedName() 955 ); 960 if ($dbMap->getTable($c->getRelatedTableName())->getPhpName() == $phpName) 961 { 962 return array( 963 constant($peerClass.'::'.$c->getColumnName()), 964 $c->getRelatedName() 965 ); 966 } 956 967 } 968 catch (PropelException $ex) 969 { 970 // silence PropelException 971 // if we got here it means that the MapBuilder related to foreign key 972 // has not been built yet. 973 } 957 974 } 958 975 } 959 976