void $DB_DataObject->whereAdd (
string $where
,
string $logic
)
Ajoute des éléments à la partie de l'instruction WHERE d'une requête SQL. L'appel à cette méthode sans aucun argument efface l'instruction WHERE. Le comportement ar défaut est d'ajouter 'AND' aux conditions existantes, utilisez le paramètre $logic pour ajouter des conditions 'OR'.
string $cond - condition à ajouter, ou vide pour effacer les conditions existantes
string $logic - logique, optionnel "OR" (par défaut, vaut "AND")
This function can not be called statically.
Exemple avec whereAdd()
<?php
$person = new DataObjects_Person;
$person->whereAdd('age > 12');
$person->whereAdd('age < 30');
$person->find();
while ($person->fetch()) {
echo "$person->id} {$person->name}<br />";
}
$person = new DataObjects_Person;
$person->whereAdd('age < 12');
$person->whereAdd('age > 30', 'OR');
$person->find();
while ($person->fetch()) {
echo "{$person->id} {$person->name}<br />";
}
?>
SQL résultant