diff --git a/models/Tag.php b/models/Tag.php index 13af5c7..14696f3 100644 --- a/models/Tag.php +++ b/models/Tag.php @@ -313,8 +313,7 @@ class Tag public function resetIdAsset() { $db = Registry::get('db'); - - $row = $db->query(' + $new_id = $db->queryValue(' SELECT MAX(id_asset) as new_id FROM assets_tags WHERE id_tag = {int:id_tag}', @@ -322,18 +321,12 @@ class Tag 'id_tag' => $this->id_tag, ]); - $new_id = 0; - if(!empty($row)) - { - $new_id = $row->fetch_assoc()['new_id']; - } - return $db->query(' UPDATE tags SET id_asset_thumb = {int:new_id} WHERE id_tag = {int:id_tag}', [ - 'new_id' => $new_id, + 'new_id' => $new_id ?? 0, 'id_tag' => $this->id_tag, ]); }