Quellcode durchsuchen

Improved the parser for responses to INFO commands

Daniele Alessandri vor 15 Jahren
Ursprung
Commit
afa72fceb2
1 geänderte Dateien mit 11 neuen und 1 gelöschten Zeilen
  1. 11 1
      lib/Predis.php

+ 11 - 1
lib/Predis.php

@@ -1093,7 +1093,17 @@ class Info extends \Predis\InlineCommand {
         $infoLines = explode("\r\n", $data, -1);
         foreach ($infoLines as $row) {
             list($k, $v) = explode(':', $row);
-            $info[$k] = $v;
+            if (!preg_match('/^db\d+$/', $k)) {
+                $info[$k] = $v;
+            }
+            else {
+                $db = array();
+                foreach (explode(',', $v) as $dbvar) {
+                    list($dbvk, $dbvv) = explode('=', $dbvar);
+                    $db[trim($dbvk)] = $dbvv;
+                }
+                $info[$k] = $db;
+            }
         }
         return $info;
     }