PHP Code:
//get num of links in root category (and its subcats) (ALL-ALWAYS)
foreach ($roots as $roots_id){
$root_count_array_total[$roots_id->category_id]=
$db->get_var("SELECT count(link_id) FROM ".table_links." WHERE link_category=".$roots_id->category_id.
" OR link_category IN (SELECT distinct subcat.category_id FROM ".table_categories.
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.
".category_id WHERE ".table_categories.".category_id=".$roots_id->category_id.
" UNION SELECT distinct subcat2.category_id FROM ".table_categories.
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.".category_id".
" JOIN ".table_categories." subcat2 ON subcat2.category_parent=subcat.category_id".
" WHERE ".table_categories.".category_id=".$roots_id->category_id.")");
PHP Code:
//get num of links in root category (and its subcats) (ALL-ALWAYS)
foreach ($roots as $roots_id){
$root_count_array_total[$roots_id->category_id]=
$db->get_var("SELECT count(link_id) FROM ".table_links." WHERE link_status NOT LIKE 'discard' AND (link_category=".$roots_id->category_id.
" OR link_category IN (SELECT distinct subcat.category_id FROM ".table_categories.
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.
".category_id WHERE ".table_categories.".category_id=".$roots_id->category_id.
" UNION SELECT distinct subcat2.category_id FROM ".table_categories.
" JOIN ".table_categories." subcat ON subcat.category_parent=".table_categories.".category_id".
" JOIN ".table_categories." subcat2 ON subcat2.category_parent=subcat.category_id".
" WHERE ".table_categories.".category_id=".$roots_id->category_id."))");







Linear Mode

