Skip to content

arrays vs. documents #5

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 11, 2012
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/triagens/ArangoDb/Cursor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down