Last active
August 29, 2015 14:08
-
-
Save aprea/eae346874f39bd8d450d to your computer and use it in GitHub Desktop.
SQL in PHP
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Get the table data | |
* | |
* @return Array | |
*/ | |
private function table_data() { | |
global $wpdb; | |
$sql = <<<SQL | |
SELECT wp_posts.ID, | |
m1.meta_value AS email, | |
wp_posts.post_date_gmt AS date | |
FROM wp_posts | |
INNER JOIN wp_postmeta m1 ON ( wp_posts.ID = m1.post_id ) | |
WHERE wp_posts.post_type = 'subscriber' | |
AND wp_posts.post_status = 'publish' | |
AND m1.meta_key = 'eec_email' | |
GROUP BY wp_posts.ID | |
SQL; | |
$sql = str_replace( 'wp_', $wpdb->prefix, $sql ); | |
$results = $wpdb->get_results( $sql, ARRAY_A ); | |
return $results; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment