From 0af1daa4929da5adcc027aee3f57f2df736c1f40 Mon Sep 17 00:00:00 2001 From: Andreas streichardt Date: Sat, 9 Jun 2012 14:59:20 +0200 Subject: [PATCH] Ensure that we are working with documents and not with arrays --- lib/triagens/ArangoDb/Cursor.php | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/triagens/ArangoDb/Cursor.php b/lib/triagens/ArangoDb/Cursor.php index 65841e95..cf5ae698 100644 --- a/lib/triagens/ArangoDb/Cursor.php +++ b/lib/triagens/ArangoDb/Cursor.php @@ -104,11 +104,19 @@ public function __construct(Connection $connection, array $data, array $options) $this->_hasMore = (bool) $data[self::ENTRY_HASMORE]; $this->_options = $options; - $this->_result = $this->sanitize((array) $data[self::ENTRY_RESULT]); + $this->_result = array(); + $this->addDocumentsFromArray((array) $data[self::ENTRY_RESULT]); $this->updateLength(); $this->rewind(); } + + private function addDocumentsFromArray(array $data) + { + foreach ($this->sanitize($data) as $row) { + $this->_result[] = Document::createFromArray($row); + } + } /** * Explicitly delete the cursor @@ -254,7 +262,7 @@ private function fetchOutstanding() { $data = $response->getJson(); $this->_hasMore = (bool) $data[self::ENTRY_HASMORE]; - $this->_result = array_merge($this->_result, $this->sanitize((array) $data[self::ENTRY_RESULT])); + $this->addDocumentsFromArray($data[self::ENTRY_RESULT]); if (!$this->_hasMore) { // we have fetch the complete result set and can unset the id now