Dataobject : complex jointures

From: Date: Tue, 26 Jul 2005 16:46:51 +0000
Subject: Dataobject : complex jointures
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-20141@lists.php.net to get a copy of this message
Hello all, Thanks for the answers you already gave me. Now I'm trying more complicated, if someone is kind enough to read it... :) Suppose I have this structure : A, B, C are "primary tables". The link between all these tables is the central table D. B is linked to another table E by a foreign key. A <- D -> B -> E ^ | C The point is : I want to get in a single query all records from D, "inner joining" A, B and C and using the relationship between B and E. The code I wrote is the following : $a = array(); DB_DataObject::debugLevel(2); $D = $this->factory('D'); $A = $this->factory('A'); $E = $this->factory('E'); $B = $this->factory('B'); $D->joinAdd($this); // $this is $C, already initialized $D->joinAdd($A); $D->selectAdd(); $D->selectAdd('A1, A2, A3'); // fields from A table $B->joinAdd($E); $D->joinAdd($B); $D->selectAs(); $D->selectAs($B, 'B_%s'); if ($D->find()) { while ($D->fetch()) { $a[] = $D; } } return $a; I get this result : - SQL statement does not include A fields, nor E fields - B fields are correctly labeled (ie B_field) - A1, A2 and A3 are not included too Can anyone help me to find out the problem ? Thanks a lot David

« previous php.pear.general (#20141) next »