Fork me on GitHub

how to use DBUtil and categories  Bottom

  • have a table (tableN) with the fields "ida" "name" "cat_id1" "cat_id2". In the fields "cat_id1" "cat_id2" found "id" categories with values. how to get data from a table tableN categories of a single query, with the values of categories, using DBUtil
  • i make query :

    Code

    select items.*
    from tableN as items
    left join  z_categories_category as cat1 on items.cat_id1 = cat1.cat_id
    left join  z_categories_category as cat2 on items.cat_id2 = cat2.cat_id


    and make execute SQL
    index was build by all useable field
    how it to do using by DBUtil
  • You want to use DBUtil::selectExpandedObjectArray and supply a join structure like this:

    Code

    $this->_objJoin[] = array ( 'join_table'          =>  'categories_category',
                                'join_field'          =>  array('name', 'display_name'),
                                'object_field_name'   =>  array('category_name', 'category_display_names'),
                                'compare_field_table' =>  'category_id',
                                'compare_field_join'  =>  'id');


    There is a page in our Wiki describing this in a bit greater detail ...

    Greetings
    R
  • Thx for replie! details can be, please? without detail it looks like ... If you need a car, take this with a piece of iron and treat it by saw
  • Sorry, I don't understand what you're asking ... please be more specific ...

    Greetings
    R
  • Hi, Robert
    please, rewrite this

    Code

    select items.*
    from tableN as items
    left join  z_categories_category as cat1 on items.cat_id1 = cat1.cat_id
    left join  z_categories_category as cat2 on items.cat_id2 = cat2.cat_id


    use DBUTil?
  • Your code to build the join structure should look something like this:

    Code

    for ($i=1; $i<=2; $i++) {
                $this->_objJoin[] = array (
                    'join_table'          =>  'categories_category',
                    'join_field'          =>  array('name', 'display_name'),
                    'object_field_name'   =>  array("category{$i}_name", "category{$i}_display_names"),
                    'compare_field_table' =>  "category{$i}_id",
                    'compare_field_join'  =>  'id');
            }


    I would suggest you see the zWebstore file classes/PNProduct.class.php for an example of just that ...

    Greetings
    R
  • Have a look at here also : http://api.zikula.de…ExpandedObjectArray



    edited by: pnFilip, datetimebrief
  • O... Great, Thx for all, big thx.

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