Clean up Tag::resetIdAsset

This commit is contained in:
Aaron van Geffen 2023-03-11 21:41:23 +01:00
parent aa3a54f237
commit 1b7e745f11

View File

@ -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,
]);
}