private function generateOptionsRecursively($pid = 0, $prefix = '')
    {
        $options = [];
        $records = $this->db->fetchAll('SELECT * FROM tl_news_category WHERE pid=? ORDER BY sorting', [$pid]);

        foreach ($records as $record) {
            $options[$record['id']] = $prefix . $record['title'];

            foreach ($this->generateOptionsRecursively($record['id'], $record['title'] . ' / ') as $k => $v) {
                $options[$k] = $v;
            }
        }

        return $options;
    }
private function generateOptionsRecursively($pid = 0, $prefix = '')
    {
        $options = [];
        $records = $this->db->fetchAll('SELECT * FROM tl_news_category WHERE pid=? ORDER BY sorting', [$pid]);

        foreach ($records as $record) {
            $options[$record['id']] = $prefix . $record['title'];

            foreach ($this->generateOptionsRecursively($record['id'], $record['title'] . ' / ') as $k => $v) {
                $options[$k] = $v;
            }
        }

        return $options;
    }
private function generateOptionsRecursively ( $ pid = 0 , $ prefix = '' ) { $ options = [ ] ; $ records = $ this -> db -> fetchAll ( 'SELECT * FROM tl_news_category WHERE pid=? ORDER BY sorting' , [ $ pid ] ) ; foreach ( $ records as $ record ) { $ options [ $ record [ 'id' ] ] = $ prefix . $ record [ 'title' ] ; foreach ( $ this -> generateOptionsRecursively ( $ record [ 'id' ] , $ record [ 'title' ] . ' / ' ) as $ k => $ v ) { $ options [ $ k ] = $ v ; } } return $ options ; }
Generate the options recursively

@param int    $pid
@param string $prefix

@return array
Generate the options recursively