Préparer des requêtes avec un nombre inconnu de variables
Bonjour,
j'exécute des séries de requêtes comme suit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
|
$sth = $cnx->prepare("SELECT id, titre
FROM $table
WHERE
xxx LIKE ?
AND
yyy = ?
");
$sth->bindParam(1, $variable_1);
$sth->bindParam(2, $variable_2);
$variable_1= '%toto%';
$variable_2= '%papa%';
$sth->execute();
$infos_a = $sth->fetchAll (); |
Par la suite, il est simple de passer
Code:
1 2 3 4
| $variable_1= '%tata%';
$variable_2= '%maman%';
$sth->execute();
$infos_b = $sth->fetchAll (); |
MAIS
comment faire pour passer une commande avec un LIKE = 'tutu' OR LIKE = 'titi', vu que ma requête SELECT est formatée pour ne recueillir qu'1 seule variable ?