public static function getCategories($uid, $table)
    {
        $categoryData = array(
            'uid_list' => array(),
            'title_list' => array()
        );

        if ($uid && $table) {
            $queryBuilder = Db::getQueryBuilder($table);
            $categoryRecords = $queryBuilder
                ->add('select', '`sys_category`.`uid`, `sys_category`.`title`')
                ->from('sys_category')
                ->from('sys_category_record_mm')
                ->from($table)
                ->add(
                    'where',
                    '`sys_category`.`uid` = `sys_category_record_mm`.`uid_local`'
                    . ' AND `' . $table . '`.`uid` = `sys_category_record_mm`.`uid_foreign`'
                    . ' AND `' . $table . '`.`uid` = ' . $uid
                    . ' AND `sys_category_record_mm`.`tablenames` ="' . $table . '"'
                )
                ->add('orderBy', '`sys_category_record_mm`.`sorting`')
                ->execute()
                ->fetchAll();

            if (!empty($categoryRecords)) {
                foreach ($categoryRecords as $cat) {
                    $categoryData['uid_list'][] = $cat['uid'];
                    $categoryData['title_list'][] = $cat['title'];
                }
            }
        }

        return $categoryData;
    }
public static function getCategories($uid, $table)
    {
        $categoryData = array(
            'uid_list' => array(),
            'title_list' => array()
        );

        if ($uid && $table) {
            $queryBuilder = Db::getQueryBuilder($table);
            $categoryRecords = $queryBuilder
                ->add('select', '`sys_category`.`uid`, `sys_category`.`title`')
                ->from('sys_category')
                ->from('sys_category_record_mm')
                ->from($table)
                ->add(
                    'where',
                    '`sys_category`.`uid` = `sys_category_record_mm`.`uid_local`'
                    . ' AND `' . $table . '`.`uid` = `sys_category_record_mm`.`uid_foreign`'
                    . ' AND `' . $table . '`.`uid` = ' . $uid
                    . ' AND `sys_category_record_mm`.`tablenames` ="' . $table . '"'
                )
                ->add('orderBy', '`sys_category_record_mm`.`sorting`')
                ->execute()
                ->fetchAll();

            if (!empty($categoryRecords)) {
                foreach ($categoryRecords as $cat) {
                    $categoryData['uid_list'][] = $cat['uid'];
                    $categoryData['title_list'][] = $cat['title'];
                }
            }
        }

        return $categoryData;
    }
public static function getCategories ( $ uid , $ table ) { $ categoryData = array ( 'uid_list' => array ( ) , 'title_list' => array ( ) ) ; if ( $ uid && $ table ) { $ queryBuilder = Db :: getQueryBuilder ( $ table ) ; $ categoryRecords = $ queryBuilder -> add ( 'select' , '`sys_category`.`uid`, `sys_category`.`title`' ) -> from ( 'sys_category' ) -> from ( 'sys_category_record_mm' ) -> from ( $ table ) -> add ( 'where' , '`sys_category`.`uid` = `sys_category_record_mm`.`uid_local`' . ' AND `' . $ table . '`.`uid` = `sys_category_record_mm`.`uid_foreign`' . ' AND `' . $ table . '`.`uid` = ' . $ uid . ' AND `sys_category_record_mm`.`tablenames` ="' . $ table . '"' ) -> add ( 'orderBy' , '`sys_category_record_mm`.`sorting`' ) -> execute ( ) -> fetchAll ( ) ; if ( ! empty ( $ categoryRecords ) ) { foreach ( $ categoryRecords as $ cat ) { $ categoryData [ 'uid_list' ] [ ] = $ cat [ 'uid' ] ; $ categoryData [ 'title_list' ] [ ] = $ cat [ 'title' ] ; } } } return $ categoryData ; }
returns the list of assigned categories to a certain record in a certain table
@param integer $uid
@param string $table
@author Christian Bülter <buelter@kennziffer.com>
@since 17.10.14
@return array
returns the list of assigned categories to a certain record in a certain table