One more thing, what if I wanted to find users not in a specific
list?

    $c->add(ContactListPeer::ID, $list->getId());
    $c->addJoin(ContactListPeer::ID, ListUserPeer::CONTACT_LIST_ID,
Criteria::LEFT_JOIN);
    $c->add(ListUserPeer::CONTACT_LIST_ID, null, Criteria::ISNULL);
    $c->addJoin(UserPeer::ID, ListUserPeer::USER_ID, Criteria::JOIN);
    $c->add(ListUserPeer::USER_ID, null, Criteria::ISNULL);

This is giving me a:

 [wrapped: SQLSTATE[42000]: Syntax error or access violation: 1066 Not
unique table/alias: 'list_user']

Do I have to resort to raw SQL?

-Brendan

On Mar 17, 1:27 pm, Richtermeister <[email protected]> wrote:
> Try this:
>
> $c = Criteria;
> $c -> addJoin(UserPeer::ID, ListUserPeer::USER_ID,
> Criteria::LEFT_JOIN);
> $c -> add(ListUserPeer::USER_ID, null, Criteria::ISNULL);
>
> that should work.
> Also, you don't need an id column in the list_user table, in fact it
> interferes with symfony on some levels.
> Just set both user_id and list_id to primaryKey: true and drop the id
> column.
>
> Hope this helps,
> Daniel
>
> On Mar 17, 9:29 am, "[email protected]" <[email protected]> wrote:
>
> > Sorry if this question is a little basic.
>
> > I'm trying to create a Criteria to retrieve records from a table that
> > aren't in another table as a foreign key.
>
> > User:
> >   id: ~
> >   name: varchar(255)
>
> > ListUser:
> >   id:  ~
> >   user_id: ~
> >   list_id:   ~
>
> > Trying to retrieve records from User that aren't in ListUser.  Is
> > there an easy way to do this with Criteria?
>
> > Thanks,
>
> > -Brendan
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"symfony users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/symfony-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to