summaryrefslogtreecommitdiff
path: root/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
diff options
context:
space:
mode:
Diffstat (limited to 'framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php')
-rw-r--r--framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php9
1 files changed, 6 insertions, 3 deletions
diff --git a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
index a352cb07..a3daf35c 100644
--- a/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
+++ b/framework/Data/ActiveRecord/Relations/TActiveRecordRelation.php
@@ -84,7 +84,7 @@ abstract class TActiveRecordRelation
$obj->collectForeignObjects($results);
}
else if($results instanceof TActiveRecordRelation)
- array_push($stack,$this); //call it later
+ $stack[] = $this; //call it later
return $results;
}
@@ -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'];