TokyoTyrantQuery::metaSearch
(No version information available, might only be in Git)
TokyoTyrantQuery::metaSearch — Retrieve records with multiple queries
Description
public array TokyoTyrantQuery::metaSearch
( array
$queries
, int $type
)Executes multiple queries on a database and returns matching records. The current object is always the left most object in the search.
Parameters
-
queries
-
Array of TokyoTyrantQuery objects
-
type
-
One of the
TokyoTyrant::RDBMS_*
constants
Return Values
Returns the matching rows and throws TokyoTyrantException on error
Examples
Example #1 TokyoTyrantQuery::metaSearch() example
<?php
/* Connect to a table database */
$tt = new TokyoTyrantTable("localhost", 1979);
/* Add test data */
$tt->put('cherry', array('color' => 'red'));
$tt->put('strawberry', array('color' => 'red'));
$tt->put('apple', array('color' => 'green'));
$tt->put('lemon', array('color' => 'yellow'));
/* First query */
$query = $tt->getQuery();
$query->addCond('color', TokyoTyrant::RDBQC_STREQ, 'red')->setOrder('color', TokyoTyrant::RDBQO_STRASC);
/* Second query */
$query1 = $tt->getQuery();
$query1->addCond('color', TokyoTyrant::RDBQC_STREQ, 'yellow');
/* Get union between the queries */
var_dump($query->metaSearch(array($query1), TokyoTyrant::RDBMS_UNION));
?>
The above example will output:
array(3) { ["cherry"]=> array(1) { ["color"]=> string(3) "red" } ["strawberry"]=> array(1) { ["color"]=> string(3) "red" } ["lemon"]=> array(1) { ["color"]=> string(6) "yellow" } }
- PHP Руководство
- Функции по категориям
- Индекс функций
- Справочник функций
- Расширения для работы с базами данных
- Расширения для работы с базами данных отдельных производителей
- tokyo_tyrant
- Функция TokyoTyrantQuery::addCond() - Adds a condition to the query
- Функция TokyoTyrantQuery::__construct() - Construct a new query
- Функция TokyoTyrantQuery::count() - Counts records
- Функция TokyoTyrantQuery::current() - Returns the current element
- Функция TokyoTyrantQuery::hint() - Get the hint string of the query
- Функция TokyoTyrantQuery::key() - Returns the current key
- Функция TokyoTyrantQuery::metaSearch() - Retrieve records with multiple queries
- Функция TokyoTyrantQuery::next() - Moves the iterator to next entry
- Функция TokyoTyrantQuery::out() - Removes records based on query
- Функция TokyoTyrantQuery::rewind() - Rewinds the iterator
- Функция TokyoTyrantQuery::search() - Searches records
- Функция TokyoTyrantQuery::setLimit() - Limit results
- Функция TokyoTyrantQuery::setOrder() - Orders results
- Функция TokyoTyrantQuery::valid() - Checks the validity of current item
Коментарии
404 Not Found