Tuesday 15 January 2013

How can I select table records that have no relation records in doctrine 1.2 -



How can I select table records that have no relation records in doctrine 1.2 -

how can select table records have no relation records using doctrine 1.2 query?

i've tried kind of thing (below) tells me there no t.relations, because have set fk relation in relation table? seems should easy can't figure it. looked @ sub queries couldn't head around kno whether right thing. thanks.

$q = doctrine_query::create() ->from('table t') ->leftjoin('t.relations r') ->where('t.user_id = ?',$userid) ->andwhere('t.relations null') homecoming $q->execute();

much simplified schema:

table: columns: id: type: integer notnull: true user_id: type: integer notnull: true relations: user: class: user foreign: id local: user_id foreignalias: users relation: columns: table_id: type: integer notnull: true relations: table: class: table foreign: id local: table_id foreignalias: relations

without knowing error message guessing error propably in andwhere(..) statement. table t doesn't have property relation, instead want check table r:

$q = doctrine_query::create() ->from('table t') ->leftjoin('t.relations r') ->where('t.user_id = ?',$userid) ->andwhere('r.table_id null') homecoming $q->execute();

doctrine

No comments:

Post a Comment