Created
May 31, 2013 05:48
-
-
Save rictorres/5683128 to your computer and use it in GitHub Desktop.
import emails from wp comments
This file contains 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 | |
$db = new mysqli('host', 'user', 'pass', 'bd'); | |
$sql = "SELECT comment_author_email, comment_author | |
FROM `wp_comments` | |
WHERE comment_author_email <> '' | |
GROUP BY comment_author_email | |
ORDER BY ( | |
comment_author_email | |
)"; | |
$query = $db->query( $sql ); | |
while( $dados = $query->fetch_object() ){ | |
$arr[] = "\"{$dados->comment_author}\", \"{$dados->comment_author_email}\""; | |
} | |
echo implode($arr, "\n"); | |
?> |
This file contains 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
SELECT comment_author_email, comment_author | |
FROM `wp_comments` | |
WHERE comment_author_email <> '' | |
GROUP BY comment_author_email | |
ORDER BY ( | |
comment_author_email | |
INTO OUTFILE '/tmp/meuarquivo.csv' | |
FIELDS TERMINATED BY ';' | |
LINES TERMINATED BY '\n'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment