i have this:
$villes = '"paris","fes","rabat"';
$sql = 'SELECT distinct telecopie FROM `comptage_fax` WHERE `ville` IN(%s)';
$query = $wpdb->prepare($sql, $villes);
when I do an echo $query;
i get:
SELECT distinct telecopie FROM `comptage_fax` WHERE `ville` IN('\"CHAPELLE VIVIERS \",\"LE MANS \",\"QUEND\"')
the probleme i have is that $wpdb
add '
in IN('...')
can someone help, thanks
Try this code (FIXED):
implode()
array_fill()
call_user_func_array()
array_merge()
WordPress already has a function for this purpose, see esc_sql(). Here is the definition of this function:
You can use it like this:
FUNCTION:
USAGE:
RESULT:
May or may not be more efficient, however it is reusable.
The
prepare
function also takes anarray
as the second parameter.You can try converting
$villes
like this:Current
Change it to
Now, try passing
$villes
to the prepare func and see if it works. Hope it helps.