Fork me on GitHub

DBUtil::selectObjectCount specifying specfying category  Bottom

  • pretty easy question using selectobjectcount function:

    selectObjectCount( tablename $tablename, [where $where = ''], [column $column = '1'], [distinct $distinct = false], [categoryFilter $categoryFilter = null])

    where the categoryfilter is a list of categories to use, i need to count the number in only 1 category, it works if i leave out the category filter to get the total number of objects, i just have no idea how to specify a category....

    Code

    $categories = categoryUtil::getCategoriesByPath($cat['path'], '', 'path');
        $catempty = array();
        foreach ($categories as $category) {
             $catempty[$category['id']] = DBUtil::selectObjectCount('faqanswer', '', 'faqid', false, array('category' => $category['id']);
                    }
        $pnRender->assign('isempty', $catempty);


    is what i'm trying to do... but it returns 0 for every category


    any suggestions.



    edited by: kylegio, Jan 16, 2009 - 09:27 AM
  • The $categoryFilter array should be build as follows:

    Code

    array($catProperty1 => $catID1,
            $catProperty2 => array($catID2, $catID3));


    Remember that in Zikula you can register more than one categorization for the modules, and this multicategorization scenario requires a property name to know which category tree is being processed icon_wink
    By default, the Value Addons modules register a 'Main' property, but the News module for instance, usually uses the 'Main' and the 'Topic' category properties.

    So, your code may work with

    Code

    DBUtil::selectObjectCount('faqanswer', '', 'faqid', false, array('Main' => $category['id']);

    but i hope that be possible a non hardcoded property name; check the available data to see if there's the category property in use somewhere icon_wink

    Greetings

    --
    - Mateo T. -
    Mis principios... son mis fines

This list is based on users active over the last 60 minutes.