Quote:
Originally Posted by cherie
I recommend doing a single query rather than a separate query for each product. For example (untested):
PHP Code:
$mids = array();
foreach ($products as $p)
$mids[] = $p['manufacturerid'];
if (!empty($mids)) {
$manufacturers = func_query_hash("SELECT manufacturerid,manufacturer FROM $sql_tbl[manufacturers] WHERE manufacturerid IN(".implode(',',$mids).")",'manufacturerid',FALSE,TRUE);
foreach ($products as $k=>$p)
$products[$k]['manufacturer'] = $manufacturers[$p['manufacturerid']];
}
I'd rather loop through products twice and do a single query than a single loop with multiple queries.
|
Hi Cherie
Thanks a lot your code works fine on all the pages for 4.5.4

i.e. on products.php, search.php & featured_products.php
Can you please explain me what is the advantage of your code ? I mean it will load the page fast or will use mysql more efficiently ?
Note: any body using this code just make sure that you do not keep any extra space on any line or you may get php error warning at admin/logs.php