[*] Classes: Db->execute() now return always a boolean. Use Db->query() instead.
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@10999 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
+1
-1
@@ -243,7 +243,7 @@ class BackupCore
|
|||||||
|
|
||||||
if (!in_array($schema[0]['Table'], $ignore_insert_table))
|
if (!in_array($schema[0]['Table'], $ignore_insert_table))
|
||||||
{
|
{
|
||||||
$data = Db::getInstance()->executeS('SELECT * FROM `' . $schema[0]['Table'] . '`', false);
|
$data = Db::getInstance()->query('SELECT * FROM `' . $schema[0]['Table'] . '`', false);
|
||||||
$sizeof = DB::getInstance()->NumRows();
|
$sizeof = DB::getInstance()->NumRows();
|
||||||
$lines = explode("\n", $schema[0]['Create Table']);
|
$lines = explode("\n", $schema[0]['Create Table']);
|
||||||
|
|
||||||
|
|||||||
@@ -260,12 +260,12 @@ class CartRuleCore extends ObjectModel
|
|||||||
return array();
|
return array();
|
||||||
|
|
||||||
$productRules = array();
|
$productRules = array();
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$results = Db::getInstance()->ExecuteS('
|
||||||
SELECT *
|
SELECT *
|
||||||
FROM '._DB_PREFIX_.'cart_rule_product_rule pr
|
FROM '._DB_PREFIX_.'cart_rule_product_rule pr
|
||||||
LEFT JOIN '._DB_PREFIX_.'cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
|
LEFT JOIN '._DB_PREFIX_.'cart_rule_product_rule_value prv ON pr.id_product_rule = prv.id_product_rule
|
||||||
WHERE pr.id_cart_rule = '.(int)$this->id, false);
|
WHERE pr.id_cart_rule = '.(int)$this->id, false);
|
||||||
while ($row = Db::getInstance()->nextRow($result))
|
foreach ($results as $row)
|
||||||
{
|
{
|
||||||
if (!isset($productRules[$row['id_product_rule']]))
|
if (!isset($productRules[$row['id_product_rule']]))
|
||||||
$productRules[$row['id_product_rule']] = array('quantity' => $row['quantity'], 'type' => $row['type'], 'values' => array());
|
$productRules[$row['id_product_rule']] = array('quantity' => $row['quantity'], 'type' => $row['type'], 'values' => array());
|
||||||
|
|||||||
+23
-21
@@ -62,18 +62,18 @@ class GroupReductionCore extends ObjectModel
|
|||||||
|
|
||||||
public function delete()
|
public function delete()
|
||||||
{
|
{
|
||||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT p.`id_product`
|
SELECT p.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
WHERE p.`id_category_default` = '.(int)$this->id_category
|
WHERE p.`id_category_default` = '.(int)$this->id_category
|
||||||
, false);
|
);
|
||||||
|
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
$ids = array();
|
||||||
{
|
foreach ($products as $row)
|
||||||
$query = 'DELETE FROM `'._DB_PREFIX_.'product_group_reduction_cache` WHERE `id_product` = '.(int)$row['id_product'];
|
$ids[] = $row['id_product'];
|
||||||
if (Db::getInstance()->execute($query) === false)
|
|
||||||
return false;
|
if ($ids)
|
||||||
}
|
Db::getInstance()->delete(_DB_PREFIX_.'product_group_reduction_cache', 'id_product IN ('.implode(', ', $ids).')');
|
||||||
return (parent::delete());
|
return (parent::delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,15 +84,15 @@ class GroupReductionCore extends ObjectModel
|
|||||||
|
|
||||||
protected function _setCache()
|
protected function _setCache()
|
||||||
{
|
{
|
||||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT p.`id_product`
|
SELECT p.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
WHERE p.`id_category_default` = '.(int)$this->id_category
|
WHERE p.`id_category_default` = '.(int)$this->id_category
|
||||||
, false);
|
);
|
||||||
|
|
||||||
$query = 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
|
$query = 'INSERT INTO `'._DB_PREFIX_.'product_group_reduction_cache` (`id_product`, `id_group`, `reduction`) VALUES ';
|
||||||
$updated = false;
|
$updated = false;
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
foreach ($products as $row)
|
||||||
{
|
{
|
||||||
$query .= '('.(int)$row['id_product'].', '.(int)$this->id_group.', '.(float)$this->reduction.'), ';
|
$query .= '('.(int)$row['id_product'].', '.(int)$this->id_group.', '.(float)$this->reduction.'), ';
|
||||||
$updated = true;
|
$updated = true;
|
||||||
@@ -105,21 +105,23 @@ class GroupReductionCore extends ObjectModel
|
|||||||
|
|
||||||
protected function _updateCache()
|
protected function _updateCache()
|
||||||
{
|
{
|
||||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$products = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT p.`id_product`
|
SELECT p.`id_product`
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
WHERE p.`id_category_default` = '.(int)$this->id_category
|
WHERE p.`id_category_default` = '.(int)$this->id_category
|
||||||
, false);
|
, false);
|
||||||
|
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
$ids = array();
|
||||||
{
|
foreach ($products as $product)
|
||||||
$query = 'UPDATE `'._DB_PREFIX_.'product_group_reduction_cache`
|
$ids[] = $product['id_product'];
|
||||||
SET `reduction` = '.(float)$this->reduction.'
|
|
||||||
WHERE `id_product` = '.(int)$row['id_product'].' AND `id_group` = '.(int)$this->id_group;
|
$result = true;
|
||||||
if (Db::getInstance()->execute($query) === false)
|
if ($ids)
|
||||||
return false;
|
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'product_group_reduction_cache', array(
|
||||||
}
|
'reduction' => (float)$this->reduction,
|
||||||
return true;
|
), 'UPDATE', 'id_product IN('.implode(', ', $ids).') AND id_group = '.(int)$this->id_group);
|
||||||
|
|
||||||
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function getGroupReductions($id_group, $id_lang)
|
public static function getGroupReductions($id_group, $id_lang)
|
||||||
|
|||||||
+3
-3
@@ -220,11 +220,11 @@ class HookCore extends ObjectModel
|
|||||||
$sql .= '
|
$sql .= '
|
||||||
GROUP BY hm.id_hook, hm.id_module
|
GROUP BY hm.id_hook, hm.id_module
|
||||||
ORDER BY hm.`position`';
|
ORDER BY hm.`position`';
|
||||||
$result = $db->executeS($sql, false);
|
$results = $db->executeS($sql);
|
||||||
self::$_hookModulesCache = array();
|
self::$_hookModulesCache = array();
|
||||||
|
|
||||||
if ($result)
|
if ($results)
|
||||||
while ($row = $db->nextRow())
|
foreach ($results as $row)
|
||||||
{
|
{
|
||||||
$row['hook'] = strtolower($row['hook']);
|
$row['hook'] = strtolower($row['hook']);
|
||||||
if (!isset(self::$_hookModulesCache[$row['hook']]))
|
if (!isset(self::$_hookModulesCache[$row['hook']]))
|
||||||
|
|||||||
+3
-4
@@ -3226,16 +3226,15 @@ class ProductCore extends ObjectModel
|
|||||||
$sql = 'SELECT `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`
|
$sql = 'SELECT `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`
|
||||||
FROM `'._DB_PREFIX_.'product_download`
|
FROM `'._DB_PREFIX_.'product_download`
|
||||||
WHERE `id_product` = '.(int)$id_product_old;
|
WHERE `id_product` = '.(int)$id_product_old;
|
||||||
$resource = Db::getInstance()->execute($sql);
|
$results = Db::getInstance()->executeS($sql);
|
||||||
|
if (!$results)
|
||||||
if (!Db::getInstance()->NumRows())
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
$query = 'INSERT INTO `'._DB_PREFIX_.'product_download`
|
$query = 'INSERT INTO `'._DB_PREFIX_.'product_download`
|
||||||
(`id_product`, `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`)
|
(`id_product`, `display_filename`, `filename`, `date_add`, `date_expiration`, `nb_days_accessible`, `nb_downloadable`, `active`, `is_shareable`)
|
||||||
VALUES';
|
VALUES';
|
||||||
|
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
foreach ($results as $row)
|
||||||
$query .= ' ('.(int)$id_product_new.', \''.pSQL($row['display_filename']).'\', \''.pSQL($row['filename']).
|
$query .= ' ('.(int)$id_product_new.', \''.pSQL($row['display_filename']).'\', \''.pSQL($row['filename']).
|
||||||
'\', \''.pSQL($row['date_add']).'\', \''.pSQL($row['date_expiration']).'\', '.(int)$row['nb_days_accessible'].
|
'\', \''.pSQL($row['date_add']).'\', \''.pSQL($row['date_expiration']).'\', '.(int)$row['nb_days_accessible'].
|
||||||
', '.(int)$row['nb_downloadable'].', '.(int)$row['active'].'), '.(int)$row['is_shareable'].'),';
|
', '.(int)$row['nb_downloadable'].', '.(int)$row['active'].'), '.(int)$row['is_shareable'].'),';
|
||||||
|
|||||||
+7
-9
@@ -219,16 +219,15 @@ class SearchCore
|
|||||||
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
SELECT id_group FROM '._DB_PREFIX_.'customer_group
|
||||||
WHERE id_customer = '.(int)$id_customer.'
|
WHERE id_customer = '.(int)$id_customer.'
|
||||||
)');
|
)');
|
||||||
$result = $db->executeS($sql, false);
|
$results = $db->executeS($sql);
|
||||||
|
|
||||||
$eligibleProducts = array();
|
$eligibleProducts = array();
|
||||||
while ($row = $db->nextRow($result))
|
foreach ($results as $row)
|
||||||
$eligibleProducts[] = $row['id_product'];
|
$eligibleProducts[] = $row['id_product'];
|
||||||
foreach ($intersectArray as $query)
|
foreach ($intersectArray as $query)
|
||||||
{
|
{
|
||||||
$result = $db->executeS($query, false);
|
|
||||||
$eligibleProducts2 = array();
|
$eligibleProducts2 = array();
|
||||||
while ($row = $db->nextRow($result))
|
foreach ($db->executeS($query) as $row)
|
||||||
$eligibleProducts2[] = $row['id_product'];
|
$eligibleProducts2[] = $row['id_product'];
|
||||||
|
|
||||||
$eligibleProducts = array_intersect($eligibleProducts, $eligibleProducts2);
|
$eligibleProducts = array_intersect($eligibleProducts, $eligibleProducts2);
|
||||||
@@ -418,19 +417,18 @@ class SearchCore
|
|||||||
'features' => Configuration::get('PS_SEARCH_WEIGHT_FEATURE')
|
'features' => Configuration::get('PS_SEARCH_WEIGHT_FEATURE')
|
||||||
);
|
);
|
||||||
|
|
||||||
// Those are kind of global variables required to save the processed data in the database every X occurences, in order to avoid overloading MySQL
|
// Those are kind of global variables required to save the processed data in the database every X occurrences, in order to avoid overloading MySQL
|
||||||
$countWords = 0;
|
$countWords = 0;
|
||||||
$countProducts = 0;
|
$countProducts = 0;
|
||||||
$queryArray3 = array();
|
$queryArray3 = array();
|
||||||
$productsArray = array();
|
$productsArray = array();
|
||||||
|
|
||||||
// Every indexed words are cached into a PHP array
|
// Every indexed words are cached into a PHP array
|
||||||
$wordIdsByWord = array();
|
|
||||||
$wordIds = Db::getInstance()->executeS('
|
$wordIds = Db::getInstance()->executeS('
|
||||||
SELECT id_word, word, id_lang, id_shop
|
SELECT id_word, word, id_lang, id_shop
|
||||||
FROM '._DB_PREFIX_.'search_word', false);
|
FROM '._DB_PREFIX_.'search_word');
|
||||||
$wordIdsByWord = array();
|
$wordIdsByWord = array();
|
||||||
while ($wordId = $db->nextRow($wordIds))
|
foreach ($wordIds as $wordId)
|
||||||
{
|
{
|
||||||
if (!isset($wordIdsByWord[$wordId['id_shop']][$wordId['id_lang']]))
|
if (!isset($wordIdsByWord[$wordId['id_shop']][$wordId['id_lang']]))
|
||||||
$wordIdsByWord[$wordId['id_shop']][$wordId['id_lang']] = array();
|
$wordIdsByWord[$wordId['id_shop']][$wordId['id_lang']] = array();
|
||||||
|
|||||||
@@ -286,7 +286,7 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
if (!self::isFeatureActive())
|
if (!self::isFeatureActive())
|
||||||
return array();
|
return array();
|
||||||
|
|
||||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
$results = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
|
||||||
SELECT `id_product`
|
SELECT `id_product`
|
||||||
FROM `'._DB_PREFIX_.'specific_price`
|
FROM `'._DB_PREFIX_.'specific_price`
|
||||||
WHERE `id_shop` IN(0, '.(int)$id_shop.') AND
|
WHERE `id_shop` IN(0, '.(int)$id_shop.') AND
|
||||||
@@ -301,9 +301,9 @@ class SpecificPriceCore extends ObjectModel
|
|||||||
)
|
)
|
||||||
AND
|
AND
|
||||||
`reduction` > 0
|
`reduction` > 0
|
||||||
', false);
|
');
|
||||||
$ids_product = array();
|
$ids_product = array();
|
||||||
while ($row = DB::getInstance()->nextRow($resource))
|
foreach ($results as $row)
|
||||||
$ids_product[] = (int)$row['id_product'];
|
$ids_product[] = (int)$row['id_product'];
|
||||||
return $ids_product;
|
return $ids_product;
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -362,14 +362,14 @@ abstract class DbCore
|
|||||||
* @param bool $use_cache Use cache or not
|
* @param bool $use_cache Use cache or not
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function delete($table, $where = false, $limit = false, $use_cache = 1)
|
public function delete($table, $where = false, $limit = false, $use_cache = true)
|
||||||
{
|
{
|
||||||
$this->result = false;
|
$this->result = false;
|
||||||
$sql = 'DELETE FROM `'.bqSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : '');
|
$sql = 'DELETE FROM `'.bqSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : '');
|
||||||
$res = $this->query($sql);
|
$res = $this->query($sql);
|
||||||
if ($use_cache && $this->is_cache_enabled)
|
if ($use_cache && $this->is_cache_enabled)
|
||||||
Cache::getInstance()->deleteQuery($sql);
|
Cache::getInstance()->deleteQuery($sql);
|
||||||
return $res;
|
return (bool)$res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -377,30 +377,30 @@ abstract class DbCore
|
|||||||
*
|
*
|
||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @param bool $use_cache
|
* @param bool $use_cache
|
||||||
* @return mixed
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function execute($sql, $use_cache = 1)
|
public function execute($sql, $use_cache = true)
|
||||||
{
|
{
|
||||||
$sql = (string)$sql;
|
$sql = (string)$sql;
|
||||||
$this->result = $this->query($sql);
|
$this->result = $this->query($sql);
|
||||||
if ($use_cache && $this->is_cache_enabled)
|
if ($use_cache && $this->is_cache_enabled)
|
||||||
Cache::getInstance()->deleteQuery($sql);
|
Cache::getInstance()->deleteQuery($sql);
|
||||||
return $this->result;
|
return (bool)$this->result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ExecuteS return the result of $sql as array
|
* ExecuteS return the result of $sql as array
|
||||||
*
|
*
|
||||||
* @param string $sql query to execute
|
* @param string $sql query to execute
|
||||||
* @param boolean $array return an array instead of a mysql_result object
|
* @param boolean $array return an array instead of a mysql_result object (deprecated since 1.5.0, use query method instead)
|
||||||
* @param int $use_cache if query has been already executed, use its result
|
* @param int $use_cache if query has been already executed, use its result
|
||||||
* @return array or result object
|
* @return array or result object
|
||||||
*/
|
*/
|
||||||
public function executeS($sql, $array = true, $use_cache = 1)
|
public function executeS($sql, $array = true, $use_cache = true)
|
||||||
{
|
{
|
||||||
$sql = (string)$sql;
|
$sql = (string)$sql;
|
||||||
|
|
||||||
// This methode must be used only with queries which display results
|
// This method must be used only with queries which display results
|
||||||
if (!preg_match('#^\s*(select|show|explain|describe)\s#i', $sql))
|
if (!preg_match('#^\s*(select|show|explain|describe)\s#i', $sql))
|
||||||
{
|
{
|
||||||
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
|
if (defined('_PS_MODE_DEV_') && _PS_MODE_DEV_)
|
||||||
@@ -441,7 +441,7 @@ abstract class DbCore
|
|||||||
* @param int $use_cache find it in cache first
|
* @param int $use_cache find it in cache first
|
||||||
* @return array associative array of (field=>value)
|
* @return array associative array of (field=>value)
|
||||||
*/
|
*/
|
||||||
public function getRow($sql, $use_cache = 1)
|
public function getRow($sql, $use_cache = true)
|
||||||
{
|
{
|
||||||
$sql = (string)$sql;
|
$sql = (string)$sql;
|
||||||
$sql .= ' LIMIT 1';
|
$sql .= ' LIMIT 1';
|
||||||
@@ -471,7 +471,7 @@ abstract class DbCore
|
|||||||
* @param int $use_cache
|
* @param int $use_cache
|
||||||
* @return void
|
* @return void
|
||||||
*/
|
*/
|
||||||
public function getValue($sql, $use_cache = 1)
|
public function getValue($sql, $use_cache = true)
|
||||||
{
|
{
|
||||||
$sql = (string)$sql;
|
$sql = (string)$sql;
|
||||||
if (!$result = $this->getRow($sql, $use_cache))
|
if (!$result = $this->getRow($sql, $use_cache))
|
||||||
@@ -504,7 +504,7 @@ abstract class DbCore
|
|||||||
* @param string $sql
|
* @param string $sql
|
||||||
* @param bool $use_cache
|
* @param bool $use_cache
|
||||||
*/
|
*/
|
||||||
protected function q($sql, $use_cache = 1)
|
protected function q($sql, $use_cache = true)
|
||||||
{
|
{
|
||||||
global $webservice_call;
|
global $webservice_call;
|
||||||
|
|
||||||
|
|||||||
@@ -294,7 +294,7 @@ class StockManagerCore implements StockManagerInterface
|
|||||||
if ($left_quantity_to_check <= 0)
|
if ($left_quantity_to_check <= 0)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->execute('
|
$resource = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||||
SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`,
|
SELECT sm.`id_stock_mvt`, sm.`date_add`, sm.`physical_quantity`,
|
||||||
IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty
|
IF ((sm2.`physical_quantity` is null), sm.`physical_quantity`, (sm.`physical_quantity` - SUM(sm2.`physical_quantity`))) as qty
|
||||||
FROM `'._DB_PREFIX_.'stock_mvt` sm
|
FROM `'._DB_PREFIX_.'stock_mvt` sm
|
||||||
|
|||||||
@@ -166,14 +166,14 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
{
|
{
|
||||||
case 'attributes':
|
case 'attributes':
|
||||||
$attributes = array('selected' => array(), 'unselected' => array());
|
$attributes = array('selected' => array(), 'unselected' => array());
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$results = Db::getInstance()->ExecuteS('
|
||||||
SELECT CONCAT(agl.name, " - ", al.name) as name, a.id_attribute as id
|
SELECT CONCAT(agl.name, " - ", al.name) as name, a.id_attribute as id
|
||||||
FROM '._DB_PREFIX_.'attribute_group_lang agl
|
FROM '._DB_PREFIX_.'attribute_group_lang agl
|
||||||
LEFT JOIN '._DB_PREFIX_.'attribute a ON a.id_attribute_group = agl.id_attribute_group
|
LEFT JOIN '._DB_PREFIX_.'attribute a ON a.id_attribute_group = agl.id_attribute_group
|
||||||
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (a.id_attribute = al.id_attribute AND al.id_lang = '.(int)Context::getContext()->language->id.')
|
LEFT JOIN '._DB_PREFIX_.'attribute_lang al ON (a.id_attribute = al.id_attribute AND al.id_lang = '.(int)Context::getContext()->language->id.')
|
||||||
WHERE agl.id_lang = '.(int)Context::getContext()->language->id.'
|
WHERE agl.id_lang = '.(int)Context::getContext()->language->id.'
|
||||||
ORDER BY agl.name, al.name', false);
|
ORDER BY agl.name, al.name');
|
||||||
while ($row = Db::getInstance()->nextRow($result))
|
foreach ($results as $row)
|
||||||
$attributes[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
$attributes[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
||||||
Context::getContext()->smarty->assign('product_rule_itemlist', $attributes);
|
Context::getContext()->smarty->assign('product_rule_itemlist', $attributes);
|
||||||
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
||||||
@@ -182,12 +182,12 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
case 'products':
|
case 'products':
|
||||||
// Todo: Consider optimization
|
// Todo: Consider optimization
|
||||||
$products = array('selected' => array(), 'unselected' => array());
|
$products = array('selected' => array(), 'unselected' => array());
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$results = Db::getInstance()->ExecuteS('
|
||||||
SELECT name, id_product as id
|
SELECT name, id_product as id
|
||||||
FROM '._DB_PREFIX_.'product_lang pl
|
FROM '._DB_PREFIX_.'product_lang pl
|
||||||
WHERE id_lang = '.(int)Context::getContext()->language->id.'
|
WHERE id_lang = '.(int)Context::getContext()->language->id.'
|
||||||
ORDER BY name', false);
|
ORDER BY name');
|
||||||
while ($row = Db::getInstance()->nextRow($result))
|
foreach ($results as $row)
|
||||||
$products[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
$products[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
||||||
Context::getContext()->smarty->assign('product_rule_itemlist', $products);
|
Context::getContext()->smarty->assign('product_rule_itemlist', $products);
|
||||||
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
||||||
@@ -196,12 +196,12 @@ class AdminCartRulesControllerCore extends AdminController
|
|||||||
case 'categories':
|
case 'categories':
|
||||||
// Todo: Consider optimization
|
// Todo: Consider optimization
|
||||||
$categories = array('selected' => array(), 'unselected' => array());
|
$categories = array('selected' => array(), 'unselected' => array());
|
||||||
$result = Db::getInstance()->ExecuteS('
|
$results = Db::getInstance()->ExecuteS('
|
||||||
SELECT name, id_category as id
|
SELECT name, id_category as id
|
||||||
FROM '._DB_PREFIX_.'category_lang pl
|
FROM '._DB_PREFIX_.'category_lang pl
|
||||||
WHERE id_lang = '.(int)Context::getContext()->language->id.'
|
WHERE id_lang = '.(int)Context::getContext()->language->id.'
|
||||||
ORDER BY name', false);
|
ORDER BY name');
|
||||||
while ($row = Db::getInstance()->nextRow($result))
|
foreach ($results as $row)
|
||||||
$categories[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
$categories[in_array($row['id'], $selected) ? 'selected' : 'unselected'][] = $row;
|
||||||
Context::getContext()->smarty->assign('product_rule_itemlist', $categories);
|
Context::getContext()->smarty->assign('product_rule_itemlist', $categories);
|
||||||
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
$choose_content = Context::getContext()->smarty->fetch('cart_rules/product_rule_itemlist.tpl');
|
||||||
|
|||||||
@@ -1102,7 +1102,7 @@ class AdminSupplyOrdersControllerCore extends AdminController
|
|||||||
$query->from('supply_order_detail');
|
$query->from('supply_order_detail');
|
||||||
$query->where('id_supply_order = '.(int)$id);
|
$query->where('id_supply_order = '.(int)$id);
|
||||||
$query->orderBy('id_supply_order_detail DESC');
|
$query->orderBy('id_supply_order_detail DESC');
|
||||||
$resource = Db::getInstance()->execute($query);
|
$resource = Db::getInstance()->query($query);
|
||||||
// gets details
|
// gets details
|
||||||
while ($row = Db::getInstance()->nextRow($resource))
|
while ($row = Db::getInstance()->nextRow($resource))
|
||||||
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
|
echo sprintf("%s\n", implode(';', array_map(array('CSVCore', 'wrap'), $row)));
|
||||||
|
|||||||
@@ -666,17 +666,17 @@ abstract class Module
|
|||||||
if (!isset(self::$_hookModulesCache))
|
if (!isset(self::$_hookModulesCache))
|
||||||
{
|
{
|
||||||
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
|
$db = Db::getInstance(_PS_USE_SQL_SLAVE_);
|
||||||
$result = $db->executeS('
|
$results = $db->executeS('
|
||||||
SELECT h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`
|
SELECT h.`name` as hook, m.`id_module`, h.`id_hook`, m.`name` as module, h.`live_edit`
|
||||||
FROM `'._DB_PREFIX_.'module` m
|
FROM `'._DB_PREFIX_.'module` m
|
||||||
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
|
LEFT JOIN `'._DB_PREFIX_.'hook_module` hm ON hm.`id_module` = m.`id_module`
|
||||||
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
|
LEFT JOIN `'._DB_PREFIX_.'hook` h ON hm.`id_hook` = h.`id_hook`
|
||||||
AND m.`active` = 1
|
AND m.`active` = 1
|
||||||
ORDER BY hm.`position`', false);
|
ORDER BY hm.`position`');
|
||||||
self::$_hookModulesCache = array();
|
self::$_hookModulesCache = array();
|
||||||
|
|
||||||
if ($result)
|
if ($results)
|
||||||
while ($row = $db->nextRow())
|
foreach ($results as $row)
|
||||||
{
|
{
|
||||||
$row['hook'] = strtolower($row['hook']);
|
$row['hook'] = strtolower($row['hook']);
|
||||||
if (!isset(self::$_hookModulesCache[$row['hook']]))
|
if (!isset(self::$_hookModulesCache[$row['hook']]))
|
||||||
|
|||||||
@@ -32,10 +32,8 @@ function convert_product_price()
|
|||||||
$taxRates = array();
|
$taxRates = array();
|
||||||
foreach ($taxes as $data)
|
foreach ($taxes as $data)
|
||||||
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100;
|
$taxRates[$data['id_tax']] = (float)($data['rate']) / 100;
|
||||||
$resource = DB::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax` FROM `'._DB_PREFIX_.'product`', false);
|
$results = DB::getInstance()->executeS('SELECT `id_product`, `price`, `id_tax` FROM `'._DB_PREFIX_.'product`');
|
||||||
if (!$resource)
|
foreach ($results as $row)
|
||||||
die(Db::getInstance()->getMsgError());
|
|
||||||
while ($row = DB::getInstance()->nextRow($resource))
|
|
||||||
if ($row['id_tax'])
|
if ($row['id_tax'])
|
||||||
{
|
{
|
||||||
$price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
|
$price = $row['price'] * (1 + $taxRates[$row['id_tax']]);
|
||||||
|
|||||||
@@ -2082,19 +2082,19 @@ class BlockLayered extends Module
|
|||||||
AND psi.`id_currency` = '.$idCurrency;
|
AND psi.`id_currency` = '.$idCurrency;
|
||||||
}
|
}
|
||||||
|
|
||||||
$allProductsOut = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
$allProductsOut = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||||
SELECT p.`id_product` id_product
|
SELECT p.`id_product` id_product
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
'.$priceFilterQueryOut.'
|
'.$priceFilterQueryOut.'
|
||||||
'.$queryFiltersFrom.'
|
'.$queryFiltersFrom.'
|
||||||
WHERE 1 '.$queryFiltersWhere.' GROUP BY id_product', false);
|
WHERE 1 '.$queryFiltersWhere.' GROUP BY id_product');
|
||||||
|
|
||||||
$allProductsIn = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
$allProductsIn = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||||
SELECT p.`id_product` id_product
|
SELECT p.`id_product` id_product
|
||||||
FROM `'._DB_PREFIX_.'product` p
|
FROM `'._DB_PREFIX_.'product` p
|
||||||
'.$priceFilterQueryIn.'
|
'.$priceFilterQueryIn.'
|
||||||
'.$queryFiltersFrom.'
|
'.$queryFiltersFrom.'
|
||||||
WHERE 1 '.$queryFiltersWhere.' GROUP BY id_product', false);
|
WHERE 1 '.$queryFiltersWhere.' GROUP BY id_product');
|
||||||
|
|
||||||
$productIdList = array();
|
$productIdList = array();
|
||||||
|
|
||||||
@@ -3304,7 +3304,7 @@ class BlockLayered extends Module
|
|||||||
$nCategories = array();
|
$nCategories = array();
|
||||||
$doneCategories = array();
|
$doneCategories = array();
|
||||||
|
|
||||||
$attributeGroups = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
$attributeGroups = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||||
SELECT a.id_attribute, a.id_attribute_group
|
SELECT a.id_attribute, a.id_attribute_group
|
||||||
FROM '._DB_PREFIX_.'attribute a
|
FROM '._DB_PREFIX_.'attribute a
|
||||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
|
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_attribute = a.id_attribute)
|
||||||
@@ -3313,13 +3313,13 @@ class BlockLayered extends Module
|
|||||||
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
||||||
LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category)
|
LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category)
|
||||||
WHERE c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').' AND p.active = 1'.(count($productsIds) ? '
|
WHERE c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').' AND p.active = 1'.(count($productsIds) ? '
|
||||||
AND p.id_product IN ('.implode(',', $productsIds).')' : ''), false);
|
AND p.id_product IN ('.implode(',', $productsIds).')' : ''));
|
||||||
|
|
||||||
$attributeGroupsById = array();
|
$attributeGroupsById = array();
|
||||||
while ($row = $db->nextRow($attributeGroups))
|
while ($row = $db->nextRow($attributeGroups))
|
||||||
$attributeGroupsById[(int)$row['id_attribute']] = (int)$row['id_attribute_group'];
|
$attributeGroupsById[(int)$row['id_attribute']] = (int)$row['id_attribute_group'];
|
||||||
|
|
||||||
$features = Db::getInstance(_PS_USE_SQL_SLAVE_)->ExecuteS('
|
$features = Db::getInstance(_PS_USE_SQL_SLAVE_)->query('
|
||||||
SELECT fv.id_feature_value, fv.id_feature
|
SELECT fv.id_feature_value, fv.id_feature
|
||||||
FROM '._DB_PREFIX_.'feature_value fv
|
FROM '._DB_PREFIX_.'feature_value fv
|
||||||
LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_feature_value = fv.id_feature_value)
|
LEFT JOIN '._DB_PREFIX_.'feature_product fp ON (fp.id_feature_value = fv.id_feature_value)
|
||||||
@@ -3327,13 +3327,13 @@ class BlockLayered extends Module
|
|||||||
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
||||||
LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category)
|
LEFT JOIN '._DB_PREFIX_.'category c ON (c.id_category = cp.id_category)
|
||||||
WHERE (fv.custom IS NULL OR fv.custom = 0) AND c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').'
|
WHERE (fv.custom IS NULL OR fv.custom = 0) AND c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').'
|
||||||
AND p.active = 1'.(count($productsIds) ? ' AND p.id_product IN ('.implode(',', $productsIds).')' : ''), false);
|
AND p.active = 1'.(count($productsIds) ? ' AND p.id_product IN ('.implode(',', $productsIds).')' : ''));
|
||||||
|
|
||||||
$featuresById = array();
|
$featuresById = array();
|
||||||
while ($row = $db->nextRow($features))
|
while ($row = $db->nextRow($features))
|
||||||
$featuresById[(int)$row['id_feature_value']] = (int)$row['id_feature'];
|
$featuresById[(int)$row['id_feature_value']] = (int)$row['id_feature'];
|
||||||
|
|
||||||
$result = $db->ExecuteS('
|
$result = $db->query('
|
||||||
SELECT p.id_product, GROUP_CONCAT(DISTINCT fv.id_feature_value) features, GROUP_CONCAT(DISTINCT cp.id_category) categories, GROUP_CONCAT(DISTINCT pac.id_attribute) attributes
|
SELECT p.id_product, GROUP_CONCAT(DISTINCT fv.id_feature_value) features, GROUP_CONCAT(DISTINCT cp.id_category) categories, GROUP_CONCAT(DISTINCT pac.id_attribute) attributes
|
||||||
FROM '._DB_PREFIX_.'product p
|
FROM '._DB_PREFIX_.'product p
|
||||||
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
LEFT JOIN '._DB_PREFIX_.'category_product cp ON (cp.id_product = p.id_product)
|
||||||
@@ -3344,7 +3344,7 @@ class BlockLayered extends Module
|
|||||||
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)
|
LEFT JOIN '._DB_PREFIX_.'product_attribute_combination pac ON (pac.id_product_attribute = pa.id_product_attribute)
|
||||||
WHERE c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').' AND p.active = 1'.(count($productsIds) ? '
|
WHERE c.active = 1'.(count($categoriesIds) ? ' AND cp.id_category IN ('.implode(',', $categoriesIds).')' : '').' AND p.active = 1'.(count($productsIds) ? '
|
||||||
AND p.id_product IN ('.implode(',', $productsIds).')' : '').' AND (fv.custom IS NULL OR fv.custom = 0)
|
AND p.id_product IN ('.implode(',', $productsIds).')' : '').' AND (fv.custom IS NULL OR fv.custom = 0)
|
||||||
GROUP BY p.id_product', false);
|
GROUP BY p.id_product');
|
||||||
|
|
||||||
while ($product = $db->nextRow($result))
|
while ($product = $db->nextRow($result))
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class StatsEquipment extends ModuleGraph
|
|||||||
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_guest` = c.`id_guest`
|
LEFT JOIN `'._DB_PREFIX_.'guest` g ON g.`id_guest` = c.`id_guest`
|
||||||
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
|
WHERE c.`date_add` BETWEEN '.ModuleGraph::getDateBetween().'
|
||||||
'.$this->sqlShopRestriction(false, 'c');
|
'.$this->sqlShopRestriction(false, 'c');
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, false);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
||||||
|
|
||||||
$calcArray = array(
|
$calcArray = array(
|
||||||
'jsOK' => 0,
|
'jsOK' => 0,
|
||||||
|
|||||||
@@ -122,7 +122,7 @@ class StatsForecast extends Module
|
|||||||
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
|
'.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
|
||||||
GROUP BY '.$dateFromGInvoice.'
|
GROUP BY '.$dateFromGInvoice.'
|
||||||
ORDER BY fix_date';
|
ORDER BY fix_date';
|
||||||
$result = $db->executeS($sql, false);
|
$result = $db->query($sql);
|
||||||
|
|
||||||
while ($row = $db->nextRow($result))
|
while ($row = $db->nextRow($result))
|
||||||
$dataTable[$row['fix_date']] = $row;
|
$dataTable[$row['fix_date']] = $row;
|
||||||
@@ -159,7 +159,7 @@ class StatsForecast extends Module
|
|||||||
WHERE c.date_add BETWEEN '.ModuleGraph::getDateBetween().'
|
WHERE c.date_add BETWEEN '.ModuleGraph::getDateBetween().'
|
||||||
'.$this->sqlShopRestriction(false, 'c').'
|
'.$this->sqlShopRestriction(false, 'c').'
|
||||||
GROUP BY '.$dateFromGAdd;
|
GROUP BY '.$dateFromGAdd;
|
||||||
$visits = Db::getInstance()->executeS($sql, false);
|
$visits = Db::getInstance()->query($sql);
|
||||||
while ($row = $db->nextRow($visits))
|
while ($row = $db->nextRow($visits))
|
||||||
$visitArray[$row['fix_date']] = $row['visits'];
|
$visitArray[$row['fix_date']] = $row['visits'];
|
||||||
|
|
||||||
@@ -172,7 +172,7 @@ class StatsForecast extends Module
|
|||||||
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween()
|
AND o.invoice_date BETWEEN '.ModuleGraph::getDateBetween()
|
||||||
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
|
.$this->sqlShopRestriction(Shop::SHARE_ORDER, 'o').'
|
||||||
GROUP BY '.$dateFromGInvoice;
|
GROUP BY '.$dateFromGInvoice;
|
||||||
$discounts = Db::getInstance()->executeS($sql, false);
|
$discounts = Db::getInstance()->query($sql);
|
||||||
while ($row = $db->nextRow($discounts))
|
while ($row = $db->nextRow($discounts))
|
||||||
$discountArray[$row['fix_date']] = $row['total'];*/
|
$discountArray[$row['fix_date']] = $row['total'];*/
|
||||||
|
|
||||||
|
|||||||
@@ -59,7 +59,7 @@ class StatsOrigin extends ModuleGraph
|
|||||||
WHERE 1
|
WHERE 1
|
||||||
'.$this->sqlShopRestriction().'
|
'.$this->sqlShopRestriction().'
|
||||||
AND date_add BETWEEN '.$dateBetween;
|
AND date_add BETWEEN '.$dateBetween;
|
||||||
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS($sql, false);
|
$result = Db::getInstance(_PS_USE_SQL_SLAVE_)->query($sql);
|
||||||
$websites = array($directLink => 0);
|
$websites = array($directLink => 0);
|
||||||
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
while ($row = Db::getInstance(_PS_USE_SQL_SLAVE_)->nextRow($result))
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user