Как я могу выбрать все записи таблицы, которые не имеют записей отношений, используя запрос доктрины 1.2?
Я пробовал такие вещи (ниже), но мне говорят, что t.Relations нет, возможно, потому, что я установил отношение FK в таблице Relation? Кажется, что это должно быть очень просто, но не могу понять. Просмотрел подзапросы, но не мог понять, правильно ли это. благодаря.
$q = Doctrine_Query::create()
->from('Table t')
->leftJoin('t.Relations r')
->where('t.user_id = ?',$userId)
->andWhere('t.Relations IS NULL')
return $q->execute();
Сильно упрощенная схема:
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