\"$wpdb->prepare\" and LIKE \'%….%\'
-
Hi, I have a problem with a query in my component.
a part of my code for the query :
if ($more_sql)
$query_where = $usermeta_sql.’WHERE ‘.implode(‘ AND ‘,$more_sql);
$sql = $wpdb->prepare(
“SELECT DISTINCT {$fields_to_get}
FROM {$bp->classifieds->table_name} c
INNER JOIN {$bp->classifieds->table_name_classifiedmeta} cm ON cm.classified_id = c.id
{$query_where}
{$group_by}
{$sort_by}
{$order}
{$pag_sql}
“
);
The $more_sql is an array that contains the statements for the query.
For example;
if ($user_id) {
$more_sql[‘creator_id’] = $wpdb->prepare(“c.creator_id = %d”,$user_id);
}
The problem is that for one of the statements, it doesn’t work. Seems it because of the % chars.
How can I fix this ?
if ($group)
$more_sql[‘group’] = $wpdb->prepare(“cm.meta_key = ‘groups’ AND cm.meta_value LIKE ‘%s'”,’%”‘.$group.'”%’);
Thanks guys !
- The topic ‘\"$wpdb->prepare\" and LIKE \'%….%\'’ is closed to new replies.