1
The doubt is the following, in mysql we can concatenate a query and then perform the search, as follows:
$cidades = '&& (cidade = 100 || cidade = 101 || cidade = 102)';
$order = 'id ASC';
$sql = 'SELECT * FROM tabela WHERE status = 1 '.$cidades.' ORDER BY '.$order;
the variable $cidade
can be empty or have n elements for search, I can not do so, I do not know also if it would be that way:
$sql = $this->_db->prepare('SELECT * FROM tabela WHERE status = 1 :cidades ORDER BY :order');
$sql->execute(array(':cidades' => $cidades, ':order' => $order));
$cidades
is an array or a string?– rray
$cidades
is a string– CleristonDantas