Advertisement
Guest User

Sphinx Test

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