开发者

Doctrine query for authentication

开发者 https://www.devze.com 2023-02-22 18:36 出处:网络
Consider this query: $query = Doctrine::getTable(\'sfGuardUser\') ->createQuery(\'u\') ->innerJoin(\'u.Groups g\')

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

精彩评论

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

关注公众号