View Single Post
  #10  
Old 01-05-2013, 02:55 PM
  cherie's Avatar 
cherie cherie is offline
 

X-Wizard
  
Join Date: May 2003
Location: USA
Posts: 1,534
 

Default Re: Manufacturer on Product List / Recommended

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.
__________________
redlimeweb.com
custom mods and design integration
4.7 linux
Reply With Quote