Re: reprade the question - how to transform linked query into array $row

From: Date: Fri, 31 Dec 2004 21:01:03 +0000
Subject: Re: reprade the question - how to transform linked query into array $row
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16541@lists.php.net to get a copy of this message
On Wed, 29 Dec 2004 06:10:48 -0800 (PST), l Burnerheimerton <lburnerheimerton@yahoo.com> wrote: > Again, I am new to dataObject so I appreciate your patience and help. > > Here's the query: > > $frc = new DataObject_Facility_join_owner(); > $frc->whereAdd("facilityName LIKE '%Hap%'"); > $frc->find(); > while ($frc->fetch()) { > $instr =& $frc->getLink('instructor_ID'); > $room =& $frc->getLink('room_ID'); > $bldg =& $room->getLink('building_ID'); > $ent =& $frc->getLink('entity_ID'); > echo $frc->facility_ID....; > Intead of echo-ing the output with a while look, I want to end up with an array like the query > was an INNER JOIN and all the data came through in one results set in $row[]. > As I said before you can use joinAdd to do this. Be careful, though, as columns with the same name will be overwritten. You should be able to use selectAdd to change the column names I think. $instr =& DB_DataObject::factory('instructor'); $frc->joinAdd($instr); $frc->find(); while ($frc->fetch()) { ... } You could also convert the DOs to arrays with $di->toArray() and merge them with array_merge(), then put them all in a big array. But this isn't what DB_DataObject is supposed to do. You're supposed to work on the DO, not on an array. -- Justin Patrin

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