Fixed bad SQL when looking for multiple uploaders

This commit is contained in:
Marcin Kurczewski 2014-11-10 20:04:38 +01:00
parent b7e2c28780
commit 4489277df8

View file

@ -166,7 +166,16 @@ class PostDao extends AbstractDao implements ICrudDao
elseif ($requirement->getType() === PostFilter::REQUIREMENT_UPLOADER) elseif ($requirement->getType() === PostFilter::REQUIREMENT_UPLOADER)
{ {
$query->innerJoin('users uploader', 'uploader.id = posts.userId'); foreach ($requirement->getValue()->getValues() as $userName)
{
$alias = 'u' . uniqid();
$query->innerJoin('users ' . $alias, $alias . '.id = posts.userId');
$sql = $alias . '.name = ?';
if ($requirement->isNegated())
$sql = 'NOT ' . $sql;
$query->where($sql, [$userName]);
}
return;
} }
elseif ($requirement->getType() === PostFilter::REQUIREMENT_USER_SCORE) elseif ($requirement->getType() === PostFilter::REQUIREMENT_USER_SCORE)