[*] Classes : table prefix is no longer required in Db::getInstance()->delete() method

This commit is contained in:
rMalie
2012-02-16 14:54:52 +00:00
parent 2f9fd38e01
commit eb97902fdd
10 changed files with 25 additions and 20 deletions
+1 -1
View File
@@ -710,7 +710,7 @@ class CarrierCore extends ObjectModel
else
$where .= 'AND id_shop = '.$shop_id;
return Db::getInstance()->delete(_DB_PREFIX_.'delivery', $where);
return Db::getInstance()->delete('delivery', $where);
}
/**
+2 -2
View File
@@ -69,13 +69,13 @@ class GroupReductionCore extends ObjectModel
$ids[] = $row['id_product'];
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());
}
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()
+4 -4
View File
@@ -527,21 +527,21 @@ abstract class ObjectModelCore
$this->clearCache();
// 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)
return false;
// Database deletion for multilingual fields related to the object
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();
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();
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::exec('actionObjectDeleteAfter', array('object' => $this));
+1 -1
View File
@@ -145,7 +145,7 @@ class ProductDownloadCore extends ObjectModel
return false;
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);
}
/**
+1 -1
View File
@@ -198,7 +198,7 @@ class ProductSaleCore
WHERE `id_product` = '.(int)$id_product
);
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;
}
}
+4 -4
View File
@@ -131,14 +131,14 @@ class StateCore extends ObjectModel
{
if (!$this->isUsed())
{
/* Database deletion */
$result = Db::getInstance()->delete(_DB_PREFIX_.$this->def['table'], '`'.$this->def['primary'].'` = '.(int)$this->id);
// Database deletion
$result = Db::getInstance()->delete($this->def['table'], '`'.$this->def['primary'].'` = '.(int)$this->id);
if (!$result)
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']))
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;
}
else
+8 -2
View File
@@ -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 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
* @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
*/
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 bool $null_values If we want to use NULL values instead of empty quotes
* @param bool $use_cache
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
* @return bool
*/
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 int $limit Number max of rows to delete
* @param bool $use_cache Use cache or not
* @param bool $add_prefix Add or not _DB_PREFIX_ before table name
* @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;
$sql = 'DELETE FROM `'.bqSQL($table).'`'.($where ? ' WHERE '.$where : '').($limit ? ' LIMIT '.(int)$limit : '');
$res = $this->query($sql);
+2 -2
View File
@@ -171,10 +171,10 @@ class ShopCore extends ObjectModel
}
// 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
$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);
-1
View File
@@ -171,7 +171,6 @@ class InstallModelInstall extends InstallAbstractModel
*/
public function populateDatabase($entity = null)
{
Db::getInstance()->delete(_DB_PREFIX_.'timezone');
$languages = array();
foreach (Language::getLanguages(false) as $lang)
$languages[$lang['id_lang']] = $lang['iso_code'];
+2 -2
View File
@@ -74,8 +74,8 @@ class MenuTopLinks
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(_DB_PREFIX_.'linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop);
Db::getInstance()->delete('linksmenutop', 'id_linksmenutop = '.(int)$id_linksmenutop.' AND id_shop = '.(int)$id_shop);
Db::getInstance()->delete('linksmenutop_lang', 'id_linksmenutop = '.(int)$id_linksmenutop);
}
}
?>