本文整理汇总了PHP中Solarium_Client::setAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client::setAdapter方法的具体用法?PHP Solarium_Client::setAdapter怎么用?PHP Solarium_Client::setAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solarium_Client
的用法示例。
在下文中一共展示了Solarium_Client::setAdapter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: __construct
/** The constructor
*
*/
public function __construct()
{
$this->_cache = Zend_Registry::get('cache');
$this->_config = Zend_Registry::get('config');
$this->_solrConfig = array('adapteroptions' => $this->_config->solr->toArray());
$this->_solr = new Solarium_Client($this->_solrConfig);
$this->_solr->setAdapter('Solarium_Client_Adapter_ZendHttp');
$loadbalancer = $this->_solr->getPlugin('loadbalancer');
$master = $this->_config->solr->master->toArray();
$slave = $this->_config->solr->slave->toArray();
$loadbalancer->addServer('master', $master, 100);
$loadbalancer->addServer('slave', $slave, 200);
$loadbalancer->setFailoverEnabled(true);
}
示例2: testExecuteRequestPostPlugin
public function testExecuteRequestPostPlugin()
{
$request = new Solarium_Client_Request();
$dummyResponse = 'dummyresponse';
$mockAdapter = $this->getMock('Solarium_Client_Adapter', array('execute'));
$mockAdapter->expects($this->any())->method('execute')->with($this->equalTo($request))->will($this->returnValue($dummyResponse));
$this->_client->setAdapter($mockAdapter);
$response = $this->_client->executeRequest($request);
$observer = $this->getMock('Solarium_Plugin_Abstract', array(), array($this->_client, array()));
$observer->expects($this->once())->method('postExecuteRequest')->with($this->equalTo($request), $this->equalTo($response));
$this->_client->registerPlugin('testplugin', $observer);
$this->_client->executeRequest($request);
}
示例3: getSolr
/** Get the solr object for querying cores
* @access public
* @return \Solarium_Client
*/
public function getSolr()
{
$this->_solr = new Solarium_Client($this->getSolrConfig());
$this->_solr->setAdapter('Solarium_Client_Adapter_ZendHttp');
$this->_solr->getAdapter()->getZendHttp();
$loadbalancer = $this->_solr->getPlugin('loadbalancer');
$master = $this->getConfig()->solr->master->toArray();
$asgard = $this->getConfig()->solr->asgard->toArray();
$valhalla = $this->getConfig()->solr->valhalla->toArray();
$loadbalancer->addServer('objects', $master, 100);
$loadbalancer->addServer('asgard', $asgard, 200);
$loadbalancer->addServer('valhalla', $valhalla, 150);
$loadbalancer->setFailoverEnabled(true);
$this->_solr->getAdapter()->getZendHttp();
$this->_loadbalancer = $loadbalancer;
return $this->_solr;
}
示例4: testFailoverMaxRetries
public function testFailoverMaxRetries()
{
$this->_plugin = new TestLoadbalancer();
// special loadbalancer that returns servers in fixed order
$this->_client = new Solarium_Client();
$adapter = new TestAdapterForFailover();
$adapter->setFailCount(10);
$this->_client->setAdapter($adapter);
// set special mock that fails for all servers
$this->_plugin->init($this->_client, array());
$request = new Solarium_Client_Request();
$servers = array('s1' => array('options' => $this->_serverOptions, 'weight' => 1), 's2' => array('options' => $this->_serverOptions, 'weight' => 1));
$this->_plugin->setServers($servers);
$this->_plugin->setFailoverEnabled(true);
$query = new Solarium_Query_Select();
$this->_plugin->preCreateRequest($query);
$this->setExpectedException('Solarium_Exception', 'Maximum number of loadbalancer retries reached');
$this->_plugin->preExecuteRequest($request);
}
示例5: foreach
<?php
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to curl
$client->setAdapter('Solarium_Client_Adapter_Curl');
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: ' . $resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach ($document as $field => $value) {
// this converts multivalue fields to a comma-separated string
if (is_array($value)) {
$value = implode(', ', $value);
}
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();
示例6: foreach
<?php
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to zendhttp and get a zendhttp client instance reference
$client->setAdapter('Solarium_Client_Adapter_ZendHttp');
$zendHttp = $client->getAdapter()->getZendHttp();
// you can use any of the zend_http features, like http-authentication
$zendHttp->setAuth('user', 'password!', Zend_Http_Client::AUTH_BASIC);
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: ' . $resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach ($document as $field => $value) {
// this converts multivalue fields to a comma-separated string
if (is_array($value)) {
$value = implode(', ', $value);
}
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
示例7: __construct
/**
* Instantiates the class; sets and configures the Solarium client
* @param Solarium_Client $client
*/
public function __construct(Solarium_Client $client)
{
$this->client = $client;
$this->client->setAdapter('Solarium_Client_Adapter_Curl');
parent::__construct();
}
示例8: foreach
<?php
require_once 'Zend/Loader/Autoloader.php';
$loader = Zend_Loader_Autoloader::getInstance();
require 'init.php';
htmlHeader();
// create a client instance
$client = new Solarium_Client($config);
// set the adapter to peclhttp
$client->setAdapter('Solarium_Client_Adapter_PeclHttp');
// get a select query instance
$query = $client->createSelect();
// this executes the query and returns the result
$resultset = $client->select($query);
// display the total number of documents found by solr
echo 'NumFound: ' . $resultset->getNumFound();
// show documents using the resultset iterator
foreach ($resultset as $document) {
echo '<hr/><table>';
// the documents are also iterable, to get all fields
foreach ($document as $field => $value) {
// this converts multivalue fields to a comma-separated string
if (is_array($value)) {
$value = implode(', ', $value);
}
echo '<tr><th>' . $field . '</th><td>' . $value . '</td></tr>';
}
echo '</table>';
}
htmlFooter();