// cleaning code (norm / perf)
git-svn-id: http://dev.prestashop.com/svn/v1/branches/1.5.x@8810 b9a71923-0436-4b27-9f14-aed3839534dd
This commit is contained in:
@@ -306,14 +306,14 @@ class AttributeCore extends ObjectModel
|
||||
$sql .= '
|
||||
ORDER BY `position`';
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
$sizeof = sizeof($result);
|
||||
|
||||
for ($i = 0; $i < $sizeof; $i++)
|
||||
$i = 0;
|
||||
foreach ($result as $value)
|
||||
$return = Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'attribute`
|
||||
SET `position` = '.(int)$i.'
|
||||
SET `position` = '.(int)$i++.'
|
||||
WHERE `id_attribute_group` = '.(int)$id_attribute_group.'
|
||||
AND `id_attribute` = '.(int)$result[$i]['id_attribute']);
|
||||
AND `id_attribute` = '.(int)$value['id_attribute']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -327,11 +327,11 @@ class AttributeCore extends ObjectModel
|
||||
*/
|
||||
public static function getHigherPosition($id_attribute_group)
|
||||
{
|
||||
$sql = 'SELECT `position`
|
||||
$sql = 'SELECT MAX(`position`)
|
||||
FROM `'._DB_PREFIX_.'attribute`
|
||||
WHERE id_attribute_group = '.(int)$id_attribute_group.'
|
||||
ORDER BY position DESC';
|
||||
return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
|
||||
WHERE id_attribute_group = '.(int)$id_attribute_group;
|
||||
$position = DB::getInstance()->getValue($sql);
|
||||
return ($position !== false) ? $position : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -262,17 +262,17 @@ class AttributeGroupCore extends ObjectModel
|
||||
$return = true;
|
||||
|
||||
$sql = '
|
||||
SELECT *
|
||||
SELECT `id_attribute_group`
|
||||
FROM `'._DB_PREFIX_.'attribute_group`
|
||||
ORDER BY `position`';
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
$sizeof = sizeof($result);
|
||||
|
||||
for ($i = 0; $i < $sizeof; $i++)
|
||||
$i = 0;
|
||||
foreach ($result as $value)
|
||||
$return = Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'attribute_group`
|
||||
SET `position` = '.(int)$i.'
|
||||
WHERE `id_attribute_group` = '.(int)$result[$i]['id_attribute_group']);
|
||||
SET `position` = '.(int)$i++.'
|
||||
WHERE `id_attribute_group` = '.(int)$value['id_attribute_group']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -285,10 +285,10 @@ class AttributeGroupCore extends ObjectModel
|
||||
*/
|
||||
public static function getHigherPosition()
|
||||
{
|
||||
$sql = 'SELECT `position`
|
||||
FROM `'._DB_PREFIX_.'attribute_group`
|
||||
ORDER BY position DESC';
|
||||
return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
|
||||
$sql = 'SELECT MAX(`position`)
|
||||
FROM `'._DB_PREFIX_.'attribute_group`';
|
||||
$position = DB::getInstance()->getValue($sql);
|
||||
return ($position !== false) ? $position : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
+9
-9
@@ -285,17 +285,17 @@ class FeatureCore extends ObjectModel
|
||||
$return = true;
|
||||
|
||||
$sql = '
|
||||
SELECT *
|
||||
SELECT `id_feature`
|
||||
FROM `'._DB_PREFIX_.'feature`
|
||||
ORDER BY `position`';
|
||||
$result = Db::getInstance()->ExecuteS($sql);
|
||||
$sizeof = sizeof($result);
|
||||
|
||||
for ($i = 0; $i < $sizeof; $i++)
|
||||
$i = 0;
|
||||
foreach ($result as $value)
|
||||
$return = Db::getInstance()->Execute('
|
||||
UPDATE `'._DB_PREFIX_.'feature`
|
||||
SET `position` = '.(int)$i.'
|
||||
WHERE `id_feature` = '.(int)$result[$i]['id_feature']);
|
||||
SET `position` = '.(int)$i++.'
|
||||
WHERE `id_feature` = '.(int)$value['id_feature']);
|
||||
return $return;
|
||||
}
|
||||
|
||||
@@ -308,10 +308,10 @@ class FeatureCore extends ObjectModel
|
||||
*/
|
||||
public static function getHigherPosition()
|
||||
{
|
||||
$sql = 'SELECT `position`
|
||||
FROM `'._DB_PREFIX_.'feature`
|
||||
ORDER BY position DESC';
|
||||
return ((DB::getInstance()->getValue($sql)!==false)) ? DB::getInstance()->getValue($sql) : -1;
|
||||
$sql = 'SELECT MAX(`position`)
|
||||
FROM `'._DB_PREFIX_.'feature`;
|
||||
$position = DB::getInstance()->getValue($sql);
|
||||
return ($position !== false) ? $position : -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user