[*] Classes : table prefix is no longer required in Db::getInstance()->delete() method
This commit is contained in:
+1
-1
@@ -710,7 +710,7 @@ class CarrierCore extends ObjectModel
|
|||||||
else
|
else
|
||||||
$where .= 'AND id_shop = '.$shop_id;
|
$where .= 'AND id_shop = '.$shop_id;
|
||||||
|
|
||||||
return Db::getInstance()->delete(_DB_PREFIX_.'delivery', $where);
|
return Db::getInstance()->delete('delivery', $where);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -69,13 +69,13 @@ class GroupReductionCore extends ObjectModel
|
|||||||
$ids[] = $row['id_product'];
|
$ids[] = $row['id_product'];
|
||||||
|
|
||||||
if ($ids)
|
if ($ids)
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'product_group_reduction_cache', 'id_product IN ('.implode(', ', $ids).')');
|
Db::getInstance()->delete('product_group_reduction_cache', 'id_product IN ('.implode(', ', $ids).')');
|
||||||
return (parent::delete());
|
return (parent::delete());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _clearCache()
|
protected function _clearCache()
|
||||||
{
|
{
|
||||||
return Db::getInstance()->execute('DELETE FROM `'._DB_PREFIX_.'product_group_reduction_cache` WHERE `id_group` = '.(int)$this->id_group);
|
return Db::getInstance()->delete('product_group_reduction_cache', 'id_group = '.(int)$this->id_group);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected function _setCache()
|
protected function _setCache()
|
||||||
|
|||||||
@@ -527,21 +527,21 @@ abstract class ObjectModelCore
|
|||||||
$this->clearCache();
|
$this->clearCache();
|
||||||
|
|
||||||
// Database deletion
|
// Database deletion
|
||||||
$result = Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'], '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
|
$result = Db::getInstance()->delete($this->def['table'], '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
|
||||||
if (!$result)
|
if (!$result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
// Database deletion for multilingual fields related to the object
|
// Database deletion for multilingual fields related to the object
|
||||||
if (isset($this->def['multilang']) && $this->def['multilang'])
|
if (isset($this->def['multilang']) && $this->def['multilang'])
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'].'_lang', '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
|
Db::getInstance()->delete($this->def['table'].'_lang', '`'.pSQL($this->def['primary']).'` = '.(int)$this->id);
|
||||||
|
|
||||||
$assos = Shop::getAssoTables();
|
$assos = Shop::getAssoTables();
|
||||||
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'shop')
|
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'shop')
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'].'_shop', '`'.$this->def['primary'].'`='.(int)$this->id);
|
Db::getInstance()->delete($this->def['table'].'_shop', '`'.$this->def['primary'].'`='.(int)$this->id);
|
||||||
|
|
||||||
$assos = GroupShop::getAssoTables();
|
$assos = GroupShop::getAssoTables();
|
||||||
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'group_shop')
|
if (isset($assos[$this->def['table']]) && $assos[$this->def['table']]['type'] == 'group_shop')
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'].'_group_shop', '`'.$this->def['primary'].'`='.(int)$this->id);
|
Db::getInstance()->delete($this->def['table'].'_group_shop', '`'.$this->def['primary'].'`='.(int)$this->id);
|
||||||
|
|
||||||
// @hook actionObject*DeleteAfter
|
// @hook actionObject*DeleteAfter
|
||||||
Hook::exec('actionObjectDeleteAfter', array('object' => $this));
|
Hook::exec('actionObjectDeleteAfter', array('object' => $this));
|
||||||
|
|||||||
@@ -145,7 +145,7 @@ class ProductDownloadCore extends ObjectModel
|
|||||||
return false;
|
return false;
|
||||||
|
|
||||||
return unlink(_PS_DOWNLOAD_DIR_.$this->filename)
|
return unlink(_PS_DOWNLOAD_DIR_.$this->filename)
|
||||||
&& Db::getInstance()->delete(_DB_PREFIX_.'product_download', 'id_product_download = '.(int)$id_product_download);
|
&& Db::getInstance()->delete('product_download', 'id_product_download = '.(int)$id_product_download);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -198,7 +198,7 @@ class ProductSaleCore
|
|||||||
WHERE `id_product` = '.(int)$id_product
|
WHERE `id_product` = '.(int)$id_product
|
||||||
);
|
);
|
||||||
elseif ($total_sales == 1)
|
elseif ($total_sales == 1)
|
||||||
return Db::getInstance()->delete(_DB_PREFIX_.'product_sale', 'id_product = '.(int)$id_product);
|
return Db::getInstance()->delete('product_sale', 'id_product = '.(int)$id_product);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
+4
-4
@@ -131,14 +131,14 @@ class StateCore extends ObjectModel
|
|||||||
{
|
{
|
||||||
if (!$this->isUsed())
|
if (!$this->isUsed())
|
||||||
{
|
{
|
||||||
/* Database deletion */
|
// Database deletion
|
||||||
$result = Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'], '`'.$this->def['primary'].'` = '.(int)$this->id);
|
$result = Db::getInstance()->delete($this->def['table'], '`'.$this->def['primary'].'` = '.(int)$this->id);
|
||||||
if (!$result)
|
if (!$result)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
/* Database deletion for multilingual fields related to the object */
|
// Database deletion for multilingual fields related to the object
|
||||||
if (!empty($this->def['multilang']))
|
if (!empty($this->def['multilang']))
|
||||||
Db::getInstance()->execute('DELETE FROM `'.pSQL(_DB_PREFIX_.$this->def['table']).'_lang` WHERE `'.$this->def['primary'].'` = '.(int)$this->id);
|
Db::getInstance()->delete(bqSQL($this->def['table']).'_lang', '`'.$this->def['primary'].'` = '.(int)$this->id);
|
||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
+8
-2
@@ -316,7 +316,8 @@ abstract class DbCore
|
|||||||
* @param array $data Data to insert as associative array. If $data is a list of arrays, multiple insert will be done
|
* @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 $null_values If we want to use NULL values instead of empty quotes
|
||||||
* @param bool $use_cache
|
* @param bool $use_cache
|
||||||
* @param $type Must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE
|
* @param int $type Must be Db::INSERT or Db::INSERT_IGNORE or Db::REPLACE
|
||||||
|
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function insert($table, $data, $null_values = false, $use_cache = true, $type = Db::INSERT, $add_prefix = true)
|
public function insert($table, $data, $null_values = false, $use_cache = true, $type = Db::INSERT, $add_prefix = true)
|
||||||
@@ -379,6 +380,7 @@ abstract class DbCore
|
|||||||
* @param int $limit
|
* @param int $limit
|
||||||
* @param bool $null_values If we want to use NULL values instead of empty quotes
|
* @param bool $null_values If we want to use NULL values instead of empty quotes
|
||||||
* @param bool $use_cache
|
* @param bool $use_cache
|
||||||
|
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function update($table, $data, $where = '', $limit = 0, $null_values = false, $use_cache = true, $add_prefix = true)
|
public function update($table, $data, $where = '', $limit = 0, $null_values = false, $use_cache = true, $add_prefix = true)
|
||||||
@@ -415,10 +417,14 @@ abstract class DbCore
|
|||||||
* @param string $where WHERE clause on query
|
* @param string $where WHERE clause on query
|
||||||
* @param int $limit Number max of rows to delete
|
* @param int $limit Number max of rows to delete
|
||||||
* @param bool $use_cache Use cache or not
|
* @param bool $use_cache Use cache or not
|
||||||
|
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
public function delete($table, $where = '', $limit = 0, $use_cache = true)
|
public function delete($table, $where = '', $limit = 0, $use_cache = true, $add_prefix = true)
|
||||||
{
|
{
|
||||||
|
if (_DB_PREFIX_ && !preg_match('#^'._DB_PREFIX_.'#i', $table) && $add_prefix)
|
||||||
|
$table = _DB_PREFIX_.$table;
|
||||||
|
|
||||||
$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);
|
||||||
|
|||||||
@@ -171,10 +171,10 @@ class ShopCore extends ObjectModel
|
|||||||
}
|
}
|
||||||
|
|
||||||
// removes stock available
|
// removes stock available
|
||||||
$res &= Db::getInstance()->delete(_DB_PREFIX_.'stock_available', 'id_shop = '.(int)$this->id);
|
$res &= Db::getInstance()->delete('stock_available', 'id_shop = '.(int)$this->id);
|
||||||
|
|
||||||
// Remove urls
|
// Remove urls
|
||||||
$res &= Db::getInstance()->delete(_DB_PREFIX_.'shop_url', 'id_shop = '.(int)$this->id);
|
$res &= Db::getInstance()->delete('shop_url', 'id_shop = '.(int)$this->id);
|
||||||
|
|
||||||
Shop::cacheShops(true);
|
Shop::cacheShops(true);
|
||||||
|
|
||||||
|
|||||||
@@ -171,7 +171,6 @@ class InstallModelInstall extends InstallAbstractModel
|
|||||||
*/
|
*/
|
||||||
public function populateDatabase($entity = null)
|
public function populateDatabase($entity = null)
|
||||||
{
|
{
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'timezone');
|
|
||||||
$languages = array();
|
$languages = array();
|
||||||
foreach (Language::getLanguages(false) as $lang)
|
foreach (Language::getLanguages(false) as $lang)
|
||||||
$languages[$lang['id_lang']] = $lang['iso_code'];
|
$languages[$lang['id_lang']] = $lang['iso_code'];
|
||||||
|
|||||||
@@ -74,8 +74,8 @@ class MenuTopLinks
|
|||||||
|
|
||||||
public static function remove($id_linksmenutop, $id_shop)
|
public static function remove($id_linksmenutop, $id_shop)
|
||||||
{
|
{
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop', 'id_linksmenutop = '.(int)$id_linksmenutop.' AND id_shop = '.(int)$id_shop);
|
Db::getInstance()->delete('linksmenutop', 'id_linksmenutop = '.(int)$id_linksmenutop.' AND id_shop = '.(int)$id_shop);
|
||||||
Db::getInstance()->delete(_DB_PREFIX_.'linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop);
|
Db::getInstance()->delete('linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|||||||
Reference in New Issue
Block a user