source: sandbox/expresso-solr/expressoMail1_2/inc/solrclient/examples/1.2-basic-select.php @ 7576

Revision 7576, 842 bytes checked in by adir, 11 years ago (diff)

Ticket #000 - Adicionando a integracao de buscas com Solr na base a ser isnerida na comunidade

Line 
1<?php
2
3require('init.php');
4htmlHeader();
5
6// create a client instance
7$client = new Solarium_Client($config);
8
9// get a select query instance
10$query = $client->createSelect();
11
12// this executes the query and returns the result
13$resultset = $client->select($query);
14
15// display the total number of documents found by solr
16echo 'NumFound: '.$resultset->getNumFound();
17
18// show documents using the resultset iterator
19foreach ($resultset as $document) {
20
21    echo '<hr/><table>';
22
23    // the documents are also iterable, to get all fields
24    foreach($document AS $field => $value)
25    {
26        // this converts multivalue fields to a comma-separated string
27        if(is_array($value)) $value = implode(', ', $value);
28       
29        echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
30    }
31
32    echo '</table>';
33}
34
35htmlFooter();
Note: See TracBrowser for help on using the repository browser.