| @@ 18-36 (lines=19) @@ | ||
| 15 | * @param string $keyword |
|
| 16 | * @return mixed |
|
| 17 | */ |
|
| 18 | public function searchByKeyword($keyword) |
|
| 19 | { |
|
| 20 | $qb = $this->createQueryBuilder('a'); |
|
| 21 | ||
| 22 | //Selecting user info |
|
| 23 | $qb->select('DISTINCT b'); |
|
| 24 | ||
| 25 | $qb->from('Chamilo\CoreBundle\Entity\BranchSync', 'b'); |
|
| 26 | ||
| 27 | //Selecting courses for users |
|
| 28 | //$qb->innerJoin('u.courses', 'c'); |
|
| 29 | ||
| 30 | //@todo check app settings |
|
| 31 | $qb->add('orderBy', 'b.branchName ASC'); |
|
| 32 | $qb->where('b.branchName LIKE :keyword'); |
|
| 33 | $qb->setParameter('keyword', "%$keyword%"); |
|
| 34 | $q = $qb->getQuery(); |
|
| 35 | return $q->execute(); |
|
| 36 | } |
|
| 37 | } |
|
| 38 | ||
| @@ 31-50 (lines=20) @@ | ||
| 28 | * |
|
| 29 | * @return mixed |
|
| 30 | */ |
|
| 31 | public function searchUserByKeyword($keyword) |
|
| 32 | { |
|
| 33 | $qb = $this->createQueryBuilder('a'); |
|
| 34 | ||
| 35 | // Selecting user info |
|
| 36 | $qb->select('DISTINCT b'); |
|
| 37 | ||
| 38 | $qb->from('Chamilo\UserBundle\Entity\User', 'b'); |
|
| 39 | ||
| 40 | // Selecting courses for users |
|
| 41 | //$qb->innerJoin('u.courses', 'c'); |
|
| 42 | ||
| 43 | //@todo check app settings |
|
| 44 | $qb->add('orderBy', 'b.firstname ASC'); |
|
| 45 | $qb->where('b.firstname LIKE :keyword OR b.lastname LIKE :keyword '); |
|
| 46 | $qb->setParameter('keyword', "%$keyword%"); |
|
| 47 | $query = $qb->getQuery(); |
|
| 48 | ||
| 49 | return $query->execute(); |
|
| 50 | } |
|
| 51 | ||
| 52 | /** |
|
| 53 | * Get course user relationship based in the course_rel_user table. |
|