Created
October 28, 2013 19:15
-
-
Save borkweb/7202819 to your computer and use it in GitHub Desktop.
SQL Formatting in PHP
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
$sql = " | |
SELECT | |
p.ID AS id, | |
p.post_title AS name | |
FROM | |
$wpdb->posts p | |
LEFT JOIN $wpdb->postmeta pm ON | |
p.ID = pm.post_id | |
AND pm.meta_key = %s | |
WHERE | |
p.post_type = %s | |
AND p.post_status = %s | |
AND pm.meta_value IS NULL | |
ORDER BY | |
p.ID DESC | |
LIMIT %d | |
"; | |
// and | |
$sql = " | |
SELECT p.ID AS id, | |
p.post_title AS name | |
FROM $wpdb->posts p | |
LEFT JOIN $wpdb->postmeta pm | |
ON p.ID = pm.post_id | |
AND pm.meta_key = %s | |
WHERE p.post_type = %s | |
AND p.post_status = %s | |
AND pm.meta_value IS NULL | |
ORDER BY p.ID DESC | |
LIMIT %d | |
"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment