Sphinx\SphinxClient::status PHP Метод

status() публичный Метод

Queries searchd status
public status ( ) : array | false
Результат array | false Status variable name and value pairs, false on error.
    public function status()
    {
        $this->mbPush();
        if (!($fp = $this->connect())) {
            $this->mbPop();
            return false;
        }
        // len=4, body=1
        $req = pack('nnNN', self::SEARCHD_COMMAND_STATUS, self::VER_COMMAND_STATUS, 4, 1);
        if (!$this->send($fp, $req, 12) || !($response = $this->getResponse($fp, self::VER_COMMAND_STATUS))) {
            $this->mbPop();
            return false;
        }
        // just ignore length, error handling, etc
        $res = substr($response, 4);
        $p = 0;
        list($rows, $cols) = array_values(unpack('N*N*', substr($response, $p, 8)));
        $p += 8;
        $res = array();
        for ($i = 0; $i < $rows; $i++) {
            for ($j = 0; $j < $cols; $j++) {
                list(, $len) = unpack('N*', substr($response, $p, 4));
                $p += 4;
                $res[$i][] = substr($response, $p, $len);
                $p += $len;
            }
        }
        $this->mbPop();
        return $res;
    }

Usage Example

Пример #1
0
 public function testStatus()
 {
     $sphinx = new SphinxClient();
     $status = $sphinx->status();
     $this->assertGreaterThan(0, count($status));
 }
All Usage Examples Of Sphinx\SphinxClient::status