Possible to use variable in category_order statement?

(10 posts) (2 voices)

Tags:

No tags yet.

  1. duane, Member

    Hi,

    I've developed a function that dynamically generates the query and mydbr view options, but using a variable with the category_order option doesn't seem to work (while a static listing does).

    I set a variable:

    SET @SortLegend = (SELECT CONCAT("'", GROUP_CONCAT(ta.answer ORDER BY sortorder ASC SEPARATOR "','"), "'") FROM answers ta WHERE ta.qid = inOptQid);

    which produces something like
    'Very frequently','Frequently','Occasionally','Rarely','Very rarely','Never'

    and then later I reference it:

    select 'dbr.chart.options', 'category_order', @SortLegend;

    But it just displays the legend as if the whole statement wasn't there (meaning out of order).

    Does dbr.chart.options and/or category_order accept variables (I don't see why it wouldn't!) and can you see any other problem?

  2. myDBR Team, Key Master

    Duane,
    the dbr.chart.options does accept variables, but as you are passing it as one variable, it will become one "'Very frequently','Frequently','Occasionally','Rarely','Very rarely','Never'" parameter instead of multiple parameters as intended.

    We'll take a look what could be done here.

    --
    myDBR Team

  3. duane, Member

    Yes. I suspected that was happening, but extensive searching of converting a variable into a literal (or a result set) has revealed nothing yet.

  4. myDBR Team, Key Master

    We'll make a change so that you can call category_order multiple times:

    select 'dbr.chart.options', 'category_order', category
    from mycategories
    order by sort_order;

    --
    myDBR Team

  5. duane, Member

    Great. Do I need to update my installation (I just did and it was the same version number) or is it in-progress?

  6. myDBR Team, Key Master

    Yeah,
    we need to implement it first ;)

    --
    myDBR Team

  7. myDBR Team, Key Master

    This functionality is now included in myDBR 4.2.3.

    Other new features include:

    • IP address & user agent into statistics
    • new chart option 'category_sort', 'string' | 'numeric' | 'natural'
    • PHP 5.1 support for Active Directory authentication

    --
    myDBR Team

  8. duane, Member

    Sounds great. Expectations are always high when asking for help and the normal response is "just update and it will work" :-)

  9. duane, Member

    FYI: this all seems to be working fine - thanks! (took me a while to realise there was 'category_order' and 'category_sort' options).

    Great job again as usual!

  10. myDBR Team, Key Master

    Hi,
    the category_order is an explicit order, whereas category_sort orders the data using the defined sort method (string | numeric | natural).

    --
    myDBR Team


Reply

You must log in to post.