Re: Dataobject : complex jointures
| From: | Justin Patrin | Date: | Tue, 26 Jul 2005 18:23:59 +0000 |
| Subject: | Re: Dataobject : complex jointures | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-20152@lists.php.net to get a copy of this message | ||
On 7/26/05, David Alia <david.alia@gmail.com> wrote:
>
>
> -----Message d'origine-----
> De : Justin Patrin [mailto:papercrane@gmail.com]
> Envoyé : mardi 26 juillet 2005 19:32
> À : David Alia
> Cc : pear-general@lists.php.net
> Objet : Re: [PEAR] Dataobject : complex jointures
>
> On 7/26/05, David Alia <david.alia@gmail.com> wrote:
> >
> > Hi. Thanks a lot for your -so quick- help.
> >
> > [cut]
> >
> > >
> > > $D->selectAdd();
> > > $D->selectAdd('A1, A2, A3'); // fields from A table
> > >
> > > $B->joinAdd($E);
> > >
> > > $D->joinAdd($B);
> > > $D->selectAs();
> >
> > >>Likely the above call is killing the A selectAdds from above. Try
> > >>removing
> > the above line and see what you get.
> >
> > --> this solved the problem : A fields are now available.
> >
> > >
> > > - SQL statement does not include A fields, nor E fields
> >
> > >> The A fields are missing likely due to the first selectAs call. The
> > >> E
> > fields aren't showing up because you didn't ask for them. Perhaps try
> > a selectAs call for A, B, *and* E.
> >
> > --> Ok, I thought I had already selected E fields using $B->joinAdd($E) ?
> > Since, E has no link with D, I canno't write $D->joinAdd($E)...
> >
>
> >>> Joining is not the same as setting up selected fields. joinAdd simply
> adds a join clause to your SQL. You empty out the SELECT part when you do
> selectAdd(), so no fields except the ones you specify will be shown. Try a
> selectAs for all 3 and see if that works.
>
> I must be an idiot but I can't get to do it :
>
> when I write :
>
> $D->selectAdd('A1, A2, A3, E1');
>
> I get an error (unknown column E1)
Does the E1 column exist? Is the join of E working? Try
DB_DataObject::debugLevel(1) to see the SQL that is generated and any
errors that may be happening.
>
> when I write :
>
> $D->selectAs($E, 'E_%s');
>
> I get an error (D has no link with E)
>
> I've tried lots of possibilities but nothing comes...
>
Perhaps I was wrong about selectAs. I've never actually used it
myself. ;-) I tend to just use selectAdd.
$D->selectAdd('A.A1, A.A2, A.A3, E.E1, E.E2, B.B1, etc...');
--
Justin Patrin