/** * Almacena las categorías a las que pertenece el artículo */ public function save_categories() { if (empty($this->categos)) { $this->add_categories(ShopFunctions::default_category_id()); } $this->db->queryF("DELETE FROM " . $this->db->prefix("shop_catprods") . " WHERE product='" . $this->id() . "'"); $sql = "INSERT INTO " . $this->db->prefix("shop_catprods") . " (`product`,`cat`) VALUES "; foreach ($this->categos as $k) { $sql .= "('" . $this->id() . "','{$k}'), "; } $sql = substr($sql, 0, strlen($sql) - 2); if ($this->db->queryF($sql)) { return true; } else { $this->addError($this->db->error()); return false; } }