Issue with database insert comparing dual meta_keys
-
Not sure if its the right area, but I’m stumped with what I have wrong in this wpdb query.
I have this:
$testresults = $wpdb->get_results(
“SELECT user_id
FROM {$wpdb->base_prefix}usermeta
WHERE (((meta_key = ‘skill_role_name’
AND meta_value LIKE ‘%%%$search_terms%%’)
OR (meta_key = ‘description’
AND meta_value LIKE ‘%%%$search_terms%%’))
AND
(meta_key = ‘zip’
AND meta_value IN (” . implode(‘,’, array_map(‘intval’, $zips_array)) . “)” . “))
“);
I’ve echo’d this out as a test, and ran it in the database through MySQL, but it doesn’t seem to like it. This is meant to grab where (‘skill_role_name’ OR ‘description’ = $search_terms) AND (‘zip’ = in($array)).
What I get when I echo it out is this:
SELECT user_id FROM wp_usermeta WHERE (((meta_key = ‘skill_role_name’ AND meta_value LIKE ‘%%%director%%’) OR (meta_key = ‘description’ AND meta_value LIKE ‘%%%director%%’)) AND (meta_key = ‘zip’ AND meta_value IN (90026,90057,90081,90084,90086,90051,90087,90088,90012,90017,90071,90030,90074,90099,90029,90039)))
Any ideas?
- The topic ‘Issue with database insert comparing dual meta_keys’ is closed to new replies.