Skip to content

Commit

Permalink
[PSR-2] Fix coding standards in Shop* class files
Browse files Browse the repository at this point in the history
  • Loading branch information
Gytis committed Aug 25, 2015
1 parent 425acfa commit f1e83c0
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 32 deletions.
49 changes: 23 additions & 26 deletions classes/shop/Shop.php
Original file line number Diff line number Diff line change
Expand Up @@ -195,12 +195,12 @@ public function setUrl()
$cache_id = 'Shop::setUrl_'.(int)$this->id;
if (!Cache::isStored($cache_id)) {
$row = Db::getInstance()->getRow('
SELECT su.physical_uri, su.virtual_uri, su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
FROM '._DB_PREFIX_.'shop s
LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
WHERE s.id_shop = '.(int)$this->id.'
AND s.active = 1 AND s.deleted = 0 AND su.main = 1');
SELECT su.physical_uri, su.virtual_uri, su.domain, su.domain_ssl, t.id_theme, t.name, t.directory
FROM '._DB_PREFIX_.'shop s
LEFT JOIN '._DB_PREFIX_.'shop_url su ON (s.id_shop = su.id_shop)
LEFT JOIN '._DB_PREFIX_.'theme t ON (t.id_theme = s.id_theme)
WHERE s.id_shop = '.(int)$this->id.'
AND s.active = 1 AND s.deleted = 0 AND su.main = 1');
Cache::store($cache_id, $row);
} else {
$row = Cache::retrieve($cache_id);
Expand Down Expand Up @@ -261,8 +261,8 @@ public function delete()
} else {
$table_name .= '_'.$row['type'];
}
$res &= Db::getInstance()->execute('
DELETE FROM `'.bqSQL(_DB_PREFIX_.$table_name).'`
$res &= Db::getInstance()->execute(
'DELETE FROM `'.bqSQL(_DB_PREFIX_.$table_name).'`
WHERE `'.bqSQL($id).'`='.(int)$this->id
);
}
Expand All @@ -287,16 +287,16 @@ public function delete()
public static function hasDependency($id_shop)
{
$has_dependency = false;
$nbr_customer = (int)Db::getInstance()->getValue('
SELECT count(*)
$nbr_customer = (int)Db::getInstance()->getValue(
'SELECT count(*)
FROM `'._DB_PREFIX_.'customer`
WHERE `id_shop`='.(int)$id_shop
);
if ($nbr_customer) {
$has_dependency = true;
} else {
$nbr_order = (int)Db::getInstance()->getValue('
SELECT count(*)
$nbr_order = (int)Db::getInstance()->getValue(
'SELECT count(*)
FROM `'._DB_PREFIX_.'orders`
WHERE `id_shop`='.(int)$id_shop
);
Expand Down Expand Up @@ -887,8 +887,8 @@ public static function getContextListShopID($share = false)
*/
public static function getShopById($id, $identifier, $table)
{
return Db::getInstance()->executeS('
SELECT `id_shop`, `'.bqSQL($identifier).'`
return Db::getInstance()->executeS(
'SELECT `id_shop`, `'.bqSQL($identifier).'`
FROM `'._DB_PREFIX_.bqSQL($table).'_shop`
WHERE `'.bqSQL($identifier).'` = '.(int)$id
);
Expand All @@ -903,22 +903,19 @@ public static function getShopById($id, $identifier, $table)
public static function setContext($type, $id = null)
{
switch ($type) {
case self::CONTEXT_ALL :
case self::CONTEXT_ALL:
self::$context_id_shop = null;
self::$context_id_shop_group = null;
break;

case self::CONTEXT_GROUP :
break;
case self::CONTEXT_GROUP:
self::$context_id_shop = null;
self::$context_id_shop_group = (int)$id;
break;

case self::CONTEXT_SHOP :
break;
case self::CONTEXT_SHOP:
self::$context_id_shop = (int)$id;
self::$context_id_shop_group = Shop::getGroupFromShop($id);
break;

default :
break;
default:
throw new PrestaShopException('Unknown context for shop');
}

Expand Down Expand Up @@ -1213,8 +1210,8 @@ public static function getEntityIds($entity, $id_shop, $active = false, $delete
return false;
}

return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS('
SELECT entity.`id_'.pSQL($entity).'`
return Db::getInstance(_PS_USE_SQL_SLAVE_)->executeS(
'SELECT entity.`id_'.pSQL($entity).'`
FROM `'._DB_PREFIX_.pSQL($entity).'_shop`es
LEFT JOIN '._DB_PREFIX_.pSQL($entity).' entity
ON (entity.`id_'.pSQL($entity).'` = es.`id_'.pSQL($entity).'`)
Expand Down
12 changes: 6 additions & 6 deletions classes/shop/ShopGroup.php
Original file line number Diff line number Diff line change
Expand Up @@ -133,8 +133,8 @@ public static function hasDependency($id_shop_group, $check = 'all')
}

if ($check == 'all' || $check == 'customer') {
$total_customer = (int)Db::getInstance()->getValue('
SELECT count(*)
$total_customer = (int)Db::getInstance()->getValue(
'SELECT count(*)
FROM `'._DB_PREFIX_.'customer`
WHERE `id_shop` IN ('.implode(', ', $list_shops).')'
);
Expand All @@ -144,8 +144,8 @@ public static function hasDependency($id_shop_group, $check = 'all')
}

if ($check == 'all' || $check == 'order') {
$total_order = (int)Db::getInstance()->getValue('
SELECT count(*)
$total_order = (int)Db::getInstance()->getValue(
'SELECT count(*)
FROM `'._DB_PREFIX_.'orders`
WHERE `id_shop` IN ('.implode(', ', $list_shops).')'
);
Expand All @@ -159,8 +159,8 @@ public static function hasDependency($id_shop_group, $check = 'all')

public function shopNameExists($name, $id_shop = false)
{
return Db::getInstance()->getValue('
SELECT id_shop
return Db::getInstance()->getValue(
'SELECT id_shop
FROM '._DB_PREFIX_.'shop
WHERE name = "'.pSQL($name).'"
AND id_shop_group = '.(int)$this->id.'
Expand Down

0 comments on commit f1e83c0

Please sign in to comment.