From a14512dd19afe71b232aed3e5632459330e6ac75 Mon Sep 17 00:00:00 2001 From: Jacek Pyziak Date: Tue, 12 Aug 2025 09:57:03 +0200 Subject: [PATCH] =?UTF-8?q?Zaktualizuj=20metod=C4=99=20set=5Fproduct=5Fdat?= =?UTF-8?q?a=20w=20klasie=20Products,=20aby=20obs=C5=82ugiwa=C5=82a=20wsta?= =?UTF-8?q?wianie=20nowych=20danych,=20je=C5=9Bli=20produkt=20nie=20istnie?= =?UTF-8?q?je.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .vscode/ftp-kr.sync.cache.json | 4 ++-- autoload/factory/class.Products.php | 7 ++++++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/.vscode/ftp-kr.sync.cache.json b/.vscode/ftp-kr.sync.cache.json index fb68005..91ca89a 100644 --- a/.vscode/ftp-kr.sync.cache.json +++ b/.vscode/ftp-kr.sync.cache.json @@ -73,8 +73,8 @@ }, "class.Products.php": { "type": "-", - "size": 4561, - "lmtime": 1744062307424, + "size": 4579, + "lmtime": 1754740016569, "modified": false }, "class.Users.php": { diff --git a/autoload/factory/class.Products.php b/autoload/factory/class.Products.php index 5661023..ece0a18 100644 --- a/autoload/factory/class.Products.php +++ b/autoload/factory/class.Products.php @@ -49,7 +49,12 @@ class Products static public function set_product_data( $product_id, $field, $value ) { global $mdb; - return $mdb -> update( 'products_data', [ $field => $value ], [ 'product_id' => $product_id ] ); + + if ( !$mdb -> count( 'products_data', [ 'product_id' => $product_id ] ) ) + $result = $mdb -> insert( 'products_data', [ 'product_id' => $product_id, $field => $value ] ); + else + $result = $mdb -> update( 'products_data', [ $field => $value ], [ 'product_id' => $product_id ] ); + return $result; } static public function get_product_history( $client_id, $product_id, $start, $limit )