• I have an concert listing, and I am having a hard time getting the events to expire at the right time. I have figured out setting everything to the correct time zone in PHP, but I need to set the time zone in SQL in order to get my events to no longer be included in the results at the right time. I need to be able to pass multiple statements into a string to give to $wpdb->get_results(), but that colon on the end of the SET time_zone like does not play well with strings. When I run the statement through phpMyAdmin everything works great. Any ideas on how to put multiple statements into a string to pass to get_results? or know a better way to set the time zone in SQL?

    Thanks in advance for your help.

    $querystr = "
    	SET time_zone = '+00:00';
    	SELECT $wpdb->posts.* ,
    	(UNIX_TIMESTAMP( wp_postmeta.meta_value )) AS TIMESTAMP ,
    	wp_postmeta.meta_value AS RAWDATE
    	FROM $wpdb->postmeta, $wpdb->posts
    	WHERE $wpdb->posts.ID = $wpdb->postmeta.post_id
    	AND $wpdb->postmeta.meta_key =  'date'
    	AND (
    	UNIX_TIMESTAMP( $wpdb->postmeta.meta_value ) +68400
    	) > $unixCurTime
    	AND $wpdb->posts.post_status =  'publish'
    	AND $wpdb->posts.post_type =  'events'
    	ORDER BY $wpdb->postmeta.meta_value ASC
    ";
    $pageposts = $wpdb->get_results($querystr, OBJECT);
  • The topic ‘Multiple statements in get_results() Query String’ is closed to new replies.