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.
精彩评论