本文整理汇总了PHP中DbQuery::orderBy方法的典型用法代码示例。如果您正苦于以下问题:PHP DbQuery::orderBy方法的具体用法?PHP DbQuery::orderBy怎么用?PHP DbQuery::orderBy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DbQuery
的用法示例。
在下文中一共展示了DbQuery::orderBy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: postProcess
public function postProcess()
{
if (Tools::isSubmit('update' . $this->table)) {
$campaign_id = (int) Tools::getValue('campaign_id');
if ($campaign_id > 0) {
Tools::redirectAdmin('index.php?controller=AdminMarketingFStep1&campaign_id=' . $campaign_id . '&token=' . Tools::getAdminTokenLite('AdminMarketingFStep1'));
exit;
}
}
if (Tools::isSubmit('delete' . $this->table)) {
$campaign_id = (int) Tools::getValue('campaign_id');
if ($campaign_id > 0) {
// On masque la campagne via son champ 'state'
// -------------------------------------------
Db::getInstance()->delete('expressmailing_fax_recipients', 'campaign_id = ' . $campaign_id);
$req = new DbQuery();
$req->select('*');
$req->from('expressmailing_fax_pages');
$req->where('campaign_id = ' . $campaign_id);
$req->orderBy('id');
$pages_db = Db::getInstance()->executeS($req, true, false);
foreach ($pages_db as $page) {
unlink($page['page_path']);
unlink($page['page_path_original']);
}
Db::getInstance()->delete('expressmailing_fax_pages', 'campaign_id = ' . $campaign_id);
Db::getInstance()->update($this->table, array('campaign_state' => self::FINISHED, 'campaign_date_update' => date('Y-m-d H:i:s')), 'campaign_id = ' . $campaign_id);
}
}
}
示例2: getLastId
public static function getLastId()
{
$query = new DbQuery();
$query->select('id_stock_mvt');
$query->from('stock_mvt');
$query->orderBy('id_stock_mvt DESC');
return Db::getInstance()->getValue($query);
}
示例3: getAll
public static function getAll()
{
$sql = new DbQuery();
$sql->select('id_simpleblog_post_type, name');
$sql->from('simpleblog_post_type', 'sbpt');
$sql->orderBy('id_simpleblog_post_type ASC');
return Db::getInstance()->executeS($sql);
}
示例4: getNextBadgeId
public function getNextBadgeId()
{
$query = new DbQuery();
$query->select('b.`id_badge`');
$query->from('badge', 'b');
$query->where('b.id_group = \'' . pSQL($this->id_group) . '\' AND b.validated = 0');
$query->orderBy('b.group_position');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
}
示例5: getLastId
public function getLastId()
{
// build query
$query = new DbQuery();
$query->select('id_erpip_inventory');
$query->from('erpip_inventory', 'i');
$query->orderBy('id_erpip_inventory DESC');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
}
示例6: getSuppliers
/**
* Return suppliers
*
* @return array Suppliers
*/
public static function getSuppliers($get_nb_products = false, $id_lang = 0, $active = true, $p = false, $n = false, $all_groups = false)
{
if (!$id_lang) {
$id_lang = Configuration::get('PS_LANG_DEFAULT');
}
$query = new DbQuery();
$query->select('s.*, sl.`description`');
$query->from('supplier', 's');
$query->leftJoin('supplier_lang', 'sl', 's.`id_supplier` = sl.`id_supplier` AND sl.`id_lang` = ' . (int) $id_lang);
$query->join(Shop::addSqlAssociation('supplier', 's'));
if ($active) {
$query->where('s.`active` = 1');
}
$query->orderBy(' s.`name` ASC');
$query->limit($n, ($p - 1) * $n);
$query->groupBy('s.id_supplier');
$suppliers = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
if ($suppliers === false) {
return false;
}
if ($get_nb_products) {
$sql_groups = '';
if (!$all_groups) {
$groups = FrontController::getCurrentCustomerGroups();
$sql_groups = count($groups) ? 'IN (' . implode(',', $groups) . ')' : '= 1';
}
foreach ($suppliers as $key => $supplier) {
$sql = '
SELECT DISTINCT(ps.`id_product`)
FROM `' . _DB_PREFIX_ . 'product_supplier` ps
JOIN `' . _DB_PREFIX_ . 'product` p ON (ps.`id_product`= p.`id_product`)
' . Shop::addSqlAssociation('product', 'p') . '
WHERE ps.`id_supplier` = ' . (int) $supplier['id_supplier'] . '
AND ps.id_product_attribute = 0' . ($active ? ' AND product_shop.`active` = 1' : '') . ($all_groups ? '' : '
AND ps.`id_product` IN (
SELECT cp.`id_product`
FROM `' . _DB_PREFIX_ . 'category_group` cg
LEFT JOIN `' . _DB_PREFIX_ . 'category_product` cp ON (cp.`id_category` = cg.`id_category`)
WHERE cg.`id_group` ' . $sql_groups . '
)');
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql);
$suppliers[$key]['nb_products'] = count($result);
}
}
$nb_suppliers = count($suppliers);
$rewrite_settings = (int) Configuration::get('PS_REWRITING_SETTINGS');
for ($i = 0; $i < $nb_suppliers; $i++) {
if ($rewrite_settings) {
$suppliers[$i]['link_rewrite'] = Tools::link_rewrite($suppliers[$i]['name'], false);
} else {
$suppliers[$i]['link_rewrite'] = 0;
}
}
return $suppliers;
}
示例7: getAllById
public static function getAllById($id_simpleblog_post)
{
if (!Validate::isUnsignedInt($id_simpleblog_post)) {
return Tools::displayError('getAllById - invalid ID');
}
$sql = new DbQuery();
$sql->select('*');
$sql->from('simpleblog_post_image', 'sbpi');
$sql->where('id_simpleblog_post = ' . (int) $id_simpleblog_post);
$sql->orderBy('position ASC');
return Db::getInstance()->executeS($sql);
}
示例8: getPosts
public static function getPosts($id_lang, $limit = 10, $id_simpleblog_category = null, $page = null, $active = true, $orderby = false, $orderway = false, $exclude = null, $featured = false, $author = false, $id_shop = null, $filter = false, $selected = array())
{
$context = Context::getContext();
$start = $limit * ($page == 0 ? 0 : $page - 1);
$sql = new DbQuery();
$sql->select('*');
$sql->from('simpleblog_post', 'sbp');
if ($id_lang) {
$sql->innerJoin('simpleblog_post_lang', 'l', 'sbp.id_simpleblog_post = l.id_simpleblog_post AND l.id_lang = ' . (int) $id_lang);
}
if (!$id_shop) {
$id_shop = $context->shop->id;
}
$sql->innerJoin('simpleblog_post_shop', 'sbps', 'sbp.id_simpleblog_post = sbps.id_simpleblog_post AND sbps.id_shop = ' . (int) $id_shop);
if ($active) {
$sql->where('sbp.active = 1');
}
if (isset($id_simpleblog_category) && (int) $id_simpleblog_category > 0) {
$sql->where('sbp.id_simpleblog_category = ' . (int) $id_simpleblog_category);
}
if ($exclude) {
$sql->where('sbp.id_simpleblog_post != ' . (int) $exclude);
}
if ($featured) {
$sql->where('sbp.is_featured = 1');
}
if ($author && Configuration::get('PH_BLOG_POST_BY_AUTHOR')) {
$sql->where('sbp.author = \'' . pSQL($author) . '\'');
}
if ($filter) {
$sql->where('sbp.id_simpleblog_post ' . $filter . ' (' . join(',', $selected) . ')');
}
if (isset($context->customer) && !$context->customer->isLogged()) {
$sql->where('sbp.logged = 0');
}
if (!$orderby) {
$orderby = 'sbp.id_simpleblog_post';
}
if (!$orderway) {
$orderway = 'DESC';
}
$sql->orderBy($orderby . ' ' . $orderway);
$sql->limit($limit, $start);
$result = Db::getInstance()->executeS($sql);
if (sizeof($result)) {
foreach ($result as &$row) {
$category_rewrite = SimpleBlogCategory::getRewriteByCategory($row['id_simpleblog_category'], $id_lang);
$category_obj = new SimpleBlogCategory($row['id_simpleblog_category'], $id_lang);
$category_url = SimpleBlogCategory::getLink($category_obj->link_rewrite, $id_lang);
if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '.' . $row['cover'])) {
$row['banner'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '.' . $row['cover'];
$row['banner_thumb'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '-thumb.' . $row['cover'];
$row['banner_wide'] = _MODULE_DIR_ . 'ph_simpleblog/covers/' . $row['id_simpleblog_post'] . '-wide.' . $row['cover'];
}
if (file_exists(_PS_MODULE_DIR_ . 'ph_simpleblog/featured/' . $row['id_simpleblog_post'] . '.' . $row['featured'])) {
$row['featured'] = _MODULE_DIR_ . 'ph_simpleblog/featured/' . $row['id_simpleblog_post'] . '.' . $row['featured'];
}
$row['url'] = self::getLink($row['link_rewrite'], $category_obj->link_rewrite, $id_lang);
$row['category'] = $category_obj->name;
$row['category_url'] = $category_url;
$tags = SimpleBlogTag::getPostTags($row['id_simpleblog_post']);
$row['tags'] = isset($tags[$id_lang]) && sizeof($tags[$id_lang] > 0) ? $tags[$id_lang] : false;
}
} else {
return;
}
return $result;
}
示例9: getList
/**
* AdminController::getList() override
* @see AdminController::getList()
*/
public function getList($id_lang, $order_by = null, $order_way = null, $start = 0, $limit = null, $id_lang_shop = false)
{
parent::getList($id_lang, $order_by, $order_way, $start, $limit, $id_lang_shop);
if ($this->ajax) {
foreach ($this->_list as &$list) {
if (file_exists(_PS_IMG_DIR_ . $this->fieldImageSettings['dir'] . '/' . (int) $list['id_attribute'] . '.jpg')) {
if (!isset($list['color']) || !is_array($list['color'])) {
$list['color'] = array();
}
$list['color']['texture'] = '../img/' . $this->fieldImageSettings['dir'] . '/' . (int) $list['id_attribute'] . '.jpg';
}
}
} else {
$nb_items = count($this->_list);
for ($i = 0; $i < $nb_items; ++$i) {
$item =& $this->_list[$i];
$query = new DbQuery();
$query->select('COUNT(a.id_attribute) as count_values');
$query->from('attribute', 'a');
$query->join(Shop::addSqlAssociation('attribute', 'a'));
$query->where('a.id_attribute_group =' . (int) $item['id_attribute_group']);
$query->groupBy('attribute_shop.id_shop');
$query->orderBy('count_values DESC');
$item['count_values'] = (int) Db::getInstance(_PS_USE_SQL_SLAVE_)->getValue($query);
unset($query);
}
}
}
示例10: getListCaptured
public function getListCaptured()
{
if (version_compare(_PS_VERSION_, '1.5', '<')) {
$query = 'SELECT * FROM ' . _DB_PREFIX_ . 'paypal_capture WHERE id_order =' . $this->id_order . ' ORDER BY date_add DESC ;';
} else {
$query = new DbQuery();
$query->from(self::$definition['table']);
$query->where('id_order = ' . $this->id_order);
$query->orderBy('date_add DESC');
}
$result = DB::getInstance()->executeS($query);
if (version_compare(_PS_VERSION_, '1.5', '<')) {
foreach ($result as &$foo) {
$foo['date'] = Tools::displayDate($foo['date_add'], Configuration::get('PS_LANG_DEFAULT'), true);
}
}
return $result;
}
示例11: sqlGroupBy
/**
* Add GROUP BY restriction on query using real SQL syntax
*
* @param string $sql
* @return Collection
*/
public function sqlGroupBy($sql)
{
$this->query->orderBy($this->parseFields($sql));
return $this;
}
示例12: getStates
/**
* Gets the list of supply order statuses
*
* @param array $ids Optional Do not include these ids in the result
* @param int $id_lang Optional
* @return array
*/
public static function getStates($ids = null, $id_lang = null)
{
if ($id_lang == null) {
$id_lang = Context::getContext()->language->id;
}
if ($ids && !is_array($ids)) {
$ids = array();
}
$query = new DbQuery();
$query->select('sl.name, s.id_supply_order_state');
$query->from('supply_order_state', 's');
$query->leftjoin('supply_order_state_lang', 'sl', 's.id_supply_order_state = sl.id_supply_order_state AND sl.id_lang=' . (int) $id_lang);
if ($ids) {
$query->where('s.id_supply_order_state NOT IN(' . implode(',', array_map('intval', $ids)) . ')');
}
$query->orderBy('sl.name ASC');
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($query);
}
示例13: getEntityContents
/**
* ONLY FOR DEVELOPMENT PURPOSE
*/
public function getEntityContents($entity)
{
$xml = $this->loadEntity($entity);
$primary = isset($xml->fields['primary']) && $xml->fields['primary'] ? (string) $xml->fields['primary'] : 'id_' . $entity;
$is_multilang = $this->isMultilang($entity);
// Check if current table is an association table (if multiple primary keys)
$is_association = false;
if (strpos($primary, ',') !== false) {
$is_association = true;
$primary = array_map('trim', explode(',', $primary));
}
// Build query
$sql = new DbQuery();
$sql->select('a.*');
$sql->from($entity, 'a');
if ($is_multilang) {
$sql->select('b.*');
$sql->leftJoin($entity . '_lang', 'b', 'a.' . $primary . ' = b.' . $primary);
}
if (isset($xml->fields['sql']) && $xml->fields['sql']) {
$sql->where((string) $xml->fields['sql']);
}
if (!$is_association) {
$sql->select('a.' . $primary);
if (!isset($xml->fields['ordersql']) || !$xml->fields['ordersql']) {
$sql->orderBy('a.' . $primary);
}
}
if ($is_multilang && (!isset($xml->fields['ordersql']) || !$xml->fields['ordersql'])) {
$sql->orderBy('b.id_lang');
}
if (isset($xml->fields['ordersql']) && $xml->fields['ordersql']) {
$sql->orderBy((string) $xml->fields['ordersql']);
}
// Get multilang columns
$alias_multilang = array();
if ($is_multilang) {
$columns = $this->getColumns($entity);
$multilang_columns = $this->getColumns($entity, true);
// If some columns from _lang table have same name than original table, rename them (E.g. value in configuration)
foreach ($multilang_columns as $c => $is_text) {
if (isset($columns[$c])) {
$alias = $c . '_alias';
$alias_multilang[$c] = $alias;
$sql->select('a.' . $c . ' as ' . $c . ', b.' . $c . ' as ' . $alias);
}
}
}
// Get all results
$nodes = $nodes_lang = array();
$results = Db::getInstance()->executeS($sql);
if (Db::getInstance()->getNumberError()) {
$this->setError($this->language->l('SQL error on query <i>%s</i>', $sql));
} else {
foreach ($results as $row) {
// Store common columns
if ($is_association) {
$id = $entity;
foreach ($primary as $key) {
$id .= '_' . $row[$key];
}
} else {
$id = $this->generateId($entity, $row[$primary], $row, isset($xml->fields['id']) && $xml->fields['id'] ? (string) $xml->fields['id'] : null);
}
if (!isset($nodes[$id])) {
$node = array();
foreach ($xml->fields->field as $field) {
$column = (string) $field['name'];
if (isset($field['relation'])) {
$sql = 'SELECT `id_' . bqSQL($field['relation']) . '`
FROM `' . bqSQL(_DB_PREFIX_ . $field['relation']) . '`
WHERE `id_' . bqSQL($field['relation']) . '` = ' . (int) $row[$column];
$node[$column] = $this->generateId((string) $field['relation'], Db::getInstance()->getValue($sql));
// A little trick to allow storage of some hard values, like '-1' for tab.id_parent
if (!$node[$column] && $row[$column]) {
$node[$column] = $row[$column];
}
} else {
$node[$column] = $row[$column];
}
}
$nodes[$id] = $node;
}
// Store multilang columns
if ($is_multilang && $row['id_lang']) {
$node = array();
foreach ($multilang_columns as $column => $is_text) {
$node[$column] = $row[isset($alias_multilang[$column]) ? $alias_multilang[$column] : $column];
}
$nodes_lang[$row['id_lang']][$id] = $node;
}
}
}
return array('nodes' => $nodes, 'nodes_lang' => $nodes_lang);
}
示例14: getProducts
public function getProducts($refresh = false, $id_product = false, $id_country = null)
{
/*
* EU-Legal
* 1) correct calculation of prices -> Problem with inaccuracy at high number of items
* 2) assign standard delivery times to products
*/
if (!$this->id) {
return array();
}
// Product cache must be strictly compared to NULL, or else an empty cart will add dozens of queries
if ($this->_products !== null && !$refresh) {
// Return product row with specified ID if it exists
if (is_int($id_product)) {
foreach ($this->_products as $product) {
if ($product['id_product'] == $id_product) {
return array($product);
}
}
return array();
}
return $this->_products;
}
// Build query
$sql = new DbQuery();
// Build SELECT
$sql->select('cp.`id_product_attribute`, cp.`id_product`, cp.`quantity` AS cart_quantity, cp.id_shop, pl.`name`, p.`is_virtual`,
pl.`description_short`, pl.`available_now`, pl.`available_later`, pl.`delivery_now`, pl.`delivery_later`, product_shop.`id_category_default`, p.`id_supplier`,
p.`id_manufacturer`, product_shop.`on_sale`, product_shop.`ecotax`, product_shop.`additional_shipping_cost`,
product_shop.`available_for_order`, product_shop.`price`, product_shop.`active`, product_shop.`unity`, product_shop.`unit_price_ratio`,
stock.`quantity` AS quantity_available, p.`width`, p.`height`, p.`depth`, stock.`out_of_stock`, p.`weight`,
p.`date_add`, p.`date_upd`, IFNULL(stock.quantity, 0) as quantity, pl.`link_rewrite`, cl.`link_rewrite` AS category,
CONCAT(LPAD(cp.`id_product`, 10, 0), LPAD(IFNULL(cp.`id_product_attribute`, 0), 10, 0), IFNULL(cp.`id_address_delivery`, 0)) AS unique_id, cp.id_address_delivery,
product_shop.advanced_stock_management, ps.product_supplier_reference supplier_reference, IFNULL(sp.`reduction_type`, 0) AS reduction_type');
// Build FROM
$sql->from('cart_product', 'cp');
// Build JOIN
$sql->leftJoin('product', 'p', 'p.`id_product` = cp.`id_product`');
$sql->innerJoin('product_shop', 'product_shop', '(product_shop.`id_shop` = cp.`id_shop` AND product_shop.`id_product` = p.`id_product`)');
$sql->leftJoin('product_lang', 'pl', '
p.`id_product` = pl.`id_product`
AND pl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('pl', 'cp.id_shop'));
$sql->leftJoin('category_lang', 'cl', '
product_shop.`id_category_default` = cl.`id_category`
AND cl.`id_lang` = ' . (int) $this->id_lang . Shop::addSqlRestrictionOnLang('cl', 'cp.id_shop'));
$sql->leftJoin('product_supplier', 'ps', 'ps.`id_product` = cp.`id_product` AND ps.`id_product_attribute` = cp.`id_product_attribute` AND ps.`id_supplier` = p.`id_supplier`');
$sql->leftJoin('specific_price', 'sp', 'sp.`id_product` = cp.`id_product`');
// AND 'sp.`id_shop` = cp.`id_shop`
// @todo test if everything is ok, then refactorise call of this method
$sql->join(Product::sqlStock('cp', 'cp'));
// Build WHERE clauses
$sql->where('cp.`id_cart` = ' . (int) $this->id);
if ($id_product) {
$sql->where('cp.`id_product` = ' . (int) $id_product);
}
$sql->where('p.`id_product` IS NOT NULL');
// Build GROUP BY
$sql->groupBy('unique_id');
// Build ORDER BY
$sql->orderBy('cp.`date_add`, p.`id_product`, cp.`id_product_attribute` ASC');
if (Customization::isFeatureActive()) {
$sql->select('cu.`id_customization`, cu.`quantity` AS customization_quantity');
$sql->leftJoin('customization', 'cu', 'p.`id_product` = cu.`id_product` AND cp.`id_product_attribute` = cu.`id_product_attribute` AND cu.`id_cart` = ' . (int) $this->id);
} else {
$sql->select('NULL AS customization_quantity, NULL AS id_customization');
}
if (Combination::isFeatureActive()) {
$sql->select('
product_attribute_shop.`price` AS price_attribute, product_attribute_shop.`ecotax` AS ecotax_attr,
IF (IFNULL(pa.`reference`, \'\') = \'\', p.`reference`, pa.`reference`) AS reference,
(p.`weight`+ pa.`weight`) weight_attribute,
IF (IFNULL(pa.`ean13`, \'\') = \'\', p.`ean13`, pa.`ean13`) AS ean13,
IF (IFNULL(pa.`upc`, \'\') = \'\', p.`upc`, pa.`upc`) AS upc,
pai.`id_image` as pai_id_image, il.`legend` as pai_legend,
IFNULL(product_attribute_shop.`minimal_quantity`, product_shop.`minimal_quantity`) as minimal_quantity,
IF(product_attribute_shop.wholesale_price > 0, product_attribute_shop.wholesale_price, product_shop.`wholesale_price`) wholesale_price
');
$sql->leftJoin('product_attribute', 'pa', 'pa.`id_product_attribute` = cp.`id_product_attribute`');
$sql->leftJoin('product_attribute_shop', 'product_attribute_shop', '(product_attribute_shop.`id_shop` = cp.`id_shop` AND product_attribute_shop.`id_product_attribute` = pa.`id_product_attribute`)');
$sql->leftJoin('product_attribute_image', 'pai', 'pai.`id_product_attribute` = pa.`id_product_attribute`');
$sql->leftJoin('image_lang', 'il', 'il.`id_image` = pai.`id_image` AND il.`id_lang` = ' . (int) $this->id_lang);
} else {
$sql->select('p.`reference` AS reference, p.`ean13`,
p.`upc` AS upc, product_shop.`minimal_quantity` AS minimal_quantity, product_shop.`wholesale_price` wholesale_price');
}
$result = Db::getInstance()->executeS($sql);
// Reset the cache before the following return, or else an empty cart will add dozens of queries
$products_ids = array();
$pa_ids = array();
if ($result) {
foreach ($result as $row) {
$products_ids[] = $row['id_product'];
$pa_ids[] = $row['id_product_attribute'];
}
}
// Thus you can avoid one query per product, because there will be only one query for all the products of the cart
Product::cacheProductsFeatures($products_ids);
Cart::cacheSomeAttributesLists($pa_ids, $this->id_lang);
$this->_products = array();
if (empty($result)) {
//.........这里部分代码省略.........
示例15: ajaxProcessUpdatePositions
/**
* Updates positions submitted via Ajax
*/
public function ajaxProcessUpdatePositions()
{
$id_shop = Shop::getContextShopID();
// Build an array of order IDs (could be a page!)
$submittedIds = array();
$rows = (array) Tools::getValue($this->table);
foreach ($rows as $row) {
$ids = explode('_', $row);
$submittedIds[] = (int) $ids[2];
}
// Get all IDs from database
$sql = new DbQuery();
$sql->select('id_ct_top_menu_item');
$sql->from('ct_top_menu_item_shop');
$sql->where('id_shop = ' . (int) $id_shop);
$sql->orderBy('position ASC');
$rows = (array) Db::getInstance()->executeS($sql);
$allIds = array();
foreach ($rows as $row) {
$allIds[] = (int) $row['id_ct_top_menu_item'];
}
// Go through all IDs, if the ID exists in the sorted ID list (could be fragment (page) or sorted IDs)
// then pick an ID from sorted ID list and overwrite the value.
$i = 0;
foreach ($allIds as $key1 => $id) {
$key2 = array_search($id, $submittedIds);
if ($key2 !== false) {
$allIds[$key1] = $submittedIds[$i++];
}
}
// Update positions of all values the way the are ordered in the array
$position = 0;
$isSuccess = true;
$shopIDs = Shop::getContextListShopID();
foreach ($allIds as $id_ct_top_menu_item) {
$isSuccess &= Db::getInstance()->update($this->table . '_shop', array('position' => $position++), 'id_ct_top_menu_item = ' . (int) $id_ct_top_menu_item . ' AND id_shop IN (' . implode(', ', $shopIDs) . ')');
if (!$isSuccess) {
break;
}
}
Hook::exec('actionCTTopMenuCompositionChanged');
if ($isSuccess) {
die(true);
} else {
header('Content-Type: application/json');
die(Tools::jsonEncode(array('hasError' => true, 'errors' => $this->l('Could not update positions in the database table.'))));
}
}