Swish->query
(PECL swish:0.1-0.3.0)
Swish->query — Execute a query and return results object
說明
object Swish->query
( string $query
)
Warning
本函式是實驗性的。這個函式的行為、名稱、和關於此函式的任何其他文件在未來PHP的發行中可能會在不通知的情況下改變。 使用此函式需自行承擔風險。
A quick method to execute a search with default parameters.
參數
- query
-
Query string.
Return值
Returns SwishResults object.
錯誤/例外
Throws SwishException on error.
範例
Example#1 Basic Swish->query() example
<?php
try {
$swish = new Swish("index.swish-e");
$results = $swish->query("test query");
echo "Found: ", $results->hits, " hits\n";
} catch (SwishException $e) {
echo $e->getMessage(), "\n";
}
?>
上例的輸出類似於:
Found: 1 hits