diff --git a/src/Models/AbstractCrudModel.php b/src/Models/AbstractCrudModel.php index 20d107fc..53ea77d4 100644 --- a/src/Models/AbstractCrudModel.php +++ b/src/Models/AbstractCrudModel.php @@ -40,7 +40,7 @@ abstract class AbstractCrudModel implements IModel $stmt = new SqlSelectStatement(); $stmt->setColumn('*'); $stmt->setTable(static::getTableName()); - $stmt->setCriterion(SqlInOperator::fromArray('id', SqlBinding::fromArray($ids))); + $stmt->setCriterion(SqlInOperator::fromArray('id', SqlBinding::fromArray(array_unique($ids)))); $rows = Database::fetchAll($stmt); if ($rows) diff --git a/src/Models/PostModel.php b/src/Models/PostModel.php index 848f1788..399373dd 100644 --- a/src/Models/PostModel.php +++ b/src/Models/PostModel.php @@ -187,7 +187,7 @@ class PostModel extends AbstractCrudModel $postMap[$postId] = $post; $tagsMap[$postId] = []; } - $postIds = array_keys($postMap); + $postIds = array_unique(array_keys($postMap)); $stmt = new SqlSelectStatement(); $stmt->setTable('tag'); @@ -213,9 +213,7 @@ class PostModel extends AbstractCrudModel } foreach ($tagsMap as $postId => $tags) - { $postMap[$postId]->setCache('tags', $tags); - } }