/** * @return bool */ public function deleteAllCategories() { $sql = 'SELECT category_id FROM s_core_shops'; $shopCategoriesIds = $this->db->fetchCol($sql); //don't delete shop's categories if (empty($shopCategoriesIds)) { $sql = 'TRUNCATE s_categories'; } else { $ids = 'id != ' . implode(' AND id != ', $shopCategoriesIds); $sql = 'DELETE FROM s_categories WHERE parent IS NOT NULL AND ' . $ids; } if ($this->db->exec($sql) === false) { return false; } if ($this->db->exec('TRUNCATE s_articles_categories') === false) { return false; } if ($this->db->exec('TRUNCATE s_emarketing_banners') === false) { return false; } $sql = 'SELECT MAX(category_id) FROM s_core_shops'; $lastCategoryId = $this->db->fetchOne($sql); $auto_increment = empty($lastCategoryId) ? 2 : $lastCategoryId + 1; $sql = 'ALTER TABLE s_categories AUTO_INCREMENT = ' . $auto_increment; if ($this->db->exec($sql) === false) { return false; } return true; }
/** * @param array $customerData * @param integer $customerId * @param Customer|boolean $newCustomer * @throws \Zend_Db_Adapter_Exception */ protected function insertCustomerAttributes(array $customerData, $customerId, $newCustomer) { if ($newCustomer === false) { return; } if (isset($customerData['attribute'])) { return; } $sql = "INSERT INTO s_user_attributes (userID) VALUES ({$customerId})"; $this->db->exec($sql); }
/** * Creates categories' attributes * * @param int $categoryId */ protected function insertCategoryAttributes($categoryId) { $sql = "INSERT INTO s_categories_attributes (categoryID) VALUES ({$categoryId})"; $this->db->exec($sql); }