Commit 4e71fc88 authored by Bas de Nooijer's avatar Bas de Nooijer

Updated examples for namespacing

parent cd4dc257
...@@ -7,7 +7,7 @@ htmlHeader(); ...@@ -7,7 +7,7 @@ htmlHeader();
echo 'Solarium library version: ' . Solarium\Version::VERSION . ' - '; echo 'Solarium library version: ' . Solarium\Version::VERSION . ' - ';
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// create a ping query // create a ping query
$ping = $client->createPing(); $ping = $client->createPing();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -25,7 +25,7 @@ foreach ($resultset as $document) { ...@@ -25,7 +25,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -7,7 +7,7 @@ if ($_POST) { ...@@ -7,7 +7,7 @@ if ($_POST) {
// if data is posted add it to solr // if data is posted add it to solr
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
...@@ -18,7 +18,7 @@ if ($_POST) { ...@@ -18,7 +18,7 @@ if ($_POST) {
$doc->id = $_POST['id']; $doc->id = $_POST['id'];
$doc->name = $_POST['name']; $doc->name = $_POST['name'];
$doc->price = $_POST['price']; $doc->price = $_POST['price'];
// add the document and a commit command to the update query // add the document and a commit command to the update query
$update->addDocument($doc); $update->addDocument($doc);
$update->addCommit(); $update->addCommit();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -19,7 +19,7 @@ $query->setStart(2)->setRows(20); ...@@ -19,7 +19,7 @@ $query->setStart(2)->setRows(20);
$query->setFields(array('id','name','price')); $query->setFields(array('id','name','price'));
// sort the results by price ascending // sort the results by price ascending
$query->addSort('price', Solarium\Query\Select::SORT_ASC); $query->addSort('price', Solarium\Query\Select\Select::SORT_ASC);
// this executes the query and returns the result // this executes the query and returns the result
$resultset = $client->select($query); $resultset = $client->select($query);
...@@ -37,7 +37,7 @@ foreach ($resultset as $document) { ...@@ -37,7 +37,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -16,7 +16,7 @@ class myDoc extends Solarium\Document\ReadOnly{ ...@@ -16,7 +16,7 @@ class myDoc extends Solarium\Document\ReadOnly{
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -33,7 +33,7 @@ foreach ($resultset as $document) { ...@@ -33,7 +33,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -32,7 +32,7 @@ foreach ($resultset as $document) { ...@@ -32,7 +32,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -32,7 +32,7 @@ foreach ($resultset as $document) { ...@@ -32,7 +32,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -34,7 +34,7 @@ foreach ($resultset as $document) { ...@@ -34,7 +34,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -33,7 +33,7 @@ foreach($groups AS $groupKey => $fieldGroup) { ...@@ -33,7 +33,7 @@ foreach($groups AS $groupKey => $fieldGroup) {
echo '<h2>'.(int)$valueGroup->getValue().'</h2>'; echo '<h2>'.(int)$valueGroup->getValue().'</h2>';
foreach($valueGroup AS $document) { foreach($valueGroup AS $document) {
echo '<hr/><table>'; echo '<hr/><table>';
// the documents are also iterable, to get all fields // the documents are also iterable, to get all fields
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance and a query helper instance // get a select query instance and a query helper instance
$query = $client->createSelect(); $query = $client->createSelect();
......
...@@ -4,11 +4,11 @@ require('init.php'); ...@@ -4,11 +4,11 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// first create a base query as a query class // first create a base query as a query class
class PriceQuery extends Solarium\Query\Select class PriceQuery extends Solarium\Query\Select\Select
{ {
protected function _init() protected function _init()
{ {
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an update query instance // get an update query instance
$update = $client->createUpdate(); $update = $client->createUpdate();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a morelikethis query instance // get a morelikethis query instance
$query = $client->createMoreLikeThis(); $query = $client->createMoreLikeThis();
...@@ -44,7 +44,7 @@ foreach ($resultset as $document) { ...@@ -44,7 +44,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a morelikethis query instance // get a morelikethis query instance
$query = $client->createMoreLikeThis(); $query = $client->createMoreLikeThis();
...@@ -45,7 +45,7 @@ foreach ($resultset as $document) { ...@@ -45,7 +45,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an analysis document query // get an analysis document query
$query = $client->createAnalysisDocument(); $query = $client->createAnalysisDocument();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get an analysis document query // get an analysis document query
$query = $client->createAnalysisField(); $query = $client->createAnalysisField();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a terms query instance // get a terms query instance
$query = $client->createTerms(); $query = $client->createTerms();
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -13,7 +13,7 @@ $query = $client->createSelect(); ...@@ -13,7 +13,7 @@ $query = $client->createSelect();
$query->setQuery('*:*'); $query->setQuery('*:*');
$query->setStart(2)->setRows(20); $query->setStart(2)->setRows(20);
$query->setFields(array('id','name','price')); $query->setFields(array('id','name','price'));
$query->addSort('price', Solarium\Query\Select::SORT_ASC); $query->addSort('price', Solarium\Query\Select\Select::SORT_ASC);
// create a filterquery using the API // create a filterquery using the API
$fq = $query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]'); $fq = $query->createFilterQuery('maxprice')->setQuery('price:[1 TO 300]');
......
...@@ -29,7 +29,7 @@ $select = array( ...@@ -29,7 +29,7 @@ $select = array(
); );
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance based on the config // get a select query instance based on the config
$query = $client->createSelect($select); $query = $client->createSelect($select);
......
...@@ -39,7 +39,7 @@ class ProductPriceLimitedQuery extends ProductQuery{ ...@@ -39,7 +39,7 @@ class ProductPriceLimitedQuery extends ProductQuery{
} }
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// create a query instance // create a query instance
$query = new ProductPriceLimitedQuery; $query = new ProductPriceLimitedQuery;
......
...@@ -10,7 +10,7 @@ htmlHeader(); ...@@ -10,7 +10,7 @@ htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// create a select query instance // create a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -41,7 +41,7 @@ foreach ($result as $document) { ...@@ -41,7 +41,7 @@ foreach ($result as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// This is a custom query class that could have some customized logic // This is a custom query class that could have some customized logic
class MyQuery extends Solarium\Query\Select class MyQuery extends Solarium\Query\Select\Select
{ {
// ...customization here... // ...customization here...
} }
...@@ -12,7 +12,7 @@ class MyQuery extends Solarium\Query\Select ...@@ -12,7 +12,7 @@ class MyQuery extends Solarium\Query\Select
// And this is the extended client, that modifies the default query mapping // And this is the extended client, that modifies the default query mapping
// for select queries to our custom query class. // for select queries to our custom query class.
// BTW, the same could also be done using a plugin, see example 5.3.2 // BTW, the same could also be done using a plugin, see example 5.3.2
class MyClient extends Solarium\Client class MyClient extends Solarium\Client\Client
{ {
/** /**
* Querytype mappings * Querytype mappings
...@@ -20,8 +20,8 @@ class MyClient extends Solarium\Client ...@@ -20,8 +20,8 @@ class MyClient extends Solarium\Client
protected $_queryTypes = array( protected $_queryTypes = array(
self::QUERYTYPE_SELECT => array( self::QUERYTYPE_SELECT => array(
'query' => 'MyQuery', 'query' => 'MyQuery',
'requestbuilder' => 'Solarium\Client\RequestBuilder\Select', 'requestbuilder' => 'Solarium\Client\RequestBuilder\Select\Select',
'responseparser' => 'Solarium\Client\ResponseParser\Select' 'responseparser' => 'Solarium\Client\ResponseParser\Select\Select'
), ),
self::QUERYTYPE_UPDATE => array( self::QUERYTYPE_UPDATE => array(
'query' => 'Solarium\Query\Update', 'query' => 'Solarium\Query\Update',
...@@ -62,7 +62,7 @@ foreach ($result as $document) { ...@@ -62,7 +62,7 @@ foreach ($result as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -3,7 +3,7 @@ require('init.php'); ...@@ -3,7 +3,7 @@ require('init.php');
// this very simple plugin shows a timing for each event and display some request debug info // this very simple plugin shows a timing for each event and display some request debug info
class basicDebug extends Solarium\PluginAbstractPlugin class basicDebug extends Solarium\Plugin\AbstractPlugin
{ {
protected $_start; protected $_start;
...@@ -90,7 +90,7 @@ htmlHeader(); ...@@ -90,7 +90,7 @@ htmlHeader();
// create a client instance and register the plugin // create a client instance and register the plugin
$plugin = new basicDebug(); $plugin = new basicDebug();
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
$client->registerPlugin('debugger', $plugin); $client->registerPlugin('debugger', $plugin);
// execute a select query and display the results // execute a select query and display the results
......
...@@ -2,32 +2,32 @@ ...@@ -2,32 +2,32 @@
require('init.php'); require('init.php');
// This is a custom query class that could have some customized logic // This is a custom query class that could have some customized logic
class MyQuery extends Solarium\Query\Select class MyQuery extends Solarium\Query\Select\Select
{ {
// ...customization here... // ...customization here...
} }
// this very simple plugin that modifies the default querytype mapping // this very simple plugin that modifies the default querytype mapping
class queryCustomizer extends Solarium\PluginAbstractPlugin class queryCustomizer extends Solarium\Plugin\AbstractPlugin
{ {
protected function _initPlugin() protected function _initPlugin()
{ {
$this->_client->registerQueryType( $this->_client->registerQueryType(
Solarium\Client::QUERYTYPE_SELECT, Solarium\Client\Client::QUERYTYPE_SELECT,
'MyQuery', 'MyQuery',
'Solarium\Client\RequestBuilder\Select', 'Solarium\Client\RequestBuilder\Select\Select',
'Solarium\Client\ResponseParser\Select' 'Solarium\Client\ResponseParser\Select\Select'
); );
} }
} }
htmlHeader(); htmlHeader();
// create a client instance and register the plugin // create a client instance and register the plugin
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
$client->registerPlugin('querycustomizer', 'queryCustomizer'); $client->registerPlugin('querycustomizer', 'queryCustomizer');
// create a select query instance // create a select query instance
......
...@@ -7,7 +7,7 @@ require('init.php'); ...@@ -7,7 +7,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// set the adapter to zendhttp and get a zendhttp client instance reference // set the adapter to zendhttp and get a zendhttp client instance reference
$client->setAdapter('Solarium\Client\Adapter\ZendHttp'); $client->setAdapter('Solarium\Client\Adapter\ZendHttp');
...@@ -35,7 +35,7 @@ foreach ($resultset as $document) { ...@@ -35,7 +35,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -7,7 +7,7 @@ require('init.php'); ...@@ -7,7 +7,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// set the adapter to peclhttp // set the adapter to peclhttp
$client->setAdapter('Solarium\Client\Adapter\PeclHttp'); $client->setAdapter('Solarium\Client\Adapter\PeclHttp');
...@@ -31,7 +31,7 @@ foreach ($resultset as $document) { ...@@ -31,7 +31,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -7,7 +7,7 @@ require('init.php'); ...@@ -7,7 +7,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// set the adapter to curl // set the adapter to curl
$client->setAdapter('Solarium\Client\Adapter\Curl'); $client->setAdapter('Solarium\Client\Adapter\Curl');
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -33,7 +33,7 @@ foreach ($resultset as $document) { ...@@ -33,7 +33,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance // create a client instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
// get a select query instance // get a select query instance
$query = $client->createSelect(); $query = $client->createSelect();
...@@ -35,7 +35,7 @@ foreach ($resultset as $document) { ...@@ -35,7 +35,7 @@ foreach ($resultset as $document) {
{ {
// this converts multivalue fields to a comma-separated string // this converts multivalue fields to a comma-separated string
if(is_array($value)) $value = implode(', ', $value); if(is_array($value)) $value = implode(', ', $value);
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>'; echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
} }
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance and get loadbalancer plugin instance // create a client instance and get loadbalancer plugin instance
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
$loadbalancer = $client->getPlugin('loadbalancer'); $loadbalancer = $client->getPlugin('loadbalancer');
// apply loadbalancer settings // apply loadbalancer settings
...@@ -39,7 +39,7 @@ echo 'Loadbalanced ping query, should display a loadbalancing server:<br/>'; ...@@ -39,7 +39,7 @@ echo 'Loadbalanced ping query, should display a loadbalancing server:<br/>';
echo 'Ping server: ' . $loadbalancer->getLastServerKey() .'<hr/>'; echo 'Ping server: ' . $loadbalancer->getLastServerKey() .'<hr/>';
// exclude ping query from loadbalancing // exclude ping query from loadbalancing
$loadbalancer->addBlockedQueryType(Solarium\Client::QUERYTYPE_PING); $loadbalancer->addBlockedQueryType(Solarium\Client\Client::QUERYTYPE_PING);
$client->ping($query); $client->ping($query);
echo 'Non-loadbalanced ping query, should not display a loadbalancing server:<br/>'; echo 'Non-loadbalanced ping query, should not display a loadbalancing server:<br/>';
echo 'Ping server: ' . $loadbalancer->getLastServerKey() .'<hr/>'; echo 'Ping server: ' . $loadbalancer->getLastServerKey() .'<hr/>';
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance and autoload the postbigrequest plugin // create a client instance and autoload the postbigrequest plugin
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
$client->getPlugin('postbigrequest'); $client->getPlugin('postbigrequest');
// create a basic query to execute // create a basic query to execute
......
...@@ -4,7 +4,7 @@ require('init.php'); ...@@ -4,7 +4,7 @@ require('init.php');
htmlHeader(); htmlHeader();
// create a client instance and autoload the customize request plugin // create a client instance and autoload the customize request plugin
$client = new Solarium\Client($config); $client = new Solarium\Client\Client($config);
$customizer = $client->getPlugin('customizerequest'); $customizer = $client->getPlugin('customizerequest');
// add a persistent HTTP header (using array input values) // add a persistent HTTP header (using array input values)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment