From 3c8a34b4b63304d663e84ca8f2dd557b0afb0d35 Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Thu, 31 Mar 2011 15:17:33 +0000 Subject: [PATCH] fix ORM relation with inherits entity (now use root entity) --- engine/classes/ModuleORM.class.php | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/engine/classes/ModuleORM.class.php b/engine/classes/ModuleORM.class.php index e4afa527..8e93c3d8 100644 --- a/engine/classes/ModuleORM.class.php +++ b/engine/classes/ModuleORM.class.php @@ -268,7 +268,7 @@ abstract class ModuleORM extends Module { $aEntityKeys=array(); foreach ($aFilter['#with'] as $sRelationName) { $sRelType=$aRelations[$sRelationName][0]; - $sRelEntity=$aRelations[$sRelationName][1]; + $sRelEntity=$this->Plugin_GetRootDelegater('entity',$aRelations[$sRelationName][1]); // получаем корневую сущность, без учета наследников $sRelKey=$aRelations[$sRelationName][2]; if (!array_key_exists($sRelationName,$aRelations) or !in_array($sRelType,array(EntityORM::RELATION_TYPE_BELONGS_TO,EntityORM::RELATION_TYPE_HAS_ONE))) { @@ -287,12 +287,10 @@ abstract class ModuleORM extends Module { * Делаем общий запрос по всем ключам */ $oRelEntityEmpty=Engine::GetEntity($sRelEntity); - - $sRelModuleName=Engine::GetModuleName($oRelEntityEmpty); - $sRelEntityName=Engine::GetEntityName($oRelEntityEmpty); - $sRelPluginPrefix=Engine::GetPluginPrefix($oRelEntityEmpty); - $sRelPrimaryKey = method_exists($oRelEntityEmpty,'_getPrimaryKey') ? func_camelize($oRelEntityEmpty->_getPrimaryKey()) : 'Id'; - + $sRelModuleName=Engine::GetModuleName($sRelEntity); + $sRelEntityName=Engine::GetEntityName($sRelEntity); + $sRelPluginPrefix=Engine::GetPluginPrefix($sRelEntity); + $sRelPrimaryKey = method_exists($oRelEntityEmpty,'_getPrimaryKey') ? func_camelize($oRelEntityEmpty->_getPrimaryKey()) : 'Id'; $aRelData=Engine::GetInstance()->_CallModule("{$sRelPluginPrefix}{$sRelModuleName}_get{$sRelEntityName}ItemsByArray{$sRelPrimaryKey}", array($aEntityKeys[$sRelKey])); /**