Sphinx\SphinxClient::runQueries PHP Method

runQueries() public method

Connect to searchd, run batch queries, and return an array of results
public runQueries ( ) : array
return array Result array.
    public function runQueries()
    {
        if (empty($this->reqs)) {
            $this->error = 'no queries defined, issue addQuery() first';
            return false;
        }
        // mbstring workaround
        $this->mbPush();
        if (!($fp = $this->connect())) {
            $this->mbPop();
            return false;
        }
        // send query, get response
        $nreqs = count($this->reqs);
        $req = implode('', $this->reqs);
        $len = 8 + strlen($req);
        // add header
        $req = pack('nnNNN', self::SEARCHD_COMMAND_SEARCH, self::VER_COMMAND_SEARCH, $len, 0, $nreqs) . $req;
        if (!$this->send($fp, $req, $len + 8) || !($response = $this->getResponse($fp, self::VER_COMMAND_SEARCH))) {
            $this->mbPop();
            return false;
        }
        // query sent ok; we can reset reqs now
        $this->reqs = array();
        // parse and return response
        return $this->parseSearchResponse($response, $nreqs);
    }

Usage Example

 /**
  * Wrapper function for Sphinx batch query execution.
  *
  * @return array Sphinx result array.
  */
 public function runQueries()
 {
     $results = parent::runQueries();
     return $results;
 }
All Usage Examples Of Sphinx\SphinxClient::runQueries