Skip to content

Commit

Permalink
Fixed DQL query
Browse files Browse the repository at this point in the history
  • Loading branch information
Aarhunt authored and rinkp committed Feb 17, 2024
1 parent 97d459a commit 44bb24c
Showing 1 changed file with 4 additions and 6 deletions.
10 changes: 4 additions & 6 deletions module/Database/src/Mapper/Meeting.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
use Doctrine\ORM\EntityRepository;

use function implode;
use function str_replace;
use function strtolower;

class Meeting
Expand Down Expand Up @@ -46,20 +47,17 @@ public function searchMeeting(

$fields = [];
$fields[] = 'LOWER(m.type)';
$fields[] = "' '";
$fields[] = 'm.number';
$fields[] = "' '";
$fields = implode(', ', $fields);
$fields = 'CONCAT(' . $fields . ')';

$qb->select('m')
->from(MeetingModel::class, 'm')
->where($fields . ' LIKE :search')
->andWhere('CONCAT(m.number, \'\') NOT LIKE :searchClean')
->orderBy('m.date');
->orWhere('CONCAT(m.number, \'\') LIKE :search')
->orderBy('m.date', 'DESC');

$qb->setParameter(':search', '%' . strtolower($query) . '%');
$qb->setParameter(':searchClean', '%_' . strtolower($query));
$qb->setParameter(':search', str_replace(' ', '', strtolower($query)) . '%');

return $qb->getQuery()->getResult();
}
Expand Down

0 comments on commit 44bb24c

Please sign in to comment.