Autocomplete search bug fix.

This commit is contained in:
Alexey Skobkin 2016-12-11 03:54:14 +03:00
parent 4c3191aa86
commit 23042cf2b1

View file

@ -32,10 +32,11 @@ class UserRepository extends EntityRepository
* Case insensitive user LIKE %login% search * Case insensitive user LIKE %login% search
* *
* @param string $login * @param string $login
* @param int $limit
* *
* @return User[] * @return User[]
*/ */
public function findUsersLikeLogin($login) public function findUsersLikeLogin($login, $limit = 10)
{ {
if (empty($login)) { if (empty($login)) {
return []; return [];
@ -44,10 +45,10 @@ class UserRepository extends EntityRepository
$qb = $this->createQueryBuilder('u'); $qb = $this->createQueryBuilder('u');
return $qb return $qb
->where('u.login LIKE :login') ->where('LOWER(u.login) LIKE LOWER(:login)')
->orderBy('u.login', 'ASC') ->orderBy('u.login', 'ASC')
->setMaxResults(10) ->setMaxResults($limit)
->setParameter('login', '%'.strtolower($login).'%') ->setParameter('login', '%'.$login.'%')
->getQuery() ->getQuery()
->getResult() ->getResult()
; ;