[*] Classes : Db::autoExecute() call are now replaced by Db::insert() or Db::update()

This commit is contained in:
rMalie
2012-01-23 17:41:02 +00:00
parent 08c7b79a27
commit cc841b6969
29 changed files with 251 additions and 235 deletions
+1 -1
View File
@@ -787,7 +787,7 @@ abstract class AdminTabCore
foreach ($category as $categ_id => $categ) foreach ($category as $categ_id => $categ)
if ($categ_id != 1) if ($categ_id != 1)
$rowList[] = array('id_category' => $categ_id, 'id_group' => $object->id); $rowList[] = array('id_category' => $categ_id, 'id_group' => $object->id);
Db::getInstance()->autoExecute(_DB_PREFIX_.'category_group', $rowList, 'INSERT'); Db::getInstance()->insert('category_group', $rowList);
} }
// Save and stay on same form // Save and stay on same form
if (Tools::isSubmit('submitAdd'.$this->table.'AndStay')) if (Tools::isSubmit('submitAdd'.$this->table.'AndStay'))
+6 -10
View File
@@ -693,14 +693,10 @@ class CartCore extends ObjectModel
public function addCartRule($id_cart_rule) public function addCartRule($id_cart_rule)
{ {
return Db::getInstance()->AutoExecute( return Db::getInstance()->insert('cart_cart_rule', array(
_DB_PREFIX_.'cart_cart_rule', 'id_cart_rule' => (int)$id_cart_rule,
array( 'id_cart' => (int)$this->id
'id_cart_rule' => (int)$id_cart_rule, ));
'id_cart' => (int)$this->id
),
'INSERT'
);
} }
public function containsProduct($id_product, $id_product_attribute = 0, $id_customization = false, $id_address_delivery = 0) public function containsProduct($id_product, $id_product_attribute = 0, $id_customization = false, $id_address_delivery = 0)
@@ -849,7 +845,7 @@ class CartCore extends ObjectModel
if ((int)$quantity < $minimal_quantity) if ((int)$quantity < $minimal_quantity)
return -1; return -1;
$result_add = Db::getInstance()->AutoExecute(_DB_PREFIX_.'cart_product', array( $result_add = Db::getInstance()->insert('cart_product', array(
'id_product' => (int)$id_product, 'id_product' => (int)$id_product,
'id_product_attribute' => (int)$id_product_attribute, 'id_product_attribute' => (int)$id_product_attribute,
'id_cart' => (int)$this->id, 'id_cart' => (int)$this->id,
@@ -857,7 +853,7 @@ class CartCore extends ObjectModel
'id_shop' => $shop->getID(true), 'id_shop' => $shop->getID(true),
'quantity' => (int)$quantity, 'quantity' => (int)$quantity,
'date_add' => date('Y-m-d H:i:s') 'date_add' => date('Y-m-d H:i:s')
), 'INSERT'); ));
if (!$result_add) if (!$result_add)
return false; return false;
+1 -1
View File
@@ -987,7 +987,7 @@ class CategoryCore extends ObjectModel
foreach ($groups as $group) foreach ($groups as $group)
{ {
$row = array('id_category' => (int)$this->id, 'id_group' => (int)$group); $row = array('id_category' => (int)$this->id, 'id_group' => (int)$group);
Db::getInstance()->AutoExecute(_DB_PREFIX_.'category_group', $row, 'INSERT'); Db::getInstance()->insert('category_group', $row);
} }
} }
+10 -10
View File
@@ -290,10 +290,10 @@ class ConfigurationCore extends ObjectModel
if (!$lang) if (!$lang)
{ {
// Update config not linked to lang // Update config not linked to lang
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'configuration', array( $result &= Db::getInstance()->update('configuration', array(
'value' => pSQL($value, $html), 'value' => pSQL($value, $html),
'date_upd' => date('Y-m-d H:i:s'), 'date_upd' => date('Y-m-d H:i:s'),
), 'UPDATE', '`name` = \''.pSQL($key).'\''.Configuration::sqlRestriction($shopGroupID, $shopID), true, true); ), '`name` = \''.pSQL($key).'\''.Configuration::sqlRestriction($shopGroupID, $shopID), true, true);
} }
else else
{ {
@@ -330,12 +330,12 @@ class ConfigurationCore extends ObjectModel
if ($lang) if ($lang)
{ {
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'configuration_lang', array( $result &= Db::getInstance()->insert('configuration_lang', array(
'id_configuration' => $configID, 'id_configuration' => $configID,
'id_lang' => $lang, 'id_lang' => $lang,
'value' => pSQL($value, $html), 'value' => pSQL($value, $html),
'date_upd' => date('Y-m-d H:i:s'), 'date_upd' => date('Y-m-d H:i:s'),
), 'INSERT'); ));
} }
} }
@@ -346,12 +346,12 @@ class ConfigurationCore extends ObjectModel
} }
/** /**
* Delete a configuration key in database (with or without language management) * Delete a configuration key in database (with or without language management)
* *
* @param string $key Key to delete * @param string $key Key to delete
* @return boolean Deletion result * @return boolean Deletion result
*/ */
static public function deleteByName($key) public static function deleteByName($key)
{ {
if (!Validate::isConfigName($key)) if (!Validate::isConfigName($key))
return false; return false;
+5 -9
View File
@@ -92,15 +92,11 @@ class ConnectionCore extends ObjectModel
// The ending time will be updated by an ajax request when the guest will close the page // The ending time will be updated by an ajax request when the guest will close the page
$time_start = date('Y-m-d H:i:s'); $time_start = date('Y-m-d H:i:s');
Db::getInstance()->AutoExecute( Db::getInstance()->insert('connections_page', array(
_DB_PREFIX_.'connections_page', 'id_connections' => (int)$cookie->id_connections,
array( 'id_page' => (int)$id_page,
'id_connections' => (int)$cookie->id_connections, 'time_start' => $time_start
'id_page' => (int)$id_page, ));
'time_start' => $time_start
),
'INSERT'
);
// This array is serialized and used by the ajax request to identify the page // This array is serialized and used by the ajax request to identify the page
return array( return array(
+1 -1
View File
@@ -535,7 +535,7 @@ class CustomerCore extends ObjectModel
foreach ($groups as $group) foreach ($groups as $group)
{ {
$row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group); $row = array('id_customer' => (int)$this->id, 'id_group' => (int)$group);
Db::getInstance()->AutoExecute(_DB_PREFIX_.'customer_group', $row, 'INSERT'); Db::getInstance()->insert('customer_group', $row);
} }
} }
+3 -4
View File
@@ -161,11 +161,10 @@ class FeatureCore extends ObjectModel
WHERE `'.$this->def['primary'].'` = '.(int)$this->id.' WHERE `'.$this->def['primary'].'` = '.(int)$this->id.'
AND `id_lang` = '.(int)$field['id_lang']; AND `id_lang` = '.(int)$field['id_lang'];
$mode = Db::getInstance()->getRow($sql); $mode = Db::getInstance()->getRow($sql);
$result &= (!$mode) ? Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'INSERT') : $result &= (!$mode) ? Db::getInstance()->insert($this->def['table'].'_lang', $field) :
Db::getInstance()->AutoExecute( Db::getInstance()->update(
_DB_PREFIX_.$this->def['table'].'_lang', $this->def['table'].'_lang',
$field, $field,
'UPDATE',
'`'.$this->def['primary'].'` = '.(int)$this->id.' AND `id_lang` = '.(int)$field['id_lang'] '`'.$this->def['primary'].'` = '.(int)$this->id.' AND `id_lang` = '.(int)$field['id_lang']
); );
} }
+2 -2
View File
@@ -113,9 +113,9 @@ class GroupReductionCore extends ObjectModel
$result = true; $result = true;
if ($ids) if ($ids)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'product_group_reduction_cache', array( $result &= Db::getInstance()->update('product_group_reduction_cache', array(
'reduction' => (float)$this->reduction, 'reduction' => (float)$this->reduction,
), 'UPDATE', 'id_product IN('.implode(', ', $ids).') AND id_group = '.(int)$this->id_group); ), 'id_product IN('.implode(', ', $ids).') AND id_group = '.(int)$this->id_group);
return $result; return $result;
} }
+1 -6
View File
@@ -106,12 +106,7 @@ class ImageCore extends ObjectModel
foreach ($result as $row) foreach ($result as $row)
{ {
$row['position'] = $i++; $row['position'] = $i++;
Db::getInstance()->AutoExecute( Db::getInstance()->update($this->def['table'], $row, '`id_image` = '.(int)$row['id_image'], 1);
_DB_PREFIX_.$this->def['table'],
$row,
'UPDATE',
'`id_image` = '.(int)$row['id_image'], 1
);
} }
return true; return true;
+6 -6
View File
@@ -215,7 +215,7 @@ abstract class ModuleCore
} }
// Install module and retrieve the installation id // Install module and retrieve the installation id
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.$this->table, array('name' => $this->name, 'active' => 1, 'version' => $this->version), 'INSERT'); $result = Db::getInstance()->insert($this->table, array('name' => $this->name, 'active' => 1, 'version' => $this->version));
if (!$result) if (!$result)
{ {
$this->_errors[] = $this->l('Technical error : PrestaShop could not installed this module.'); $this->_errors[] = $this->l('Technical error : PrestaShop could not installed this module.');
@@ -500,10 +500,10 @@ abstract class ModuleCore
// Enable module in the shop where it is not enabled yet // Enable module in the shop where it is not enabled yet
foreach ($list as $id) foreach ($list as $id)
if (!in_array($id, $items)) if (!in_array($id, $items))
Db::getInstance()->autoExecute(_DB_PREFIX_.'module_shop', array( Db::getInstance()->insert('module_shop', array(
'id_module' => $this->id, 'id_module' => $this->id,
'id_shop' => $id, 'id_shop' => $id,
), 'INSERT'); ));
return true; return true;
} }
@@ -630,12 +630,12 @@ abstract class ModuleCore
$position = 0; $position = 0;
// Register module in hook // Register module in hook
$return &= Db::getInstance()->autoExecute(_DB_PREFIX_.'hook_module', array( $return &= Db::getInstance()->insert('hook_module', array(
'id_module' => (int)$this->id, 'id_module' => (int)$this->id,
'id_hook' => (int)$id_hook, 'id_hook' => (int)$id_hook,
'id_shop' => (int)$shopID, 'id_shop' => (int)$shopID,
'position' => (int)($position + 1), 'position' => (int)($position + 1),
), 'INSERT'); ));
} }
return $return; return $return;
@@ -713,7 +713,7 @@ abstract class ModuleCore
'id_shop' => (int)$shopID, 'id_shop' => (int)$shopID,
'file_name' => pSQL($except), 'file_name' => pSQL($except),
); );
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.'hook_module_exceptions', $insertException, 'INSERT'); $result = Db::getInstance()->insert('hook_module_exceptions', $insertException);
if (!$result) if (!$result)
return false; return false;
} }
+12 -12
View File
@@ -383,9 +383,9 @@ abstract class ObjectModelCore
// Database insertion // Database insertion
if ($null_values) if ($null_values)
$result = Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.$this->def['table'], $this->getFields(), 'INSERT'); $result = Db::getInstance()->insert($this->def['table'], $this->getFields(), true);
else else
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.$this->def['table'], $this->getFields(), 'INSERT'); $result = Db::getInstance()->insert($this->def['table'], $this->getFields());
if (!$result) if (!$result)
return false; return false;
@@ -412,11 +412,11 @@ abstract class ObjectModelCore
foreach ($shops as $id_shop) foreach ($shops as $id_shop)
{ {
$field['id_shop'] = (int)$id_shop; $field['id_shop'] = (int)$id_shop;
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'INSERT'); $result &= Db::getInstance()->insert($this->def['table'].'_lang', $field);
} }
} }
else else
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'INSERT'); $result &= Db::getInstance()->insert($this->def['table'].'_lang', $field);
} }
} }
@@ -457,9 +457,9 @@ abstract class ObjectModelCore
// Database update // Database update
if ($null_values) if ($null_values)
$result = Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.$this->def['table'], $this->getFields(), 'UPDATE', '`'.pSQL($this->def['primary']).'` = '.(int)($this->id)); $result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id, 0, true);
else else
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.$this->def['table'], $this->getFields(), 'UPDATE', '`'.pSQL($this->def['primary']).'` = '.(int)($this->id)); $result = Db::getInstance()->update($this->def['table'], $this->getFields(), '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
if (!$result) if (!$result)
return false; return false;
@@ -487,9 +487,9 @@ abstract class ObjectModelCore
.' AND id_shop = '.$field['id_shop']; .' AND id_shop = '.$field['id_shop'];
if (Db::getInstance()->getValue('SELECT COUNT(*) FROM '.pSQL(_DB_PREFIX_.$this->def['table']).'_lang WHERE '.$where)) if (Db::getInstance()->getValue('SELECT COUNT(*) FROM '.pSQL(_DB_PREFIX_.$this->def['table']).'_lang WHERE '.$where))
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'UPDATE', $where); $result &= Db::getInstance()->update($this->def['table'].'_lang', $field, $where);
else else
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'INSERT'); $result &= Db::getInstance()->insert($this->def['table'].'_lang', $field);
} }
} }
// If this table is not linked to multishop system ... // If this table is not linked to multishop system ...
@@ -498,9 +498,9 @@ abstract class ObjectModelCore
$where = pSQL($this->def['primary']).' = '.(int)$this->id $where = pSQL($this->def['primary']).' = '.(int)$this->id
.' AND id_lang = '.(int)$field['id_lang']; .' AND id_lang = '.(int)$field['id_lang'];
if (Db::getInstance()->getValue('SELECT COUNT(*) FROM '.pSQL(_DB_PREFIX_.$this->def['table']).'_lang WHERE '.$where)) if (Db::getInstance()->getValue('SELECT COUNT(*) FROM '.pSQL(_DB_PREFIX_.$this->def['table']).'_lang WHERE '.$where))
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'UPDATE', $where); $result &= Db::getInstance()->update($this->def['table'].'_lang', $field, $where);
else else
$result &= Db::getInstance()->AutoExecute(_DB_PREFIX_.$this->def['table'].'_lang', $field, 'INSERT'); $result &= Db::getInstance()->insert($this->def['table'].'_lang', $field, 'INSERT');
} }
} }
} }
@@ -977,11 +977,11 @@ abstract class ObjectModelCore
if (!is_array($fields)) if (!is_array($fields))
return false; return false;
if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'required_field WHERE object_name = \''.pSQL(get_class($this)).'\'')) if (!Db::getInstance()->execute('DELETE FROM '._DB_PREFIX_.'required_field WHERE object_name = \''.get_class($this).'\''))
return false; return false;
foreach ($fields AS $field) foreach ($fields AS $field)
if (!Db::getInstance()->AutoExecute(_DB_PREFIX_.'required_field', array('object_name' => pSQL(get_class($this)), 'field_name' => pSQL($field)), 'INSERT')) if (!Db::getInstance()->insert('required_field', array('object_name' => get_class($this), 'field_name' => pSQL($field))))
return false; return false;
return true; return true;
} }
+1 -1
View File
@@ -190,7 +190,7 @@ class PackCore extends Product
public static function addItem($id_product, $id_item, $qty) public static function addItem($id_product, $id_item, $qty)
{ {
return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET cache_is_pack = 1 WHERE id_product = '.(int)($id_product).' LIMIT 1') && return Db::getInstance()->execute('UPDATE '._DB_PREFIX_.'product SET cache_is_pack = 1 WHERE id_product = '.(int)($id_product).' LIMIT 1') &&
Db::getInstance()->AutoExecute(_DB_PREFIX_.'pack', array('id_product_pack' => (int)($id_product), 'id_product_item' => (int)($id_item), 'quantity' => (int)($qty)), 'INSERT') && Db::getInstance()->insert('pack', array('id_product_pack' => (int)$id_product, 'id_product_item' => (int)$id_item, 'quantity' => (int)$qty)) &&
Configuration::updateGlobalValue('PS_PACK_FEATURE_ACTIVE', '1'); Configuration::updateGlobalValue('PS_PACK_FEATURE_ACTIVE', '1');
} }
+5 -5
View File
@@ -80,7 +80,7 @@ class PageCore extends ObjectModel
if ($result['id_page']) if ($result['id_page'])
return $result['id_page']; return $result['id_page'];
Db::getInstance()->autoExecuteWithNullValues(_DB_PREFIX_.'page', $insertData, 'INSERT'); Db::getInstance()->insert('page', $insertData, true);
return Db::getInstance()->Insert_ID(); return Db::getInstance()->Insert_ID();
} }
@@ -97,9 +97,9 @@ class PageCore extends ObjectModel
if ($value = Db::getInstance()->getValue($sql)) if ($value = Db::getInstance()->getValue($sql))
return $value; return $value;
Db::getInstance()->autoExecute(_DB_PREFIX_.'page_type', array( Db::getInstance()->insert('page_type', array(
'name' => $name, 'name' => $name,
), 'INSERT'); ));
return Db::getInstance()->Insert_ID(); return Db::getInstance()->Insert_ID();
} }
@@ -118,12 +118,12 @@ class PageCore extends ObjectModel
// If no one has seen the page in this date range, it is added // If no one has seen the page in this date range, it is added
if (Db::getInstance()->Affected_Rows() == 0) if (Db::getInstance()->Affected_Rows() == 0)
Db::getInstance()->autoExecute(_DB_PREFIX_.'page_viewed', array( Db::getInstance()->insert('page_viewed', array(
'id_date_range' => (int)$id_date_range, 'id_date_range' => (int)$id_date_range,
'id_page' => (int)$id_page, 'id_page' => (int)$id_page,
'counter' => 1, 'counter' => 1,
'id_shop' => (int)$context->shop->getID(), 'id_shop' => (int)$context->shop->getID(),
'id_group_shop' => (int)$context->shop->getGroupID(), 'id_group_shop' => (int)$context->shop->getGroupID(),
), 'INSERT'); ));
} }
} }
+15 -23
View File
@@ -2102,7 +2102,7 @@ class ProductCore extends ObjectModel
AND id_shop = '.(int)$this->id_shop AND id_shop = '.(int)$this->id_shop
); );
Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_carrier', $data, 'INSERT'); Db::getInstance()->insert('product_carrier', $data);
} }
/** /**
@@ -2913,14 +2913,10 @@ class ProductCore extends ObjectModel
public function changeAccessories($accessories_id) public function changeAccessories($accessories_id)
{ {
foreach ($accessories_id as $id_product_2) foreach ($accessories_id as $id_product_2)
Db::getInstance()->AutoExecute( Db::getInstance()->insert('accessory', array(
_DB_PREFIX_.'accessory', 'id_product_1' => (int)$this->id,
array( 'id_product_2' => (int)$id_product_2
'id_product_1' => (int)$this->id, ));
'id_product_2' => (int)$id_product_2
),
'INSERT'
);
} }
/** /**
@@ -2929,7 +2925,7 @@ class ProductCore extends ObjectModel
public function addFeaturesCustomToDB($id_value, $lang, $cust) public function addFeaturesCustomToDB($id_value, $lang, $cust)
{ {
$row = array('id_feature_value' => (int)$id_value, 'id_lang' => (int)$lang, 'value' => pSQL($cust)); $row = array('id_feature_value' => (int)$id_value, 'id_lang' => (int)$lang, 'value' => pSQL($cust));
return Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value_lang', $row, 'INSERT'); return Db::getInstance()->insert('feature_value_lang', $row);
} }
public function addFeaturesToDB($id_feature, $id_value, $cust = 0) public function addFeaturesToDB($id_feature, $id_value, $cust = 0)
@@ -2937,11 +2933,11 @@ class ProductCore extends ObjectModel
if ($cust) if ($cust)
{ {
$row = array('id_feature' => (int)$id_feature, 'custom' => 1); $row = array('id_feature' => (int)$id_feature, 'custom' => 1);
Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_value', $row, 'INSERT'); Db::getInstance()->insert('feature_value', $row);
$id_value = Db::getInstance()->Insert_ID(); $id_value = Db::getInstance()->Insert_ID();
} }
$row = array('id_feature' => (int)$id_feature, 'id_product' => (int)$this->id, 'id_feature_value' => (int)$id_value); $row = array('id_feature' => (int)$id_feature, 'id_product' => (int)$this->id, 'id_feature_value' => (int)$id_value);
Db::getInstance()->autoExecute(_DB_PREFIX_.'feature_product', $row, 'INSERT'); Db::getInstance()->insert('feature_product', $row);
if ($id_value) if ($id_value)
return ($id_value); return ($id_value);
} }
@@ -3104,7 +3100,7 @@ class ProductCore extends ObjectModel
$row['id_product'] = $id_product_new; $row['id_product'] = $id_product_new;
unset($row['id_product_attribute']); unset($row['id_product_attribute']);
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute', $row, 'INSERT'); $return &= Db::getInstance()->insert('product_attribute', $row);
$id_product_attribute_new = (int)Db::getInstance()->Insert_ID(); $id_product_attribute_new = (int)Db::getInstance()->Insert_ID();
if ($result_images = Product::_getAttributeImageAssociations($id_product_attribute_old)) if ($result_images = Product::_getAttributeImageAssociations($id_product_attribute_old))
@@ -3115,7 +3111,7 @@ class ProductCore extends ObjectModel
foreach ($result2 as $row2) foreach ($result2 as $row2)
{ {
$row2['id_product_attribute'] = $id_product_attribute_new; $row2['id_product_attribute'] = $id_product_attribute_new;
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'product_attribute_combination', $row2, 'INSERT'); $return &= Db::getInstance()->insert('product_attribute_combination', $row2);
} }
} }
return !$return ? false : $combination_images; return !$return ? false : $combination_images;
@@ -3151,7 +3147,7 @@ class ProductCore extends ObjectModel
$data = array( $data = array(
'id_product_1' => (int)$id_product_new, 'id_product_1' => (int)$id_product_new,
'id_product_2' => (int)$row['id_product_2']); 'id_product_2' => (int)$row['id_product_2']);
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'accessory', $data, 'INSERT'); $return &= Db::getInstance()->insert('accessory', $data);
} }
return $return; return $return;
} }
@@ -3216,7 +3212,7 @@ class ProductCore extends ObjectModel
{ {
$old_id_feature_value = $result2['id_feature_value']; $old_id_feature_value = $result2['id_feature_value'];
unset($result2['id_feature_value']); unset($result2['id_feature_value']);
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'feature_value', $result2, 'INSERT'); $return &= Db::getInstance()->insert('feature_value', $result2);
$max_fv = Db::getInstance()->getRow(' $max_fv = Db::getInstance()->getRow('
SELECT MAX(`id_feature_value`) AS nb SELECT MAX(`id_feature_value`) AS nb
FROM `'._DB_PREFIX_.'feature_value`'); FROM `'._DB_PREFIX_.'feature_value`');
@@ -3230,12 +3226,12 @@ class ProductCore extends ObjectModel
WHERE `id_feature_value` = '.(int)$old_id_feature_value.' WHERE `id_feature_value` = '.(int)$old_id_feature_value.'
AND `id_lang` = '.(int)$language['id_lang']); AND `id_lang` = '.(int)$language['id_lang']);
$result3['id_feature_value'] = $new_id_feature_value; $result3['id_feature_value'] = $new_id_feature_value;
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'feature_value_lang', $result3, 'INSERT'); $return &= Db::getInstance()->insert('feature_value_lang', $result3);
} }
$row['id_feature_value'] = $new_id_feature_value; $row['id_feature_value'] = $new_id_feature_value;
} }
$row['id_product'] = $id_product_new; $row['id_product'] = $id_product_new;
$return &= Db::getInstance()->AutoExecute(_DB_PREFIX_.'feature_product', $row, 'INSERT'); $return &= Db::getInstance()->insert('feature_product', $row);
} }
return $return; return $return;
} }
@@ -3301,11 +3297,7 @@ class ProductCore extends ObjectModel
unset($customization_field['id_customization_field']); unset($customization_field['id_customization_field']);
if (!Db::getInstance()->AutoExecute( if (!Db::getInstance()->insert('customization_field', $customization_field)
_DB_PREFIX_.'customization_field',
$customization_field,
'INSERT'
)
|| !$customization_field_id = Db::getInstance()->Insert_ID()) || !$customization_field_id = Db::getInstance()->Insert_ID())
return false; return false;
+2 -2
View File
@@ -271,7 +271,7 @@ class ReferrerCore extends ObjectModel
$registrations = $referrer->getRegistrations(null, $employee, $shop); $registrations = $referrer->getRegistrations(null, $employee, $shop);
$stats_sales = $referrer->getStatsSales(null, $employee, $shop); $stats_sales = $referrer->getStatsSales(null, $employee, $shop);
Db::getInstance()->autoExecute(_DB_PREFIX_.'referrer_shop', array( Db::getInstance()->update('referrer_shop', array(
'cache_visitors' => $stats_visits['uniqs'], 'cache_visitors' => $stats_visits['uniqs'],
'cache_visits' => $stats_visits['visits'], 'cache_visits' => $stats_visits['visits'],
'cache_pages' => $stats_visits['pages'], 'cache_pages' => $stats_visits['pages'],
@@ -280,7 +280,7 @@ class ReferrerCore extends ObjectModel
'cache_sales' => number_format($stats_sales['sales'], 2, '.', ''), 'cache_sales' => number_format($stats_sales['sales'], 2, '.', ''),
'cache_reg_rate' => $stats_visits['uniqs'] ? $registrations / $stats_visits['uniqs'] : 0, 'cache_reg_rate' => $stats_visits['uniqs'] ? $registrations / $stats_visits['uniqs'] : 0,
'cache_order_rate' => $stats_visits['uniqs'] ? $stats_sales['orders'] / $stats_visits['uniqs'] : 0, 'cache_order_rate' => $stats_visits['uniqs'] ? $stats_sales['orders'] / $stats_visits['uniqs'] : 0,
), 'UPDATE', 'id_referrer = '.$referrer->id.' AND id_shop = '.$shop_id); ), 'id_referrer = '.$referrer->id.' AND id_shop = '.$shop_id);
} }
} }
+2 -2
View File
@@ -139,7 +139,7 @@ class SceneCore extends ObjectModel
'id_category' => (int)$category, 'id_category' => (int)$category,
); );
} }
return Db::getInstance()->autoExecute(_DB_PREFIX_.'scene_category', $data, 'INSERT'); return Db::getInstance()->insert('scene_category', $data);
} }
public function deleteCategories() public function deleteCategories()
@@ -173,7 +173,7 @@ class SceneCore extends ObjectModel
); );
} }
return Db::getInstance()->autoExecute(_DB_PREFIX_.'scene_products', $data, 'INSERT'); return Db::getInstance()->insert('scene_products', $data);
} }
public function deleteZoneProducts() public function deleteZoneProducts()
+4 -4
View File
@@ -81,21 +81,21 @@ class SpecificPriceRuleCore extends ObjectModel
if (!is_array($conditions)) if (!is_array($conditions))
return; return;
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.'specific_price_rule_condition_group', array( $result = Db::getInstance()->insert('specific_price_rule_condition_group', array(
'id_specific_price_rule_condition_group' => '', 'id_specific_price_rule_condition_group' => '',
'id_specific_price_rule' => (int)$this->id 'id_specific_price_rule' => (int)$this->id
), 'INSERT'); ));
if (!$result) if (!$result)
return false; return false;
$id_specific_price_rule_condition_group = (int)Db::getInstance()->Insert_ID(); $id_specific_price_rule_condition_group = (int)Db::getInstance()->Insert_ID();
foreach ($conditions as $condition) foreach ($conditions as $condition)
{ {
$result = Db::getInstance()->autoExecute(_DB_PREFIX_.'specific_price_rule_condition', array( $result = Db::getInstance()->insert('specific_price_rule_condition', array(
'id_specific_price_rule_condition' => '', 'id_specific_price_rule_condition' => '',
'id_specific_price_rule_condition_group' => (int)$id_specific_price_rule_condition_group, 'id_specific_price_rule_condition_group' => (int)$id_specific_price_rule_condition_group,
'type' => $condition['type'], 'type' => $condition['type'],
'value' => $condition['value'], 'value' => $condition['value'],
), 'INSERT'); ));
if (!$result) if (!$result)
return false; return false;
} }
+121 -73
View File
@@ -30,6 +30,13 @@ if (file_exists(dirname(__FILE__).'/../config/settings.inc.php'))
abstract class DbCore abstract class DbCore
{ {
/**
* Constants used by insert() method
*/
const INSERT = 1;
const INSERT_IGNORE = 2;
const REPLACE = 3;
/** /**
* @var string Server (eg. localhost) * @var string Server (eg. localhost)
*/ */
@@ -105,7 +112,7 @@ abstract class DbCore
abstract public function disconnect(); abstract public function disconnect();
/** /**
* Execute a query and get result ressource * Execute a query and get result resource
* *
* @param string $sql * @param string $sql
* @return mixed * @return mixed
@@ -125,7 +132,7 @@ abstract class DbCore
abstract public function Insert_ID(); abstract public function Insert_ID();
/** /**
* Get number of affected rows in previous databse operation * Get number of affected rows in previous database operation
*/ */
abstract public function Affected_Rows(); abstract public function Affected_Rows();
@@ -167,7 +174,7 @@ abstract class DbCore
/** /**
* Get Db object instance * Get Db object instance
* *
* @param bool $master Decides wether the connection to be returned by the master server or the slave server * @param bool $master Decides whether the connection to be returned by the master server or the slave server
* @return Db instance * @return Db instance
*/ */
public static function getInstance($master = true) public static function getInstance($master = true)
@@ -246,86 +253,32 @@ abstract class DbCore
} }
/** /**
* Filter SQL query within a blacklist * @deprecated 1.5.0 use insert() or update() method instead
*
* @param string $table Table where insert/update data
* @param string $data Data to insert/update
* @param string $type INSERT or INSERT IGNORE or REPLACE or UPDATE
* @param string $where WHERE clause, only for UPDATE (optional)
* @param int $limit LIMIT clause (optional)
* @param bool $use_cache
* @param bool $use_null If true, replace empty strings and NULL by a NULL value
* @return mixed|boolean SQL query result
*/ */
public function autoExecute($table, $data, $type, $where = '', $limit = 0, $use_cache = true, $use_null = false) public function autoExecute($table, $data, $type, $where = '', $limit = 0, $use_cache = true, $use_null = false)
{ {
if (!$data) Tools::displayAsDeprecated();
return true; if (substr($table, 0, strlen(_DB_PREFIX_)) == _DB_PREFIX_)
$table = substr($table, strlen(_DB_PREFIX_));
$type = strtoupper($type); $type = strtoupper($type);
if ($type == 'INSERT' || $type == 'INSERT IGNORE' || $type == 'REPLACE') switch ($type)
{ {
// Check if $data is a list of row case 'INSERT' :
$current = current($data); return $this->insert($table, $data, $use_null, $use_cache, Db::INSERT);
if (!is_array($current) || isset($current['type']))
$data = array($data);
$keys = array(); case 'INSERT IGNORE' :
$values_stringified = array(); return $this->insert($table, $data, $use_null, $use_cache, Db::INSERT_IGNORE);
foreach ($data as $row_data)
{
$values = array();
foreach ($row_data as $key => $value)
{
if (isset($keys_stringified))
{
// Check if row array mapping are the same
if (!in_array("`$key`", $keys))
throw new PrestaShopDatabaseException('Keys form $data subarray don\'t match');
}
else
$keys[] = "`$key`";
if (!is_array($value)) case 'REPLACE' :
$value = array('type' => 'text', 'value' => $value); return $this->insert($table, $data, $use_null, $use_cache, Db::REPLACE);
if ($value['type'] == 'sql')
$values[] = $value['value'];
else
$values[] = $use_null && ($value['value'] === '' || is_null($value['value'])) ? 'NULL' : "'{$value['value']}'";
}
$keys_stringified = implode(', ', $keys);
$values_stringified[] = '('.implode(', ', $values).')';
}
$sql = $type.' INTO `'.$table.'` ('.$keys_stringified.') VALUES '.implode(', ', $values_stringified); case 'UPDATE' :
if ($limit) return $this->update($table, $data, $where, $limit, $use_null, $use_cache);
$sql .= ' LIMIT '.(int)$limit;
return (bool)$this->q($sql, $use_cache); default :
throw new PrestaShopDatabaseException('Wrong argument (miss type) in Db::autoExecute()');
} }
else if ($type == 'UPDATE')
{
$sql = 'UPDATE `'.$table.'` SET ';
foreach ($data as $key => $value)
{
if (!is_array($value))
$value = array('type' => 'text', 'value' => $value);
if ($value['type'] == 'sql')
$sql .= "`$key` = {$value['value']},";
else
$sql .= ($use_null && ($value['value'] === '' || is_null($value['value']))) ? "`$key` = NULL," : "`$key` = '{$value['value']}',";
}
$sql = rtrim($sql, ',');
if ($where)
$sql .= ' WHERE '.$where;
if ($limit)
$sql .= ' LIMIT '.(int)$limit;
return (bool)$this->q($sql, $use_cache);
}
else
throw new PrestaShopDatabaseException('Wrong argument (miss type) in Db::autoExecute()');
return false;
} }
/** /**
@@ -360,6 +313,101 @@ abstract class DbCore
return $result; return $result;
} }
/**
* Execute an INSERT query
*
* @param string $table Table name without prefix
* @param array $data Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
* @param bool $null_values If we want to use NULL values instead of empty quotes
* @param bool $use_cache
* @param $type Must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE
* @return bool
*/
public function insert($table, $data, $null_values = false, $use_cache = true, $type = Db::INSERT)
{
if (!$data)
return true;
$table = _DB_PREFIX_.$table;
if ($type == Db::INSERT)
$insert_keyword = 'INSERT';
else if ($type == Db::INSERT_IGNORE)
$insert_keyword = 'INSERT IGNORE';
else if ($type == Db::REPLACE)
$insert_keyword = 'REPLACE';
else
throw new PrestaShopDatabaseException('Bad keyword, must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE');
// Check if $data is a list of row
$current = current($data);
if (!is_array($current) || isset($current['type']))
$data = array($data);
$keys = array();
$values_stringified = array();
foreach ($data as $row_data)
{
$values = array();
foreach ($row_data as $key => $value)
{
if (isset($keys_stringified))
{
// Check if row array mapping are the same
if (!in_array("`$key`", $keys))
throw new PrestaShopDatabaseException('Keys form $data subarray don\'t match');
}
else
$keys[] = "`$key`";
if (!is_array($value))
$value = array('type' => 'text', 'value' => $value);
if ($value['type'] == 'sql')
$values[] = $value['value'];
else
$values[] = $null_values && ($value['value'] === '' || is_null($value['value'])) ? 'NULL' : "'{$value['value']}'";
}
$keys_stringified = implode(', ', $keys);
$values_stringified[] = '('.implode(', ', $values).')';
}
$sql = $insert_keyword.' INTO `'.$table.'` ('.$keys_stringified.') VALUES '.implode(', ', $values_stringified);
return (bool)$this->q($sql, $use_cache);
}
/**
* @param string $table Table name without prefix
* @param array $data Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
* @param string $where WHERE condition
* @param int $limit
* @param bool $null_values If we want to use NULL values instead of empty quotes
* @param bool $use_cache
* @return bool
*/
public function update($table, $data, $where = '', $limit = 0, $null_values = false, $use_cache = true)
{
if (!$data)
return true;
$table = _DB_PREFIX_.$table;
$sql = 'UPDATE `'.$table.'` SET ';
foreach ($data as $key => $value)
{
if (!is_array($value))
$value = array('type' => 'text', 'value' => $value);
if ($value['type'] == 'sql')
$sql .= "`$key` = {$value['value']},";
else
$sql .= ($null_values && ($value['value'] === '' || is_null($value['value']))) ? "`$key` = NULL," : "`$key` = '{$value['value']}',";
}
$sql = rtrim($sql, ',');
if ($where)
$sql .= ' WHERE '.$where;
if ($limit)
$sql .= ' LIMIT '.(int)$limit;
return (bool)$this->q($sql, $use_cache);
}
/** /**
* Execute a DELETE query * Execute a DELETE query
* *
+7 -7
View File
@@ -68,15 +68,15 @@ class OrderReturnCore extends ObjectModel
{ {
/* Classic product return */ /* Classic product return */
if ($orderDetailList) if ($orderDetailList)
foreach ($orderDetailList AS $key => $orderDetail) foreach ($orderDetailList as $key => $orderDetail)
if ($qty = (int)($productQtyList[$key])) if ($qty = (int)$productQtyList[$key])
Db::getInstance()->AutoExecute(_DB_PREFIX_.'order_return_detail', array('id_order_return' => (int)($this->id), 'id_order_detail' => (int)($orderDetail), 'product_quantity' => $qty, 'id_customization' => 0), 'INSERT'); Db::getInstance()->insert('order_return_detail', array('id_order_return' => (int)$this->id, 'id_order_detail' => (int)$orderDetail, 'product_quantity' => $qty, 'id_customization' => 0));
/* Customized product return */ /* Customized product return */
if ($customizationIds) if ($customizationIds)
foreach ($customizationIds AS $orderDetailId => $customizations) foreach ($customizationIds as $orderDetailId => $customizations)
foreach ($customizations AS $customizationId) foreach ($customizations as $customizationId)
if ($quantity = (int)($customizationQtyInput[(int)($customizationId)])) if ($quantity = (int)$customizationQtyInput[(int)$customizationId])
Db::getInstance()->AutoExecute(_DB_PREFIX_.'order_return_detail', array('id_order_return' => (int)($this->id), 'id_order_detail' => (int)($orderDetailId), 'product_quantity' => $quantity, 'id_customization' => (int)($customizationId)), 'INSERT'); Db::getInstance()->insert('order_return_detail', array('id_order_return' => (int)$this->id, 'id_order_detail' => (int)$orderDetailId, 'product_quantity' => $quantity, 'id_customization' => (int)$customizationId));
} }
public function checkEnoughProduct($orderDetailList, $productQtyList, $customizationIds, $customizationQtyInput) public function checkEnoughProduct($orderDetailList, $productQtyList, $customizationIds, $customizationQtyInput)
+6 -2
View File
@@ -81,7 +81,11 @@ class OrderSlipCore extends ObjectModel
foreach ($orderDetailList as $key => $orderDetail) foreach ($orderDetailList as $key => $orderDetail)
{ {
if ($qty = (int)($productQtyList[$key])) if ($qty = (int)($productQtyList[$key]))
Db::getInstance()->AutoExecute(_DB_PREFIX_.'order_slip_detail', array('id_order_slip' => (int)($this->id), 'id_order_detail' => (int)($orderDetail), 'product_quantity' => $qty), 'INSERT'); Db::getInstance()->insert('order_slip_detail', array(
'id_order_slip' => (int)$this->id,
'id_order_detail' => (int)$orderDetail,
'product_quantity' => $qty,
));
} }
} }
@@ -227,7 +231,7 @@ class OrderSlipCore extends ObjectModel
'amount_tax_excl' => (float)($tab['amount_tax_excl']), 'amount_tax_excl' => (float)($tab['amount_tax_excl']),
'amount_tax_incl' => (float)($tab['amount_tax_incl']), 'amount_tax_incl' => (float)($tab['amount_tax_incl']),
); );
Db::getInstance()->autoExecute(_DB_PREFIX_.'order_slip_detail', $insertOrderSlip, 'INSERT'); Db::getInstance()->insert('order_slip_detail', $insertOrderSlip);
} }
} }
+3 -3
View File
@@ -99,8 +99,8 @@ class ShopUrlCore extends ObjectModel
public function setMain() public function setMain()
{ {
$res = Db::getInstance()->autoExecute(_DB_PREFIX_.'shop_url', array('main' => 0), 'UPDATE', 'id_shop = '.(int)$this->id_shop); $res = Db::getInstance()->update('shop_url', array('main' => 0), 'id_shop = '.(int)$this->id_shop);
$res &= Db::getInstance()->autoExecute(_DB_PREFIX_.'shop_url', array('main' => 1), 'UPDATE', 'id_shop_url = '.(int)$this->id); $res &= Db::getInstance()->update('shop_url', array('main' => 1), 'id_shop_url = '.(int)$this->id);
$this->main = true; $this->main = true;
// Reset main URL for all shops to prevent problems // Reset main URL for all shops to prevent problems
@@ -112,7 +112,7 @@ class ShopUrlCore extends ObjectModel
) = 0 ) = 0
GROUP BY s1.id_shop'; GROUP BY s1.id_shop';
foreach (Db::getInstance()->executeS($sql) as $row) foreach (Db::getInstance()->executeS($sql) as $row)
Db::getInstance()->autoExecute(_DB_PREFIX_.'shop_url', array('main' => 1), 'UPDATE', 'id_shop_url = '.$row['id_shop_url']); Db::getInstance()->update('shop_url', array('main' => 1), 'id_shop_url = '.$row['id_shop_url']);
return $res; return $res;
} }
+10 -22
View File
@@ -141,13 +141,12 @@ class StockAvailableCore extends ObjectModel
{ {
$quantity = $manager->getProductRealQuantities($id_product, $id_product_attribute, $warehouses, true); $quantity = $manager->getProductRealQuantities($id_product, $id_product_attribute, $warehouses, true);
$query = array( $query = array(
'table' => _DB_PREFIX_.'stock_available', 'table' => 'stock_available',
'data' => array('quantity' => $quantity), 'data' => array('quantity' => $quantity),
'type' => 'UPDATE',
'where' => 'id_product = '.(int)$id_product.' AND id_product_attribute = '.(int)$id_product_attribute. 'where' => 'id_product = '.(int)$id_product.' AND id_product_attribute = '.(int)$id_product_attribute.
StockAvailable::addSqlShopRestriction(null, $id_shop) StockAvailable::addSqlShopRestriction(null, $id_shop)
); );
Db::getInstance()->autoExecute($query['table'], $query['data'], $query['type'], $query['where']); Db::getInstance()->update($query['table'], $query['data'], $query['where']);
$product_quantity += $quantity; $product_quantity += $quantity;
} }
@@ -155,13 +154,12 @@ class StockAvailableCore extends ObjectModel
// updates // updates
// if $id_product has attributes, it also updates the sum for all attributes // if $id_product has attributes, it also updates the sum for all attributes
$query = array( $query = array(
'table' => _DB_PREFIX_.'stock_available', 'table' => 'stock_available',
'data' => array('quantity' => $product_quantity), 'data' => array('quantity' => $product_quantity),
'type' => 'UPDATE',
'where' => 'id_product = '.(int)$id_product.' AND id_product_attribute = 0'. 'where' => 'id_product = '.(int)$id_product.' AND id_product_attribute = 0'.
StockAvailable::addSqlShopRestriction(null, $id_shop) StockAvailable::addSqlShopRestriction(null, $id_shop)
); );
Db::getInstance()->autoExecute($query['table'], $query['data'], $query['type'], $query['where']); Db::getInstance()->update($query['table'], $query['data'], $query['where']);
} }
} }
@@ -190,10 +188,9 @@ class StockAvailableCore extends ObjectModel
if ($existing_id > 0) if ($existing_id > 0)
{ {
Db::getInstance()->autoExecute( Db::getInstance()->update(
_DB_PREFIX_.'stock_available', 'stock_available',
array('depends_on_stock' => (int)(bool)$depends_on_stock), array('depends_on_stock' => (int)(bool)$depends_on_stock),
'UPDATE',
'id_product = '.(int)$id_product. 'id_product = '.(int)$id_product.
StockAvailable::addSqlShopRestriction(null, $id_shop) StockAvailable::addSqlShopRestriction(null, $id_shop)
); );
@@ -208,11 +205,7 @@ class StockAvailableCore extends ObjectModel
StockAvailable::addSqlShopParams($params, $id_shop); StockAvailable::addSqlShopParams($params, $id_shop);
Db::getInstance()->autoExecute( Db::getInstance()->insert('stock_available', $params);
_DB_PREFIX_.'stock_available',
$params,
'INSERT'
);
} }
// depends on stock.. hence synchronizes // depends on stock.. hence synchronizes
@@ -236,10 +229,9 @@ class StockAvailableCore extends ObjectModel
if ($existing_id > 0) if ($existing_id > 0)
{ {
Db::getInstance()->autoExecute( Db::getInstance()->update(
_DB_PREFIX_.'stock_available', 'stock_available',
array('out_of_stock' => (int)$out_of_stock), array('out_of_stock' => (int)$out_of_stock),
'UPDATE',
'id_product = '.(int)$id_product. 'id_product = '.(int)$id_product.
StockAvailable::addSqlShopRestriction(null, $id_shop) StockAvailable::addSqlShopRestriction(null, $id_shop)
); );
@@ -254,11 +246,7 @@ class StockAvailableCore extends ObjectModel
StockAvailable::addSqlShopParams($params, $id_shop); StockAvailable::addSqlShopParams($params, $id_shop);
Db::getInstance()->autoExecute( Db::getInstance()->insert('stock_available', $params);
_DB_PREFIX_.'stock_available',
$params,
'INSERT'
);
} }
} }
+3 -3
View File
@@ -145,7 +145,7 @@ class WarehouseCore extends ObjectModel
DELETE FROM '._DB_PREFIX_.'warehouse_shop DELETE FROM '._DB_PREFIX_.'warehouse_shop
WHERE '.$this->def['primary'].' = '.(int)$this->id); WHERE '.$this->def['primary'].' = '.(int)$this->id);
Db::getInstance()->autoExecute(_DB_PREFIX_.'warehouse_shop', $row_to_insert, 'INSERT'); Db::getInstance()->insert('warehouse_shop', $row_to_insert);
} }
/** /**
@@ -190,7 +190,7 @@ class WarehouseCore extends ObjectModel
WHERE '.$this->def['primary'].' = '.(int)$this->id); WHERE '.$this->def['primary'].' = '.(int)$this->id);
if ($row_to_insert) if ($row_to_insert)
Db::getInstance()->autoExecute(_DB_PREFIX_.'warehouse_carrier', $row_to_insert, 'INSERT'); Db::getInstance()->insert('warehouse_carrier', $row_to_insert);
} }
/** /**
@@ -263,7 +263,7 @@ class WarehouseCore extends ObjectModel
'location' => pSQL($location), 'location' => pSQL($location),
); );
return Db::getInstance()->autoExecute(_DB_PREFIX_.'warehouse_product_location', $row_to_insert, 'INSERT'); return Db::getInstance()->insert('warehouse_product_location', $row_to_insert);
} }
/** /**
+10 -10
View File
@@ -89,35 +89,35 @@ class BlockCms extends Module
return false; return false;
// Install fixtures for blockcms // Install fixtures for blockcms
if (!Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block', array( if (!Db::getInstance()->insert('cms_block', array(
'id_cms_category' => 1, 'id_cms_category' => 1,
'location' => 0, 'location' => 0,
'position' => 0, 'position' => 0,
), 'INSERT')) )))
return false; return false;
$id_cms_block = Db::getInstance()->Insert_ID(); $id_cms_block = Db::getInstance()->Insert_ID();
$result = true; $result = true;
$shops = Shop::getShops(true, null, true); $shops = Shop::getShops(true, null, true);
foreach ($shops as $shop) foreach ($shops as $shop)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_shop', array( $result &= Db::getInstance()->insert('cms_block_shop', array(
'id_cms_block' => $id_cms_block, 'id_cms_block' => $id_cms_block,
'id_shop' => $shop 'id_shop' => $shop
), 'INSERT'); ));
foreach (Language::getLanguages(false) as $lang) foreach (Language::getLanguages(false) as $lang)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_lang', array( $result &= Db::getInstance()->insert('cms_block_lang', array(
'id_cms_block' => $id_cms_block, 'id_cms_block' => $id_cms_block,
'id_lang' => $lang['id_lang'], 'id_lang' => $lang['id_lang'],
'name' => $this->l('Information'), 'name' => $this->l('Information'),
), 'INSERT'); ));
foreach (CMS::getCMSPages(null, 1) as $cms) foreach (CMS::getCMSPages(null, 1) as $cms)
$result &= Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_page', array( $result &= Db::getInstance()->insert('cms_block_page', array(
'id_cms_block' => $id_cms_block, 'id_cms_block' => $id_cms_block,
'id_cms' => $cms['id_cms'], 'id_cms' => $cms['id_cms'],
'is_category' => 0, 'is_category' => 0,
), 'INSERT'); ));
return $result; return $result;
} }
@@ -740,10 +740,10 @@ class BlockCms extends Module
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'cms_block_shop WHERE id_cms_block='.(int)$id_cms_block); Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'cms_block_shop WHERE id_cms_block='.(int)$id_cms_block);
foreach ($assos_shop as $asso) foreach ($assos_shop as $asso)
foreach ($asso as $id_shop => $row) foreach ($asso as $id_shop => $row)
Db::getInstance()->autoExecute(_DB_PREFIX_.'cms_block_shop', array( Db::getInstance()->insert('cms_block_shop', array(
'id_cms_block' => (int)$id_cms_block, 'id_cms_block' => (int)$id_cms_block,
'id_shop' => (int)$id_shop, 'id_shop' => (int)$id_shop,
), 'INSERT'); ));
} }
$cmsBoxes = Tools::getValue('cmsBox'); $cmsBoxes = Tools::getValue('cmsBox');
+2 -2
View File
@@ -188,10 +188,10 @@ class BlockLink extends Module
Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'blocklink_shop WHERE id_blocklink='.(int)$id_link); Db::getInstance()->Execute('DELETE FROM '._DB_PREFIX_.'blocklink_shop WHERE id_blocklink='.(int)$id_link);
foreach ($assos_shop as $asso) foreach ($assos_shop as $asso)
foreach ($asso as $id_shop => $row) foreach ($asso as $id_shop => $row)
Db::getInstance()->autoExecute(_DB_PREFIX_.'blocklink_shop', array( Db::getInstance()->insert('blocklink_shop', array(
'id_blocklink' => (int)$id_link, 'id_blocklink' => (int)$id_link,
'id_shop' => (int)$id_shop, 'id_shop' => (int)$id_shop,
), 'INSERT'); ));
return true; return true;
} }
+6 -8
View File
@@ -49,27 +49,25 @@ class MenuTopLinks
if(!is_array($label)) if(!is_array($label))
return false; return false;
Db::getInstance()->autoExecute( Db::getInstance()->insert(
_DB_PREFIX_.'linksmenutop', 'linksmenutop',
array( array(
'new_window'=>(int)$newWindow, 'new_window'=>(int)$newWindow,
'link'=>pSQL($link), 'link'=>pSQL($link),
'id_shop' => (int)$id_shop 'id_shop' => (int)$id_shop
), )
'INSERT'
); );
$id_linksmenutop = Db::getInstance()->Insert_ID(); $id_linksmenutop = Db::getInstance()->Insert_ID();
foreach($label as $id_lang=>$label) foreach($label as $id_lang=>$label)
{ {
Db::getInstance()->autoExecute( Db::getInstance()->insert(
_DB_PREFIX_.'linksmenutop_lang', 'linksmenutop_lang',
array( array(
'id_linksmenutop'=>(int)$id_linksmenutop, 'id_linksmenutop'=>(int)$id_linksmenutop,
'id_lang'=>(int)$id_lang, 'id_lang'=>(int)$id_lang,
'id_shop'=>(int)$id_shop, 'id_shop'=>(int)$id_shop,
'label'=>pSQL($label) 'label'=>pSQL($label)
), )
'INSERT'
); );
} }
} }
+2 -2
View File
@@ -80,14 +80,14 @@ class Editorial extends Module
{ {
$id_editorial = Db::getInstance()->Insert_ID(); $id_editorial = Db::getInstance()->Insert_ID();
foreach (Language::getLanguages(false) as $lang) foreach (Language::getLanguages(false) as $lang)
$res &= Db::getInstance()->autoExecute(_DB_PREFIX_.'editorial_lang', array( $res &= Db::getInstance()->insert('editorial_lang', array(
'id_editorial' => $id_editorial, 'id_editorial' => $id_editorial,
'id_lang' => $lang['id_lang'], 'id_lang' => $lang['id_lang'],
'body_title' => 'Lorem ipsum dolor sit amet', 'body_title' => 'Lorem ipsum dolor sit amet',
'body_subheading' => 'Excepteur sint occaecat cupidatat non proident', 'body_subheading' => 'Excepteur sint occaecat cupidatat non proident',
'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>', 'body_paragraph' => '<p>Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum</p>',
'body_logo_subheading' => 'Lorem ipsum presta shop amet', 'body_logo_subheading' => 'Lorem ipsum presta shop amet',
), 'INSERT'); ));
} }
if (!$res) if (!$res)
+1 -1
View File
@@ -270,7 +270,7 @@ class Followup extends Module
$values['id_cart'] = (int)($id_cart); $values['id_cart'] = (int)($id_cart);
if (!empty($id_customer)) if (!empty($id_customer))
$values['id_customer'] = (int)($id_customer); $values['id_customer'] = (int)($id_customer);
Db::getInstance()->autoExecute(_DB_PREFIX_.'log_email', $values, 'INSERT'); Db::getInstance()->insert('log_email', $values);
} }
/* Each cart which wasn't transformed into an order */ /* Each cart which wasn't transformed into an order */
+3 -3
View File
@@ -726,7 +726,7 @@ class shopimporter extends ImportModule
$item['cart_products'][$k][$key] = $foreignKey[$key][$val]; $item['cart_products'][$k][$key] = $foreignKey[$key][$val];
else else
$item['cart_products'][$k][$key] = 0; $item['cart_products'][$k][$key] = 0;
Db::getInstance()->autoExecute(_DB_PREFIX_.'cart_product', $item['cart_products'][$k],'INSERT'); Db::getInstance()->insert('cart_product', $item['cart_products'][$k]);
} }
foreach($item['order_products'] as $k => $order_products) foreach($item['order_products'] as $k => $order_products)
{ {
@@ -755,7 +755,7 @@ class shopimporter extends ImportModule
$item['order_products'][$k][$key] = $foreignKey[$key][$val]; $item['order_products'][$k][$key] = $foreignKey[$key][$val];
else else
$item['order_products'][$k][$key] = 0; $item['order_products'][$k][$key] = 0;
Db::getInstance()->autoExecute(_DB_PREFIX_.'order_detail', $item['order_products'][$k],'INSERT'); Db::getInstance()->insert('order_detail', $item['order_products'][$k]);
} }
//save order history //save order history
foreach($item['order_history'] as $k => $order_history) foreach($item['order_history'] as $k => $order_history)
@@ -767,7 +767,7 @@ class shopimporter extends ImportModule
else else
$item['order_history'][$k][$key] = 0; $item['order_history'][$k][$key] = 0;
Db::getInstance()->autoExecute(_DB_PREFIX_.'order_history', $item['order_history'][$k],'INSERT'); Db::getInstance()->insert('order_history', $item['order_history'][$k]);
} }
} }
} }