Last active
August 29, 2015 14:28
-
-
Save khoand0000/b9c348db1afdfaa2295a to your computer and use it in GitHub Desktop.
Use $wpdb->prepare with parameter is array
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
// ref: http://wordpress.stackexchange.com/questions/110982/how-to-modify-this-wpdb-query-to-accept-an-array-of-post-statuses | |
// escape the values | |
// $filter is array of string | |
$filter = array_map( 'esc_sql', (array) $filter ); | |
$filter = "'" . implode( "','", $filter ) . "'"; | |
$rows = $wpdb->get_results( | |
$wpdb->prepare( | |
"SELECT * FROM language_table | |
WHERE language_code=%s AND id IN (" . $filter . ") ORDER BY id", | |
$language_code | |
) | |
); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment