Fixed saving tags under certain circumstances
This commit is contained in:
parent
8f7985bd83
commit
34752529b5
1 changed files with 6 additions and 1 deletions
|
@ -46,7 +46,12 @@ class PostDao extends AbstractDao implements ICrudDao
|
||||||
|
|
||||||
private function syncTags($postId, array $tags)
|
private function syncTags($postId, array $tags)
|
||||||
{
|
{
|
||||||
$existingTags = iterator_to_array($this->fpdo->from('postTags')->where('postId', $postId));
|
$existingTags = array_map(
|
||||||
|
function($arrayEntity)
|
||||||
|
{
|
||||||
|
return $arrayEntity['tagName'];
|
||||||
|
},
|
||||||
|
iterator_to_array($this->fpdo->from('postTags')->where('postId', $postId)));
|
||||||
$tagRelationsToInsert = array_diff($tags, $existingTags);
|
$tagRelationsToInsert = array_diff($tags, $existingTags);
|
||||||
$tagRelationsToDelete = array_diff($existingTags, $tags);
|
$tagRelationsToDelete = array_diff($existingTags, $tags);
|
||||||
$this->createMissingTags($tags);
|
$this->createMissingTags($tags);
|
||||||
|
|
Loading…
Reference in a new issue