tags:

views:

20

answers:

1

Hello. My sphinx config:

source logs
{
    type            = mysql
    sql_host        = localhost
    sql_user        = root
    sql_pass        =
    sql_db            = bot
    sql_port        = 3306
    sql_query_pre    = SET NAMES utf8
    sql_query        = SELECT * FROM logs

    sql_attr_uint   = host

    sql_query_info    = SELECT * FROM logs WHERE id=$id
}

index logs
{
    source          = logs
    path            = D:\Webserver/Sphinx/index/logs
    morphology      = stem_ru, stem_en
    min_word_len    = 1
    charset_type    = utf-8
}

searchd
{
    listen      = 9312
    log         = D:\Webserver/Sphinx/log/searchd.log
    query_log   = D:\Webserver/Sphinx/log/query.log
    pid_file    = D:\Webserver/Sphinx/log/searchd.pid
}

My database:

ID      |     HOST      |      POST     |       URL
1     |       yahoo.com    |    *js3s7Hs56     |   http://yahoo.com     
2     |       google.com    |    7sf6jsg73     |   http://google.com/?asfaa=23

PHP Code Sphinx (search)

<?php
    include('sphinxapi.php');

    $cl = new SphinxClient();
    $cl->SetServer( "localhost", 9312 );

    $cl->SetMatchMode( SPH_MATCH_ANY  );
    $result = $cl->Query("google");


    if ( $result === false )
    { 
          echo "Query failed: " . $cl->GetLastError() . ".\n";
    }
    else
    {
        print_r($result);
    }

This code is returned :

2

As now I'm using sphinx to withdraw all data id 2??

Sorry for bad english

+1  A: 

You can now take that ID returned in $result and query your database with it.

Something like:

<?php
    foreach ($result["IDs"] as $ID) {
        $r = mysql_query("SELECT * FROM `table` WHERE `ID`=$ID");
        # Handle $r
    }
?>
PureForm
Thanks .. I thought at the Sphinx is its function
Isis