ā%1sā placeholder in $wpdb->prepare()
-
I have an array variable in my PHP code.
$id_arr = fn_get_id_array(); // Returns Array, i.e. [23,24,25]
I need to use this value in my query, like this:
... WHERE ID IN(23,24,25)
If I prepare it using ā%sā, this is not working:
... WHERE ID IN('23,24,25')
So, I use this:
$wpdb->query( $wpdb->prepare( "SELECT ... WHERE ID IN(%1s) ", implode(',',$id_arr) ) );
PCP says:
WARNING WordPress.DB.PreparedSQLPlaceholders.UnquotedComplexPlaceholder Complex placeholders used for values in the query string in $wpdb->prepare() will NOT be quoted automagically. Found: %1s.
Should another method be used to prepare the query? I’m waiting for your advice.
Viewing 2 replies - 1 through 2 (of 2 total)
Viewing 2 replies - 1 through 2 (of 2 total)
- You must be logged in to reply to this topic.