Doctrine2 allows you to query using magic finders based on field names. If you have an entity named User you should able to call $repo->findOneByUsernameAndPassword() assuming that the entity has username and password fields.
How can i pass parameters to magic finders? How to query when the field that is actually a relation?
I've tried:
$repo->findOneByUsernameAndPassword('Jhon', 'password')
and
$开发者_JAVA百科repo->findOneByUsernameAndPassword(array('Jhon', 'password'))
but i'm getting the error:
Entity 'User' has no field 'usernameAndPassword'. You can therefore not call 'findOneByUsernameAndPassword'
I couldn't find any reference for this syntax with Doctrine 2, though it was possible with Doctrine 1. I used it myself then and remember having problems getting it to work. Now you would rather do this I guess :
$repo->findOneBy(array('username' => 'Jhon', 'password' => 'password'));
You can get more information in this § of the Doctrine 2 documentation
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论