From 4489277df87e022c2dc632a15f23e156f137db19 Mon Sep 17 00:00:00 2001 From: Marcin Kurczewski Date: Mon, 10 Nov 2014 20:04:38 +0100 Subject: [PATCH] Fixed bad SQL when looking for multiple uploaders --- src/Dao/PostDao.php | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/Dao/PostDao.php b/src/Dao/PostDao.php index dc9dc276..b2a31d7d 100644 --- a/src/Dao/PostDao.php +++ b/src/Dao/PostDao.php @@ -166,7 +166,16 @@ class PostDao extends AbstractDao implements ICrudDao 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)