PHP Velho Oeste 2024

Swish::prepare

(PECL swish >= 0.1.0)

Swish::preparePrepare a search query

Descrição

Swish::prepare ([ string $query ] ) : object
Aviso

Esta função é EXPERIMENTAL. O comportamento, seu nome e documentação podem mudar sem aviso em futuras versões do PHP. Utilize por sua própria conta e risco.

Prepare and return a search object, which you can later use for unlimited number of queries.

Parâmetros

query

Optional query string. The query can be also set using SwishSearch::execute() method.

Valor Retornado

Returns SwishSearch object.

Erros

Throws SwishException on error.

Exemplos

Exemplo #1 Basic Swish::prepare() example

<?php

try {

    
$swish = new Swish("index.swish-e");
    
$search $swish->prepare("search query");
    
$results $search->execute();
    echo 
"Found: "$results->hits" hits\n";

    
$results $search->execute("new search");

    echo 
"Found: "$results->hits" hits\n";
} catch (
SwishException $e) {
    echo 
$e->getMessage(), "\n";
}

?>

O exemplo acima irá imprimir algo similar à:

Found: 2 hits
Found: 5 hits

add a note add a note

User Contributed Notes

There are no user contributed notes for this page.
To Top