// 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:
vChabot
2011-09-27 15:08:24 +00:00
parent 810f17c38e
commit 2045401f9e
10 changed files with 52 additions and 53 deletions
+9 -9
View File
@@ -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;
}
}