Advertisement
Guest User

Sphinx

a guest
Oct 22nd, 2012
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.66 KB | None | 0 0
  1. <?php
  2.   include('api/sphinxapi.php');
  3.  
  4.   $cl = new SphinxClient();
  5.   $cl->SetServer( "195.xxx.xxx.xxx", 3312 );
  6.   $cl->SetMatchMode( SPH_MATCH_ANY  );
  7.   $cl->SetFilter( 'model', array( 3 ) );
  8.  
  9.   $result = $cl->Query( 'key', 'stage' );
  10.  
  11.   if ( $result === false ) {
  12.       echo "Query failed: " . $cl->GetLastError() . ".\n";
  13.   }
  14.   else {
  15.       if ( $cl->GetLastWarning() ) {
  16.           echo "WARNING: " . $cl->GetLastWarning() . "
  17. ";
  18.       }
  19.  
  20.       if ( ! empty($result["matches"]) ) {
  21.           foreach ( $result["matches"] as $doc => $docinfo ) {
  22.                 echo "$doc\n";
  23.           }
  24.  
  25.           print_r( $result );
  26.       }
  27.   }
  28.  
  29.   exit;
  30. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement