Code
// build the where clause
$where = array();
$count = 1;
foreach ($categoryFilter as $property => $category) {
// this allows to have an array of categories IDs
if (is_array($category)) {
$wherecat = array();
foreach ($category as $cat) {
$wherecat[] = "mapobj".$count.".cmo_category_id='".DataUtil::formatForStore($cat)."'";
}
$wherecat = '('.implode(' OR ', $wherecat).')';
// if there's only one category ID
} else {
$wherecat = "mapobj".$count.".cmo_category_id='".DataUtil::formatForStore($category)."'";
}
$where[] = "cmo_obj_id IN (SELECT mapobj".$count.".cmo_obj_id FROM pn_categories_mapobj mapobj".$count." WHERE mapobj".$count.".cmo_reg_id = '".DataUtil::formatForStore($propids[$property])."' AND ".$wherecat.")";
$count++;
}
$where = "cmo_table='".DataUtil::formatForStore($tablename)."' AND (".implode(' AND ', $where).")";
$where = array();
$count = 1;
foreach ($categoryFilter as $property => $category) {
// this allows to have an array of categories IDs
if (is_array($category)) {
$wherecat = array();
foreach ($category as $cat) {
$wherecat[] = "mapobj".$count.".cmo_category_id='".DataUtil::formatForStore($cat)."'";
}
$wherecat = '('.implode(' OR ', $wherecat).')';
// if there's only one category ID
} else {
$wherecat = "mapobj".$count.".cmo_category_id='".DataUtil::formatForStore($category)."'";
}
$where[] = "cmo_obj_id IN (SELECT mapobj".$count.".cmo_obj_id FROM pn_categories_mapobj mapobj".$count." WHERE mapobj".$count.".cmo_reg_id = '".DataUtil::formatForStore($propids[$property])."' AND ".$wherecat.")";
$count++;
}
$where = "cmo_table='".DataUtil::formatForStore($tablename)."' AND (".implode(' AND ', $where).")";
Any category experts to comment out there?
