• Resolved ledevweb

    (@ledevweb)


    Hi,

    I just updated the Pods plugin to the last 2.8, and now some pages of my website are broken. I get an SQL error.

    I created a CPT “maine_coon” to display cats on my website. Each cat have 2 relationship fields to link the cat to his father and his mother (that are also maine coons).

    In my functions.php file, I created a function to get kitten from a specific cat (from his ID), with the pods()->find() method.

    Here is my code to set the params options (pere = father, mere = mother):

    $params = array(
    	'where'=>'pere.id = '.$parent_id.' OR mere.id = '.$parent_id	
    );

    It worked perfectly in 2.7 version of the plugin. Now, with 2.8 version, I get an SQL error :

    Database Error; SQL: SELECT DISTINCTt.* FROMwp_postsAStLEFT JOINwp_podsrelASrel_pereONrel_pere.field_id= 141 ANDrel_pere.item_id=t.IDLEFT JOINwp_postsASpereONpere.ID=rel_pere.related_item_idLEFT JOINwp_postmetaASmere_idONmere_id.meta_key= 'ID' ANDmere_id.post_id=mere.IDLEFT JOINwp_podsrelASrel_mereONrel_mere.field_id= 142 ANDrel_mere.item_id=t.IDLEFT JOINwp_postsASmereONmere.ID=rel_mere.related_item_idWHERE ( (pere.id= 1015 ORmere.id= 1015 ) AND (t.post_type= 'maine_coon' ) AND (t.post_statusIN ( 'publish' ) ) ) ORDER BYt.menu_order,t.post_title,t.post_dateLIMIT 0, 15; Response: Unknown column 'mere.ID' in 'on clause'

    I tried to change the params options this way :

    $params = array(
    	'where'=>'mere.id = '.$parent_id
    );

    It worked perfectly. It also worked perfectly with :

    $params = array(
    	'where'=>'pere.id = '.$parent_id
    );

    But with the OR condition, it doesn’t work anymore :/

    Can you tell me how I can fix this bug ?

    Thx

    • This topic was modified 2 years, 6 months ago by ledevweb.
Viewing 8 replies - 1 through 8 (of 8 total)
Viewing 8 replies - 1 through 8 (of 8 total)
  • The topic ‘OR condition doesn’t work anymore in ‘params’ options’ is closed to new replies.