TokyoTyrantQuery::search

(PECL tokyo_tyrant >= 0.1.0)

TokyoTyrantQuery::searchCherche des enregistrements

Description

public array TokyoTyrantQuery::search ( void )

Effectue une recherche sur la base de données. Retourne un tableau de tableaux, contenant les enregistrements correspondant. Dans le tableau retourné, le premier niveau correspond aux clés primaires des données, et le second, les données des lignes.

Liste de paramètres

Cette fonction ne contient aucun paramètre.

Valeurs de retour

Retourne les lignes correspondantes et lance une exception TokyoTyrantException si une erreur survient.

Exemples

Exemple #1 Exemple avec TokyoTyrantQuery::search()

<?php
/* Connexion à la base de données */
$tt = new TokyoTyrantTable("localhost", 1979);

/* Ajoute 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"
  }
}

Voir aussi

LoadingChargement en cours