Monday, April 16, 2012

MYSQL Query suddenly no longer works

I have the following MySQL that fecthes data from several tables:



SELECT * FROM $wpdb->posts
LEFT JOIN userContests ON ($wpdb->posts.ID = taxi.taxiID)
LEFT JOIN $wpdb->term_relationships ON ($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON ($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
WHERE $wpdb->posts.post_status = 'publish'
AND $wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_date < NOW()+INTERVAL 1 DAY
AND $wpdb->term_taxonomy.taxonomy = 'category'
AND $wpdb->term_taxonomy.term_id IN(3)
AND ($wpdb->postmeta.meta_key = 'EndDate' AND $wpdb->postmeta.meta_value > DATE_ADD(NOW(), INTERVAL 3 HOUR))


As of yesterday, the query is NOT returning any results but here's the kicker: PHP MyAdmin does still return the proper results!



After a lot of trial and error, I've narrowed the problem down to this one line:



AND ($wpdb->postmeta.meta_key = 'EndDate' AND $wpdb->postmeta.meta_value > DATE_ADD(NOW(), INTERVAL 3 HOUR))


The line does function on my server but when it comes to running on the site itself, no results get displayed. Something is suddenly not working, does anyone have any ideas why? Again, the query has been working for two weeks but suddenly as of yesterday, it won't return results on the site, but does return results on my server!





No comments:

Post a Comment