DB_DataObject 2 joins to same table
| From: | Leo Márquez | Date: | Fri, 26 Nov 2004 13:16:50 +0000 |
| Subject: | DB_DataObject 2 joins to same table | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-15832@lists.php.net to get a copy of this message | ||
Hi!,
Hi have a tables relationship like the
'Automatic Table Linking and Joins' example at PEAR DB_DAtaObject
Documentation. One table that have two columns that links to the same
table and the same column. For example:
table USER
user_id
user_name
user_firstcar
user_secondcar
table CAR
car_id
car_model
car_color
on mydatabase.links.ini
[USER]
user_firscar=CAR:car_id
user_secondcar=CAR:car_id
In the PEAR doc example I see:
...
$car->use = 'first';
...
I have been looking for the 'use' attribute in doc of DB_DAtaObject
and DB and not have seen it. I understand that in my code I should
type:
$car->use='user_firstcar' for the first join
and
$car2->use='user_secondcar' for the first join
and the selectAs, etc.
I have tried it and not work, always see the first instance of car. My
code is here:
$mo=new MAGATZEM();
$mo->use='MAGATZEM_ORIGEN';
$md=new MAGATZEM();
$md->use='MAGATZEM_DESTI';
$dob->joinAdd($mo);
$dob->selectAs($mo,'mo_%s');
$dob->joinAdd($md,'','md');
$dob->selectAs($md,'md_%s');
$dob->find();
Thanks about any help.