PHP Doku:: Retrieve records with multiple queries - tokyotyrantquery.metasearch.html

Verlauf / Chronik / History: (1) anzeigen

Sie sind hier:
Doku-Startseite ≥ PHP-Handbuch ≥ Funktionsreferenz ≥ Datenbankerweiterungen ≥ Anbieterspezifische Datenbankerweiterungen ≥ tokyo_tyrant ≥ The TokyoTyrantQuery class ≥ TokyoTyrantQuery::metaSearch

Ein Service von Reinhard Neidl - Webprogrammierung.

The TokyoTyrantQuery class

<<TokyoTyrantQuery::key

TokyoTyrantQuery::next>>

TokyoTyrantQuery::metaSearch

(No version information available, might only be in SVN)

TokyoTyrantQuery::metaSearch — Retrieve records with multiple queries

Beschreibung

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.

Parameter-Liste

queries

Array of TokyoTyrantQuery objects

type

One of the TokyoTyrant::RDBMS_* constants

Rückgabewerte

Returns the matching rows and throws TokyoTyrantException on error

Beispiele

Beispiel #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));
?>

Das oben gezeigte Beispiel erzeugt folgende Ausgabe:

array(3) {
  ["cherry"]=>
  array(1) {
    ["color"]=>
    string(3) "red"
  }
  ["strawberry"]=>
  array(1) {
    ["color"]=>
    string(3) "red"
  }
  ["lemon"]=>
  array(1) {
    ["color"]=>
    string(6) "yellow"
  }
}

Siehe auch


Keine BenutzerBeiträge.
- Beiträge aktualisieren...



PHP Powered Diese Seite bei php.net
The PHP manual text and comments are covered by the Creative Commons Attribution 3.0 License © the PHP Documentation Group - Impressum - mail("TO:Reinhard Neidl",...)