Doctrine 如何选择原则1.2中没有关系记录的表记录
如何使用doctrine 1.2查询选择没有关系记录的所有表记录 我尝试过这种方法(如下),但它告诉我没有t.关系,可能是因为我在关系表中设置了FK关系? 看起来这应该很容易,但我想不出来。查看了子查询,但无法让我的头绕过它,以知道这是否是正确的事情。 谢谢 更简化的模式:Doctrine 如何选择原则1.2中没有关系记录的表记录,doctrine,Doctrine,如何使用doctrine 1.2查询选择没有关系记录的所有表记录 我尝试过这种方法(如下),但它告诉我没有t.关系,可能是因为我在关系表中设置了FK关系? 看起来这应该很容易,但我想不出来。查看了子查询,但无法让我的头绕过它,以知道这是否是正确的事情。 谢谢 更简化的模式: Table: columns: id: type: integer notnull: true user_id: ty
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
在不知道您的错误消息的情况下,我只是猜测,但错误很可能出现在您的
和where(…)
语句中。表t
没有属性关系
,而是要检查表r
:
$q = Doctrine_Query::create()
->from('Table t')
->leftJoin('t.Relations r')
->where('t.user_id = ?',$userId)
->andWhere('r.table_id IS NULL')
return $q->execute();
谢谢,这就是问题所在。我倒着想。
$q = Doctrine_Query::create()
->from('Table t')
->leftJoin('t.Relations r')
->where('t.user_id = ?',$userId)
->andWhere('r.table_id IS NULL')
return $q->execute();