From d5eb713888715e8f18d2ccf508a8eb0b1a483ad1 Mon Sep 17 00:00:00 2001 From: wei <> Date: Tue, 24 Apr 2007 06:14:56 +0000 Subject: add active record Relations --- framework/Data/DataGateway/TDataGatewayCommand.php | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) (limited to 'framework/Data/DataGateway') diff --git a/framework/Data/DataGateway/TDataGatewayCommand.php b/framework/Data/DataGateway/TDataGatewayCommand.php index 43a57aa7..80856a0e 100644 --- a/framework/Data/DataGateway/TDataGatewayCommand.php +++ b/framework/Data/DataGateway/TDataGatewayCommand.php @@ -179,7 +179,7 @@ class TDataGatewayCommand extends TComponent public function findAllByIndex($criteria,$fields,$values) { - $index = $this->getIndexKeyCondition($fields,$values); + $index = $this->getIndexKeyCondition($this->getTableInfo(),$fields,$values); if(strlen($where = $criteria->getCondition())>0) $criteria->setCondition("({$index}) AND ({$where})"); else @@ -202,11 +202,12 @@ class TDataGatewayCommand extends TComponent return $this->onExecuteCommand($command,$command->execute()); } - protected function getIndexKeyCondition($fields,$values) + public function getIndexKeyCondition($table,$fields,$values) { $columns = array(); + $tableName = $table->getTableFullName(); foreach($fields as $field) - $columns[] = $this->getTableInfo()->getColumn($field)->getColumnName(); + $columns[] = $tableName.'.'.$table->getColumn($field)->getColumnName(); return '('.implode(', ',$columns).') IN '.$this->quoteTuple($values); } @@ -236,7 +237,7 @@ class TDataGatewayCommand extends TComponent throw new TDbException('dbtablegateway_pk_value_count_mismatch', $this->getTableInfo()->getTableFullName()); } - return $this->getIndexKeyCondition($primary, $values); + return $this->getIndexKeyCondition($this->getTableInfo(),$primary, $values); } /** -- cgit v1.2.3