Support » Plugin: Pods - Custom Content Types and Fields » Where Parameters to Access a Pod Problems

  • Resolved rolandksmith

    (@rolandksmith)


    If I have this coded in the snippet:

    $params = array(‘where=>”response.meta_value=’Y'”, ‘orderby’=>’t.post_title’,limit=>’-1′);

    All works as expected.

    If, however, the snippet is passed in a variable
    $theWhere = “response.meta_value=’Y'”;
    and code the snippet as
    $params = array(‘where’=>$where, ‘orderby’=>’t.post_title’, limit=>’-1′);

    the code throws an exception

    Database Error; SQL: SELECT DISTINCT t.* FROM wpxi_posts AS t LEFT JOIN wpxi_postmeta AS response ON response.meta_key = ‘response’ AND response.post_id = t.ID WHERE ( ( response.meta_value=’Y’ ) AND ( t.post_type = “student2” ) AND ( t.post_status IN ( “publish” ) ) ) ORDER BY t.post_title, t.menu_order, t.post_title, t.post_date; Response: 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 ”Y’ ) AND ( t.post_type = “student2” ) AND ( t.post_status IN ( ‘ at line 11

    Doing a print_r on the params shows:
    Array
    (
    [where] => response.meta_value=’Y’
    [orderby] => t.post_title
    [limit] => -1
    )

    I’ve tried a number of other combinations of quotes apostrophes, and have not found the right syntax.

    Help, please!

    Thanks!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Note, there’s a typo in my original message. I missed putting a ‘ in the ‘where=’… It should have read ‘where’=>”response.meta_value=’Y'”,

    Plugin Author Jory Hogeveen

    (@keraweb)

    Hello @rolandksmith

    This is still most likely due to a typo somewhere. Unfortunately WP forums modify the apostrophes so I can’t really see what your original code was.
    You could try to debug the SQL by adding ?pods_debug_sql=1 to your page.

    Cheers, Jory

    Plugin Author Scott Kingsley Clark

    (@sc0ttkclark)

    It does look like there’s some odd quote usage in the clause there. Just noting this because I can see the syntax error is directly related to the quotes in the clause.

    Double check you’ve used the very basic ' and " marks when writing the database query. Some times keyboards can output the more stylized versions of those which are not database compatible.

Viewing 3 replies - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.