问题
I'm using the login form from Symfony, but I can't login, if the entered username is 'FOO' and in the DB is stored 'foo'. I'm using Postgres. It means the username-field is case sensitive. What can I do?
回答1:
This depends mainly on your Database-Server. MySQL is case insensitive, PostgreSQL is case sensitive.
But you can write query Like this
$this->createQueryBuilder('user')
->where('LOWER(user.username) = :username')
->setParameter('username', strtolower($username))
->getQuery()
->getResult()
;
来源:https://stackoverflow.com/questions/56183229/how-to-do-username-case-insensitive-in-login-form