本文整理汇总了PHP中Solarium_Client::getAdapter方法的典型用法代码示例。如果您正苦于以下问题:PHP Solarium_Client::getAdapter方法的具体用法?PHP Solarium_Client::getAdapter怎么用?PHP Solarium_Client::getAdapter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Solarium_Client
的用法示例。
在下文中一共展示了Solarium_Client::getAdapter方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testBlockedQueryTypeNotLoadbalanced
public function testBlockedQueryTypeNotLoadbalanced()
{
$originalHost = $this->_client->getAdapter()->getHost();
$servers = array('s1' => array('options' => $this->_serverOptions, 'weight' => 100), 's2' => array('options' => $this->_serverOptions, 'weight' => 1));
$this->_plugin->setServers($servers);
$request = new Solarium_Client_Request();
$query = new Solarium_Query_Update();
// this is a blocked querytype that should not be loadbalanced
$this->_plugin->preCreateRequest($query);
$this->_plugin->preExecuteRequest($request);
$this->assertEquals($originalHost, $this->_client->getAdapter()->getHost());
$this->assertEquals(null, $this->_plugin->getLastServerKey());
}
示例2: 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;
}
示例3: testSetAndGetAdapterWithObject
public function testSetAndGetAdapterWithObject()
{
$adapterClass = 'MyAdapter';
$this->_client->setAdapter(new $adapterClass());
$this->assertThat($this->_client->getAdapter(), $this->isInstanceOf($adapterClass));
}
示例4: 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>';