I have this query:
$conditions = array(
'editore LIKE' => "%$e%",
'titolo LIKE' => "%$t%"
);
if (isset($autore_diviso))
$conditions[] = array('autori LIKE ? AND ?' => array("%$autore1%","%$autore2%"));
else
$conditions[]=array('autori LIKE' => "%$a%");
if (!$anno&&!$anno2) // I HAVE TO CHANGE THIS - if the user does not insert any year
$conditions=$conditions;
else {
if (!$anno)
$conditions[] = array('anno <=' => "$anno2");
if (!$anno2)
$conditions[] = array('anno >=' => "$anno");
}
if ($anno&&$anno2)
$conditions[] = array('anno BETWEEN ? AND ?' => array($anno,$anno2));
Where anno mean year, editore means publisher and titolo means title.
It’s not working the search for exactly 2 authors.
If I debug $conditions, I have for example:
Array (
[editore LIKE] => %%
[titolo LIKE] => %%
[0] => Array
(
[autori LIKE ? AND ?] => Array
(
[0] => %massi%
[1] => %palu%
)
) )
But the result is empty.
That’s not how you add elements to arrays in PHP. Also, there’s no need to use explicit
AND, that’s the default. It’s needed only if there would otherwise be multiple identical array keys.