(PECL tokyo_tyrant >= 0.1.0)
TokyoTyrantQuery::addCond — Ajoute une condition à la requête
Ajoute une condition à la requête. La condition peut être quelques choses comme : récupérer toutes les clés dont la valeur correspond à une expression.
nameNom de la colonne dans la condition
op
L'opérateur. Une constante parmi les constantes
TokyoTyrant::RDBQC_*.
exprL'expression.
La méthode retourne l'objet courant et lance une exception TokyoTyrantException si une erreur survient.
Exemple #1 Exemple avec TokyoTyrantQuery::addCond()
<?php
/* Connexion à une base de données de table */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Ajout de quelques lignes */
$tt->put(null, array("column1" => "some data", "column2" => "something here"));
$tt->put(null, array("column1" => "more data", "column2" => "best data this far"));
$tt->put(null, array("column1" => "again data", "column3" => "not here"));
$tt->put(null, array("column45" => "random data", "column2" => "something along the lines"));
$tt->put(null, array("column21" => "test data", "column2" => "generating.."));
$tt->put(null, array("column1" => "foobar data", "column2" => "value here"));
/* Récupère un nouvel objet de requête */
$query = $tt->getQuery();
/* Ajoute une condition de recherche */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Affiche les résultats de la recherche */
var_dump($query->search());
?>
L'exemple ci-dessus va afficher :
array(2) {
[1]=>
array(2) {
["column1"]=>
string(9) "some data"
["column2"]=>
string(14) "something here"
}
[4]=>
array(2) {
["column45"]=>
string(11) "random data"
["column2"]=>
string(25) "something along the lines"
}
}