Skip to content

Commit

Permalink
Precount $category_links and $column_list for performance
Browse files Browse the repository at this point in the history
  • Loading branch information
acidvertigo committed Aug 14, 2011
1 parent 49bfc28 commit 4d754cf
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions catalog/index.php
Expand Up @@ -49,7 +49,8 @@
if (isset($cPath) && strpos('_', $cPath)) { if (isset($cPath) && strpos('_', $cPath)) {
// check to see if there are deeper categories within the current category // check to see if there are deeper categories within the current category
$category_links = array_reverse($cPath_array); $category_links = array_reverse($cPath_array);
for($i=0, $n=sizeof($category_links); $i<$n; $i++) { $n=sizeof($category_links);
for($i=0;$i<$n; $i++) {
$categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'"); $categories_query = tep_db_query("select count(*) as total from " . TABLE_CATEGORIES . " c, " . TABLE_CATEGORIES_DESCRIPTION . " cd where c.parent_id = '" . (int)$category_links[$i] . "' and c.categories_id = cd.categories_id and cd.language_id = '" . (int)$languages_id . "'");
$categories = tep_db_fetch_array($categories_query); $categories = tep_db_fetch_array($categories_query);
if ($categories['total'] < 1) { if ($categories['total'] < 1) {
Expand Down Expand Up @@ -111,8 +112,8 @@
} }


$select_column_list = ''; $select_column_list = '';

$n=sizeof($column_list);
for ($i=0, $n=sizeof($column_list); $i<$n; $i++) { for ($i=0; $i<$n; $i++) {
switch ($column_list[$i]) { switch ($column_list[$i]) {
case 'PRODUCT_LIST_MODEL': case 'PRODUCT_LIST_MODEL':
$select_column_list .= 'p.products_model, '; $select_column_list .= 'p.products_model, ';
Expand Down

0 comments on commit 4d754cf

Please sign in to comment.