Re: DB_DataObject linking 3 tables to make an N - N relation.
| From: | Justin Patrin | Date: | Fri, 21 Jan 2005 20:02:00 +0000 |
| Subject: | Re: DB_DataObject linking 3 tables to make an N - N relation. | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17090@lists.php.net to get a copy of this message | ||
On Fri, 21 Jan 2005 16:41:36 -0300, luca@llucax.hn.org
<luca@llucax.hn.org> wrote:
> Hi! I'm relative new to DB_DataObject and I have a simple database with
> an N to N relation, something like:
>
> table1 table2 table1_table2
> ------ ------ -------------
> id1 id2 id1
> stuff1 stuff2 id2
>
> I'd like to get all table1 items that belongs to a table2 item (eventually
> adding a filter, like stuff1 > 5, but this is secondary). Is there any way
> of doing this without messing up with SQL?
> I can't find it anywhere and I think is a relative common case...
>
> Any suggestions are welcome!
You can joinAdd the N-N table to the table1, then set up the filter on
table2 (set the member) and joinAdd that to the N-N table.
Or, rather, yould joinAdd table2 to the N-N and then joinAdd the N-N to table1.
>
> PS: Please Cc, I'm not in the list.
>
--
Justin Patrin