ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

query module malfunction

December 16, 2011 9:17am

Subscribe [3]
  • #1 / Dec 16, 2011 9:17am

    jelle

    104 posts

    I am having an issue with exp:query, after checking it on the pt site(http://help.pixelandtonic.com/brandonkelly/topics/can_i_conditionally_display_a_specific_cells_content). It seems as if this error is caused by the query module of EE

    if i put this statement in a template, it returns an error
    statement:

    {embed='inc/.get_quote'
      entry_ids='{exp:query sql="
        SELECT md.entry_id FROM exp_matrix_data md
        INNER JOIN exp_channel_titles ct ON ct.entry_id = md.entry_id
        WHERE md.col_id_25 = "Strategy"
        AND ct.channel_id = 6
    "}'}

    error:

    Error Number: 1064
    
    You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1
    
    SELECT md.entry_id FROM exp_matrix_data md INNER JOIN exp_channel_titles ct ON ct.entry_id = md.entry_id WHERE md.col_id_25 =
    
    Filename: modules/query/mod.query.php
    
    Line Number: 181

    However, if i change the double quotes around Strategy into single quotes, there is no error, but no id’s are passed to the embedded template.

    When i run the query in the sql manager, it does work, and returns a number of id’s

  • #2 / Dec 16, 2011 11:28am

    neuralynx

    62 posts

    I could be wrong, but I believe you need to structure your template a little differently:

    {exp:query sql="SELECT md.entry_id FROM exp_matrix_data md
                    INNER JOIN exp_channel_titles ct ON ct.entry_id = md.entry_id
                    WHERE md.col_id_25 = 'Strategy'
                    AND ct.channel_id = 6"}
    
        <!- Now within this block, you can reference {entry_id} (or is it {md.entry_id} ? )-->
    
        {exp:channel:entries entry_id="{entry_id}"}
            <!- Do something with the channel entries -->
        {/exp:channel:entries}
    {/exp:query}

    At least that’s the way I’d do it.

  • #3 / Dec 16, 2011 12:26pm

    jelle

    104 posts

    Allthough it works on a basic level, i need to get 1 entry_id, and all the data from that entry. This way, i am getting all matrix data that matches “strategy”.

    in a non-matrix world we were using:
    <br /> {exp:channel:entries channel="people" dynamic="no" limit="1" orderby="random" entry_id="not 109|136|135|72" search:quote-strategie="not IS_EMPTY"}<br /> volgens {first-name} {tussenvoegsels} {last-name}</h2><br /> <a href="/over-ons/onze-mensen/{url_title}" title="{first-name} {tussenvoegsels} {last-name}">{people-thumbnail}</a><br /> {quote-strategie}<br /> <hr ><br /> {en_people_matrix_quotes search:en_people_quotes_pijler="=strategy"}<br />   {en_people_quotes_quote}<br /> {/en_people_matrix_quotes}<br /> <div class=“ctaLink”><br />   <a href="/over-ons/onze-mensen/{url_title}">Lees meer over {first-name} {tussenvoegsels} {last-name}</a><br />   </div><br /> {/exp:channel:entries}<br />

    But we want to move away from this because it lacks flexibility.

  • #4 / Dec 19, 2011 5:06am

    John Henry Donovan

    12339 posts

    Hi jelle,

    This relates to a third-party add-on so moving this thread to the Community Forums where its more appropriate

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases