Home > Archive > PHP Pear > January 2005 > Re: [PEAR] DataObjects joins
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Re: [PEAR] DataObjects joins
|
|
| Justin Patrin 2005-01-28, 3:59 pm |
| On Fri, 28 Jan 2005 13:14:45 -0500, James Stewart <lists@jystewart.net> wrote:
> I'm running into some problems with DB_DataObject on PHP 4.3.10 (I have
> no choice about the version, it's on a shared host). I've only been
> seeing the problems since I tried working on 4.3.10, though it is
> possible they slipped through the cracks previously.
>
> The code I'm using is:
>
> $staff = DB_DataObject::factory('member');
> $attendance = DB_DataObject::factory('staff_conference
');
> $position = DB_DataObject::factory('position');
> $staff->joinAdd($attendance);
> $staff->joinAdd($position);
>
> $position->school = $college_id;
> $position->whereAdd('end_date IS NULL');
>
> $staff->find();
>
> and the error I'm seeing is:
>
> joinAdd: staff_conference has no link with member
>
> my <dbname>.links.ini file contains:
>
> [staff_conference]
> member_id = member:id
> member_id = registration:registrant
> member_id = position:member
>
> Through a little digging around I discovered that DB_DataObject is only
> recognising the last link where there are several from the same field
> in the originating table. Can anyone recommend a way around this?
>
Ummm...how are you expecting that to work? One field can only link to
one table. Sounds like the first one is the real one (member_id links
to member:id) and the other two should be set up in the other tables
[registration]
registrant = member:id
--
Justin Patrin
| |
| James Stewart 2005-01-28, 3:59 pm |
| On Jan 28, 2005, at 1:29 PM, Justin Patrin wrote:
> On Fri, 28 Jan 2005 13:14:45 -0500, James Stewart
> <lists@jystewart.net> wrote:
>
> Ummm...how are you expecting that to work? One field can only link to
> one table. Sounds like the first one is the real one (member_id links
> to member:id) and the other two should be set up in the other tables
>
> [registration]
> registrant = member:id
I'm linking that field with different tables depending on the context.
In some cases the registrant is a member, but in others they're a guest
and so linked with another table. Where necessary, I use
registration.reg_type to check that.
James.
|
|
|
|
|