Improved search speed
This commit is contained in:
parent
da6c4681fa
commit
99b08879bd
1 changed files with 7 additions and 3 deletions
|
@ -118,16 +118,20 @@ class PostDao extends AbstractDao implements ICrudDao
|
||||||
{
|
{
|
||||||
if ($requirement->getType() === PostFilter::REQUIREMENT_TAG)
|
if ($requirement->getType() === PostFilter::REQUIREMENT_TAG)
|
||||||
{
|
{
|
||||||
|
$tagName = $requirement->getValue()->getValue();
|
||||||
|
$tag = $this->tagDao->findByName($tagName);
|
||||||
|
if (!$tag)
|
||||||
|
throw new \DomainException('Invalid tag: "' . $tagName . '"');
|
||||||
|
|
||||||
$sql = 'EXISTS (
|
$sql = 'EXISTS (
|
||||||
SELECT 1 FROM postTags
|
SELECT 1 FROM postTags
|
||||||
INNER JOIN tags ON postTags.tagId = tags.id
|
|
||||||
WHERE postTags.postId = posts.id
|
WHERE postTags.postId = posts.id
|
||||||
AND LOWER(tags.name) = LOWER(?))';
|
AND postTags.tagId = ?)';
|
||||||
|
|
||||||
if ($requirement->isNegated())
|
if ($requirement->isNegated())
|
||||||
$sql = 'NOT ' . $sql;
|
$sql = 'NOT ' . $sql;
|
||||||
|
|
||||||
$query->where($sql, $requirement->getValue()->getValue());
|
$query->where($sql, $tag->getId());
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue