downloads | documentation | faq | getting help | mailing lists | licenses | wiki | reporting bugs | php.net sites | conferences | my php.net

search for in the

SphinxClient::setSortMode> <SphinxClient::setSelect
[edit] Last updated: Fri, 30 Nov 2012

view this page in

SphinxClient::setServer

(PECL sphinx >= 0.1.0)

SphinxClient::setServerSet searchd host and port

Opis

public bool SphinxClient::setServer ( string $server , int $port )

Sets searchd host name and TCP port. All subsequent requests will use the new host and port settings. Default host and port are 'localhost' and 3312, respectively.

Parametry

server

IP or hostname.

port

Port number.

Zwracane wartości

Zwraca TRUE w przypadku powodzenia, FALSE w przypadku błędu.



add a note add a note User Contributed Notes SphinxClient::setServer - [1 notes]
up
0
craig dot constable at gmail dot com
8 months ago
<?php
   
//Here is an example of using the Sphinx api client
   
$server = "192.168.0.100:3306";
   
$username = "johnsmith";
   
$password = "Password1";
   
$database = "customers";
    function
newSQL() {
        global
$server, $username, $password, $database;
       
$con = new mysqli($server, $username, $password, $database);
        return
$con;
    }

    include(
'sphinxapi.php');

   
$search = '@postcode 2012';
   
$s = new SphinxClient;
   
$s->SetServer("192.168.0.100", 9312);
   
$s->SetMatchMode(SPH_MATCH_EXTENDED2);
   
$s->SetSortMode (SPH_SORT_EXTENDED,'@random');
   
$s->SetLimits(0, $times);
   
$index = 'main:delta';
   
$result = $s->Query($search, $index);

    if (
$result['total'] > 0) {
        foreach (
$result['matches'] as $id => $other) {
           
$people .= "pid=$id OR ";   
        }
       
$people = substr($people, 0, -4);
    }

   
$mysqli = newSQL();
   
$mysqliResult = $mysqli->query("SELECT `pid`, `name`, `postcode` FROM `profiles` WHERE ($people)");
   
//Do something with $mysqliResult
   
$mysqli->close();
?>

 
show source | credits | sitemap | contact | advertising | mirror sites