This commit is contained in:
thbourlove
2014-03-15 00:57:21 +08:00
parent 809f76a7b3
commit e1d700dd0c
2 changed files with 25 additions and 25 deletions
+23 -13
View File
@@ -34,27 +34,37 @@ class ServerInfo extends AbstractCommand
$infoLines = preg_split('/\r?\n/', $data);
foreach ($infoLines as $row) {
@list($k, $v) = explode(':', $row);
if ($row === '' || !isset($v)) {
if (strpos($row, ':') === false) {
continue;
}
if (!preg_match('/^db\d+$/', $k)) {
if ($k === 'allocation_stats') {
$info[$k] = $this->parseAllocationStats($v);
continue;
}
$info[$k] = $v;
} else {
$info[$k] = $this->parseDatabaseStats($v);
}
list($k, $v) = $this->parseRow($row);
$info[$k] = $v;
}
return $info;
}
/**
* Parses single row of the reply buffer and returns the key-value pair.
*
* @param string $row Single row of the reply buffer.
* @return array
*/
public function parseRow($row)
{
list($k, $v) = explode(':', $row, 2);
if (!preg_match('/^db\d+$/', $k)) {
if ($k === 'allocation_stats') {
$v = $this->parseAllocationStats($v);
}
} else {
$v = $this->parseDatabaseStats($v);
}
return [$k, $v];
}
/**
* Parses the reply buffer and extracts the statistics of each logical DB.
*
+2 -12
View File
@@ -41,18 +41,8 @@ class ServerInfoV26x extends ServerInfo
continue;
}
list($k, $v) = explode(':', $row);
if (!preg_match('/^db\d+$/', $k)) {
if ($k === 'allocation_stats') {
$current[$k] = $this->parseAllocationStats($v);
continue;
}
$current[$k] = $v;
} else {
$current[$k] = $this->parseDatabaseStats($v);
}
list($k, $v) = $this->parseRow($row);
$current[$k] = $v;
}
return $info;