I have this code:
if(isset($params['bedrooms']) && is_numeric($params['bedrooms']) && $params['bedrooms'] > 0){
$what['bedrooms >= ?'] = $params['bedrooms'];
$what_or['suites >= ?'] = $params['bedrooms'];
}
$where = implode(' AND ',array_keys($what));
$conditions = array_values($what);
if (!empty($what_or)) {
$where .= ' OR ' . implode(' OR ', array_keys($what_or));
$conditions = array_merge($conditions, array_values($what_or));
}
pr($where);
die();
What will result in:
modality_id = ? AND property_type_id = ? AND properties.city_id = ? AND status = ? AND bedrooms >= ? OR suites >= ?
But I need to return this with bedrooms >= ? OR suites >= ?
in parentheses, how can I do this?
Ps: without using str_replace () .