Browse Source

replace keywords match mode from OR to AND condition

main
ghost 1 year ago
parent
commit
5168280519
  1. 7
      src/Repository/TorrentRepository.php

7
src/Repository/TorrentRepository.php

@ -72,21 +72,22 @@ class TorrentRepository extends ServiceEntityRepository
if ($keywords) // @TODO ANY or DTS if ($keywords) // @TODO ANY or DTS
{ {
$orX = $query->expr()->orX(); $andX = $query->expr()->andX();
foreach ($keywords as $i => $keyword) foreach ($keywords as $i => $keyword)
{ {
$keyword = mb_strtolower($keyword); // all keywords stored in lowercase $keyword = mb_strtolower($keyword); // all keywords stored in lowercase
$orX->add("t.keywords LIKE :keyword{$i}"); $andX->add("t.keywords LIKE :keyword{$i}");
$query->setParameter(":keyword{$i}", "%{$keyword}%"); $query->setParameter(":keyword{$i}", "%{$keyword}%");
} }
$query->andWhere($orX); $query->andWhere($andX);
} }
if ($locales) // @TODO ANY or DTS if ($locales) // @TODO ANY or DTS
{ {
//$orX = $query->expr()->orX();
$orX = $query->expr()->orX(); $orX = $query->expr()->orX();
foreach ($locales as $i => $locale) foreach ($locales as $i => $locale)

Loading…
Cancel
Save