$value = array('one', 'two', 'three');
I have that part of query:
$features_filter .= $this->db->placehold('AND p.id in (SELECT product_id FROM __options WHERE feature_id=? AND value in (?@) ) ', $feature, $value);
That query returns result only if database contains values == 'one' or 'two' or 'three'. How I can change my query to do that query returned some LIKE 'one' or 'two' or 'three'?
PS Sorry for my bad English
Here's a quick and dirty solution:
$value = array('one', 'two', 'three');
for ($i = 0; $i < sizeof($value); $i++ ):
$new .= " LIKE '%$value[$i]%'";
if ( $i < sizeof($value) -1 ) :
$new .= " OR";
endif;
endfor;
$features_filter .= $this->db->placehold('AND p.id in (SELECT product_id FROM __options WHERE feature_id=? AND value ' . $new ) ', $feature );
Addition: On PHP >= 5.3 the for
-loop could also be replaced with this code:
array_walk( $value, function (&$value, $key) {
$value = " LIKE %$value%";
});
$new = implode(' OR', $value );