public RunQueries ( ) |
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 = join("", $this->_reqs);
$len = 8 + strlen($req);
$req = pack("nnNNN", SEARCHD_COMMAND_SEARCH, VER_COMMAND_SEARCH, $len, 0, $nreqs) . $req;
// add header
if (!$this->_Send($fp, $req, $len + 8) || !($response = $this->_GetResponse($fp, 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);
}
protected function execute() { $sph = $this->sphinxClient->RunQueries(); if ($error = $this->sphinxClient->GetLastError()) { throw new ESphinxException($error); } if ($error = $this->sphinxClient->GetLastWarning()) { throw new ESphinxException($error); } if (!is_array($sph)) { throw new ESphinxException("Sphinx client returns result not array"); } $results = array(); foreach ($sph as $result) { if (isset($result['error']) && strlen($result['error'])) { throw new ESphinxException($result['error']); } $results[] = new ESphinxResult($result); } return $results; }