PHP - Manual: TokyoTyrantQuery::addCond
2024-12-23
(PECL tokyo_tyrant >= 0.1.0)
TokyoTyrantQuery::addCond — Adds a condition to the query
Adds a condition to the query. Condition can be something like: get all keys which value matches expr.
name
Name of the column in the condition
op
The operator. One of the TokyoTyrant::RDBQC_*
constants
expr
The expression
This method returns the current object and throws TokyoTyrantException on failure.
Example #1 TokyoTyrantQuery::addCond() example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add rows */
$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"));
/* Get a new query object */
$query = $tt->getQuery();
/* Add a search condition */
$query->addCond("column2", TokyoTyrant::RDBQC_STROR, "something");
/* Dump the search results */
var_dump($query->search());
?>
以上例程会输出:
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" } }
官方地址:https://www.php.net/manual/en/tokyotyrantquery.addcond.php