Re: DB_DataObject 2 joins to same table
| From: | Justin Patrin | Date: | Fri, 26 Nov 2004 21:51:19 +0000 |
| Subject: | Re: DB_DataObject 2 joins to same table | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15844@lists.php.net to get a copy of this message | ||
On Fri, 26 Nov 2004 14:16:50 +0100, Leo Márquez <leo@calidae.net> wrote:
> 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:
Could you please give us a link to said documentation? I've never
heard of a "use" member variable in DB_DataObject. In fact, I'm
absolutely sure it doesn't exist as it would conflict with column
names.
>
> $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();
You should really be using factory here.
$mo = DB_DataObject::factory('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.
>
--
Justin Patrin