2012-08-14 7 views
3

저는 PHP를 통해 스핑크스를 사용하려고 노력해 왔으며, 지금까지 전혀 운이 없었습니다. 자체가 예상대로 작동스핑크스 php api가 작동하지 않습니다.

스핑크스

Engine_Api_SphinxClient 설치 패키지와 함께 제공 스핑크스에 대한 일반의 PHP API는 (리눅스 터미널을 통해 내 검색 명령이 작동). 유일한 차이점은 클래스의 이름 지정입니다.

// Connect to sphinx server 
    $sp = new \Engine_Api_SphinxClient(); 

    // Set the server 
    $sp->SetServer('localhost', 9312); 

    // SPH_MATCH_ALL will match all words in the search term 
    $sp->SetMatchMode(SPH_MATCH_ANY); 

    // We want an array with complete per match information including the document ids 
    $sp->SetArrayResult(true); 

    $sp->setFieldWeights(array(
     'thesis'=>2, 
     'body'=>1 
    )); 

    /** 
    * Run the search query. Here the first argument is the search term 
    * and the second is the name of the index to search in. 
    * Search term can come from a search form 
    */ 
    $results = $sp->Query('gun', 'test1'); 
    debug($results); 

setServer에서 9312는 스핑크스 설정 파일에 정의 된 수신 대기입니다. 디버그 라인은 "false"를 제공하고, 나는 다음과 같은 경고 및주의 사항을 참조하십시오

Errors 

Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 998 
Warning: assert(): Assertion failed in /library/Engine/Api/SphinxClient.php on line 177 
Warning: assert(): Assertion failed in /library/Engine/Api/SphinxClient.php on line 177 
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1006 
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1054 
Warning: Invalid argument supplied for foreach() in /library/Engine/Api/SphinxClient.php on line 1070 
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 564 
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 569 
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 477 
Notice: Undefined property: Engine_Api_SphinxClient::$_socket in /library/Engine/Api/SphinxClient.php on line 478 
Warning: fclose() expects parameter 1 to be resource, null given in /library/Engine/Api/SphinxClient.php on line 478 

내 의심은 그 4 개 통지 함께 할 수있는 뭔가가입니다. 누군가가 문제가 무엇인지에 대한 힌트를 제공 할 수 있다면 크게 감사 할 것입니다.

+0

'SphinxClient.php on line 177'은 무엇인가? 어떤 주장이 실패하고 있습니까? – Tchoupi

+0

해당 행의 코드는 'code'assert (is_numeric ($ v)),'code '입니다. $ v는 함수에 전달 된 인수입니다. 177 행은 함수의 첫 번째 행입니다. 음, 어쨌든이 코드는 인터넷에서 무료로 사용할 수 있습니다. 관심이 있다면 다운로드 할 수 있습니다. – Furyvore

답변

7

클래스 자체의 이름을 변경 한 경우 생성자 이름도 변경 했습니까 (430 행 주변)?)이 문제가있는 경우, 당신은 아마 (__construct하는 기능의 이름을 바꿀 수 있습니다 (

을 (생성자에서 발생하는)

나는라고하기 생성자 밤은 의심 때문에 _socket는 initalized되지 않도록이 아니 어떤 클래스가 호출되는지에 따라 다르다. http://php.net/manual/en/language.oop5.decon.php )

+0

고마워, 그게 정확히 문제 였어. – Furyvore

+0

@barryhunter, 감사합니다! – shiva8

관련 문제