public function _read_sync()
{
# type of response
# decode body char with flag continue ( Header already read )
$response_type = $this->_readChar();
$res = [];
switch ($response_type) {
case 'n':
# get end Line \x00
$this->_readChar();
$res = array(null);
break;
case $response_type == 'r' || $response_type == 'w':
$res = [Record::fromConfig($this->_readRecord())];
# get end Line \x00
$this->_readChar();
break;
case 'a':
$res = [$this->_readString()];
# get end Line \x00
$this->_readChar();
break;
case 'l':
$list_len = $this->_readInt();
for ($n = 0; $n < $list_len; $n++) {
$res[] = Record::fromConfig($this->_readRecord());
}
# async-result-type can be:
# 0: no records remain to be fetched
# 1: a record is returned as a result set
# 2: a record is returned as pre-fetched to be loaded in client's
# cache only. It's not part of the result set but the client
# knows that it's available for later access
$cached_results = $this->_read_prefetch_record();
$res = array_merge($res, $cached_results);
# cache = cached_results['cached']
break;
default:
# debug errors
if (!Constants::$LOGGING) {
throw new PhpOrientException('Unknown payload type ' . $response_type);
}
$msg = '';
$m = $this->_transport->getSocket()->read(1);
while ($m != '') {
$msg .= $m;
$this->_transport->hexDump($msg);
$m = $this->_transport->getSocket()->read(1);
}
break;
}
return $res;
}