Skip to content

Instantly share code, notes, and snippets.

View kaspy003's full-sized avatar

Kaspars Siliņš kaspy003

View GitHub Profile
if(query("UPDATE `store_items` SET
".(!empty($cats) ? "`cats` = '".mysqli_real_escape_string(db(), $cats)."',":"")."
".(!empty($simular) ? "`simular_cats` = '".mysqli_real_escape_string(db(), $simular)."',":"")."
`date` = NOW()
WHERE `id` = '".(int) $post['id']."'
") && mysqli_affected_rows(db())){}
public static function updateItem($post){
$item = self::getItemByID($post['id']);
if(!empty($item)){
$deleteCatItems = self::deleteItemCatsByItem($post['id']);
$deleteCatItemsSimular = self::deleteItemSimularCatsByItem($post['id']);
if(query("UPDATE `store_items` SET
".(!empty($post['title']) ? "`title` = '".mysqli_real_escape_string(db(), $post['title'])."',":"")."
".(!empty($post['subtitle']) ? "`subtitle` = '".mysqli_real_escape_string(db(), $post['subtitle'])."',":"`subtitle` = '',")."
".(!empty($post['code']) ? "`code` = '".mysqli_real_escape_string(db(), $post['code'])."'," : "`code` = '',")."
".(!empty($item['url']) ? "`url` = '".mysqli_real_escape_string(db(), $item['url'])."',":"")."