In this search when the array returns 4
as shown in the SQL below, I need the system to return all results whose number of rooms and >= 4
. You can help me get this result.
I converted the column to INT
. It was ugly the thing in DB
, I did not do it, it was ready.
# Selecionando conforme quantidade de dormitorios
$dormi = $_POST['dorm'];
if (isset($_POST['dorm']) && is_array($_POST['dorm']) && count($_POST['dorm']) > 0){
$where .= " DORMITORIO IN (". implode(', ', $dormi).") AND ";
if (in_array(4, $_POST['dorm'])){
$where .= trim($where,' AND ').' OR DORMITORIO >= 4 AND ';
}
}
This is the SQL resutaldo of this search:
SELECT * FROM property WHERE 1 = 1 AND BEDROOM IN (1, 2, 3, 4)