略微加速

PHP官方手册 - 互联网笔记

PHP - Manual: TokyoTyrantQuery::metaSearch

2024-12-23

TokyoTyrantQuery::metaSearch

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

TokyoTyrantQuery::metaSearchRetrieve records with multiple queries

说明

public TokyoTyrantQuery::metaSearch ( array $queries , int $type ) : array

Executes multiple queries on a database and returns matching records. The current object is always the left most object in the search.

参数

queries

Array of TokyoTyrantQuery objects

type

One of the TokyoTyrant::RDBMS_* constants

返回值

Returns the matching rows and throws TokyoTyrantException on error

范例

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

以上例程会输出:

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

参见

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.

官方地址:https://www.php.net/manual/en/tokyotyrantquery.metasearch.php

北京半月雨文化科技有限公司.版权所有 京ICP备12026184号-3