The limitation or error of $wpdb
-
Hi for one page, I try to use a $wpdb->get_results() with a complex query (3 joints on the standard tables). The query runs directly on mySql, returns 2 results as expected, but $wpdb returns nothing !
My php code :$wpdb->flush(); $request = 'SELECT posts.ID AS ID, posts.post_title AS post_title, posts.post_content AS post_content FROM '.$wpdb->posts.' posts LEFT JOIN '.$wpdb->term_relationships.' relationships ON relationships.object_id = posts.ID LEFT JOIN '.$wpdb->term_taxonomy.' taxonomy ON taxonomy.term_taxonomy_id = relationships.term_taxonomy_id LEFT JOIN '.$wpdb->terms.' terms ON terms.term_id = taxonomy.term_id WHERE terms.name = "'.$pageTerm.'" AND posts.post_type = "reference" AND posts.post_status = "publish" ORDER BY posts.post_date DESC LIMIT 0, 2;'; $references = $wpdb->get_results($request);
The request generated is : SELECT posts.ID AS myID, posts.post_title AS myPost_title, posts.post_content AS myPost_content FROM wp1_posts posts LEFT JOIN wp1_term_relationships relationships ON relationships.object_id = posts.ID LEFT JOIN wp1_term_taxonomy taxonomy ON taxonomy.term_taxonomy_id = relationships.term_taxonomy_id LEFT JOIN wp1_terms terms ON terms.term_id = taxonomy.term_id WHERE terms.name = "Restaurant" AND posts.post_type = "reference" AND posts.post_status = "publish" ORDER BY posts.post_date DESC LIMIT 0, 2;
This request returns 2 result in phpMyAdmin as execpted.
The return of get_results() is empty !!!
I already use $wpdb->get_results on other pages but with the request with only one joint.
Is it the problem ?If anybody have an idea, feel free to help.
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘The limitation or error of $wpdb’ is closed to new replies.