Faster preloading
This commit is contained in:
parent
e6b37afa8c
commit
3a2a686b6c
2 changed files with 2 additions and 4 deletions
|
@ -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)
|
||||
|
|
|
@ -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,10 +213,8 @@ class PostModel extends AbstractCrudModel
|
|||
}
|
||||
|
||||
foreach ($tagsMap as $postId => $tags)
|
||||
{
|
||||
$postMap[$postId]->setCache('tags', $tags);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue