From ed95b343dd11a3c5136d33dcb55ab11d75c551a9 Mon Sep 17 00:00:00 2001 From: "godzilla80@gmx.net" <> Date: Thu, 14 May 2009 07:40:17 +0000 Subject: Fixed Issue#78 - add schema support to TActiveRecordRelation::findForeignKeys() --- HISTORY | 1 + framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php | 7 +++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/HISTORY b/HISTORY index 76871038..61cf7150 100644 --- a/HISTORY +++ b/HISTORY @@ -1,6 +1,7 @@ Version 3.1.5 (to be released) BUG: Issue#55 - TPropertyAccess.get and has don't recognize magic getter __get (Yves) BUG: Issue#68 - TSqlMapConfig::createSqlMapGateway(): assign current connection to cached TSqlMapManager to avoid loosing active transaction (Yves) +BUG: Issue#78 - add schema support to TActiveRecordRelation::findForeignKeys() (Yves) BUG: Issue#87 - TinyMCE : empty string disapears after encoding JS, that's a problem! (Christophe) BUG: Issue#88 - SQLMap $Param$ re-evaluation bug (Yves) BUG: Issue#95 - TMysqlMetaData::getShowCreateTable() throws TPhpErrorException "[Notice] Undefined index: Create Table" if table is a view (Yves) diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php index 85dd6735..a3daf35c 100644 --- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php +++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php @@ -109,14 +109,17 @@ abstract class TActiveRecordRelation protected function findForeignKeys($from, $matchesRecord, $loose=false) { $gateway = $matchesRecord->getRecordGateway(); - $matchingTableName = $gateway->getRecordTableInfo($matchesRecord)->getTableName(); + $recordTableInfo = $gateway->getRecordTableInfo($matchesRecord); + $matchingTableName = strtolower($recordTableInfo->getTableName()); + $matchingFullTableName = strtolower($recordTableInfo->getTableFullName()); $tableInfo=$from; if($from instanceof TActiveRecord) $tableInfo = $gateway->getRecordTableInfo($from); //find first non-empty FK foreach($tableInfo->getForeignKeys() as $fkeys) { - if(strtolower($fkeys['table'])===strtolower($matchingTableName)) + $fkTable = strtolower($fkeys['table']); + if($fkTable===$matchingTableName || $fkTable===$matchingFullTableName) { $hasFkField = !$loose && $this->getContext()->hasFkField(); $key = $hasFkField ? $this->getFkFields($fkeys['keys']) : $fkeys['keys']; -- cgit v1.2.3