From 1b7e745f1135d06054fefa80a3e1148c22410823 Mon Sep 17 00:00:00 2001 From: Aaron van Geffen Date: Sat, 11 Mar 2023 21:41:23 +0100 Subject: [PATCH] Clean up Tag::resetIdAsset --- models/Tag.php | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) 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, ]); }