Reduced query count for tag retrieval
This commit is contained in:
parent
332ca8e4b7
commit
4220a83589
1 changed files with 11 additions and 7 deletions
|
@ -24,13 +24,17 @@ class TagDao extends AbstractDao implements ICrudDao
|
||||||
|
|
||||||
public function findByPostId($postId)
|
public function findByPostId($postId)
|
||||||
{
|
{
|
||||||
$query = $this->fpdo->from('postTags')->where('postId', $postId);
|
return $this->findByPostIds([$postId]);
|
||||||
$tagIds = array_map(function($arrayEntity)
|
}
|
||||||
{
|
|
||||||
return $arrayEntity['tagId'];
|
public function findByPostIds($postIds)
|
||||||
},
|
{
|
||||||
iterator_to_array($query));
|
$query = $this->fpdo->from($this->tableName)
|
||||||
return $this->findByIds($tagIds);
|
->disableSmartJoin()
|
||||||
|
->innerJoin('postTags ON postTags.tagId = tags.id')
|
||||||
|
->where('postTags.postId', $postIds);
|
||||||
|
$arrayEntities = iterator_to_array($query);
|
||||||
|
return $this->arrayToEntities($arrayEntities);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function exportJson()
|
public function exportJson()
|
||||||
|
|
Loading…
Reference in a new issue