Skip to content

Commit

Permalink
optimize getValues() by using native PHP function.
Browse files Browse the repository at this point in the history
  • Loading branch information
janl committed Jul 7, 2011
1 parent 400779c commit b69a420
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions Couchbase/View.php
Expand Up @@ -63,12 +63,13 @@ function getResultByRange($start, $end = null, $options = array())
function getValues($options = array())
{
$result = $this->getResult($options);
$ids = array();
foreach($result->rows AS $row) {
$ids[] = $row->id;
}

// TODO: make this a anonymous function when 5.3 is our minimum version
function extract_id($row) { return $row->id; }
$ids = array_map("extract_id", $result->rows);

$multi_result = $this->db->getMulti($ids);
// TODO: make this a anonymous function when 5.3 is our minimum version
function jsonize($s) { return json_decode($s); }
$jsoned_result = array_map("jsonize", $multi_result);
return($jsoned_result);
Expand Down

0 comments on commit b69a420

Please sign in to comment.