Search code examples
phpsphinx

Change sphinxapi.php and restart on Sphinx


I should change sphinxapi.php , my sphinxapi.php on (usr/local/sphinx/lib/sphinxapi.php) i changed it but what should i do after that to use new functions ?

my php :

<?php

            $sphinx = new SphinxClient();
            $sphinx->SetServer($this->config->sphinx->host, $this->config->sphinx->port);
            $sphinx->SetMatchMode(SPH_MATCH_ALL);
            $sphinx->SetLimits(0, 1,1);

..filters...

            $sphinx->RemoveFilter($color['id']);

My new function :

 function RemoveFilter ( $attribute )
   {
      assert ( is_string($attribute) );

      foreach($this->_filters AS $key => $filter){
         if($filter['attr'] == $attribute){
            unset($this->_filters[$key]);
            break;
         }
      }
   }

Error :

Fatal error: Call to undefined method SphinxClient::RemoveFilter() in

Solution

  • At a guess, you've modified the one that comes with sphinx, but the application itself is using a different 'sphinxapi.php' - maybe a locally installed one.

    Or even you have the sphinx extension installed, so its providing the SphinxClient not 'sphinxapi.php`'- if so uninstall the extension.