Browse Source

Parse response to HGETALL as an array of key => value.

Daniele Alessandri 15 years ago
parent
commit
db6b8a3fc8
1 changed files with 10 additions and 0 deletions
  1. 10 0
      lib/Predis.php

+ 10 - 0
lib/Predis.php

@@ -2220,6 +2220,16 @@ class HashValues extends \Predis\MultiBulkCommand {
 
 
 class HashGetAll extends \Predis\MultiBulkCommand {
 class HashGetAll extends \Predis\MultiBulkCommand {
     public function getCommandId() { return 'HGETALL'; }
     public function getCommandId() { return 'HGETALL'; }
+    public function parseResponse($data) {
+        if ($data instanceof \Iterator) {
+            return new \Predis\Utilities\MultiBulkResponseKVIterator($data);
+        }
+        $result = array();
+        for ($i = 0; $i < count($data); $i++) {
+            $result[$data[$i]] = $data[++$i];
+        }
+        return $result;
+    }
 }
 }
 
 
 /* multiple databases handling commands */
 /* multiple databases handling commands */