开发者

Doctrine query for authentication

Consider this query:

$query = Doctrine::getTable('sfGuardUser')
      ->createQuery('u')
      ->innerJoin('u.Groups g')
      ->where('u.name = 'username')
      ->adnWhere('g.name <> 'groupname')

This return a user with 'username' regardless of his 'groupname'. I need to only retu开发者_如何学Crn a user if he does NOT have a 'groupname' relation.


You should use the WITH keyword in your inner join. This basically add conditions to the implicit ON clause of the inner join.

$query = Doctrine::getTable('sfGuardUser')
      ->createQuery('u')
      ->innerJoin("u.Groups g WITH g.name <> 'groupname'")
      ->where('u.name = 'username')

More info here.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜