Skip to:
Content
Pages
Categories
Search
Top
Bottom

Re: \\\”$wpdb->prepare\\\” and LIKE \\\'%….%\\\'


grosbouff
Participant

@grosbouff

(I need the quotes around $group, so :)

$more_sql[‘group’] = $wpdb->prepare(“cm.meta_key = ‘groups’ AND cm.meta_value LIKE ‘%%”$group”%%'”);

print_r($more_sql[‘group’]);

returns

cm.meta_key = ‘groups’ AND cm.meta_value LIKE ‘%”8″%

as it should (thanks !)

then

print_r(“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}

“);

works but not with prepare :

print_r($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}

“));

which returns nothing… :( :( :(

help! :)

Skip to toolbar