/**
  * get back a the view results.
  * Example:
  *    $params = array(
  *       'startkey'=>'bear',
  *       'endkey'=>'zebra',
  *       'connection_timeout'=> 60000,
  *       'limit'=>10,
  *       'skip'=>0,
  *       'full_set'=>'true',
  *    );
  *    $result = $view->query('mammals' $params);
  *
  */
 public function query($view, $params = NULL)
 {
     $params = new Container($params);
     foreach ($params as $k => $v) {
         if (!is_scalar($v) || preg_match('#key#i', $k)) {
             $params->{$k} = json_encode($v);
         }
     }
     $len = strlen($this->app);
     $app = $len > 0 ? $this->app : 'default/';
     $http = $this->request('_design/' . $app . '_view/' . $view . '/?' . \Gaia\Http\Util::buildQuery($params->all()));
     $response = $this->validateResponse($http->exec(), array(200));
     $result = $response->body;
     if ($len < 1) {
         return $result;
     }
     foreach ($result['rows'] as &$row) {
         if (isset($row['id'])) {
             $row['id'] = substr($row['id'], $len);
         }
     }
     return $result;
 }
}
foreach ($input as $k => $v) {
    $result_set[$k] = $c->{$k} = $v;
    $result_isset[$k] = isset($c->{$k});
    $result_get[$k] = $c->{$k};
    unset($c->{$k});
    $result_unset[$k] = $c->{$k};
}
Tap::is($input, $result_set, 'set works properly');
Tap::is($input, $result_get, 'get works properly');
Tap::is(array_fill_keys(array_keys($input), TRUE), $result_isset, 'isset works properly');
Tap::is(array_fill_keys(array_keys($input), NULL), $result_unset, 'unset works properly');
Tap::is($c->non_existent, NULL, 'non-existent variables are null');
$c->load($input);
Tap::is($c->get(array_keys($input)), $input, 'multi-get works properly');
Tap::is($c->all(), $input, 'grabbed all of the data at once');
$each = array();
while (list($k, $v) = $c->each()) {
    $each[$k] = $v;
}
Tap::is($c->all(), $each, 'each loop returns all the data in the container');
Tap::is(array_keys($input), $c->keys(), 'keys returns all the keys passed to input');
Tap::is(array_keys($input, 'a'), $c->keys('a'), 'search for a key');
Tap::is($c->pop(), $v = array_pop($input), 'popped off an element, same as input');
Tap::is($c->push($v), array_push($input, $v), 'pushed an element back onto the container');
Tap::is($c->all(), $input, 'after pop and push, input matches container');
Tap::is($c->shift(), $v = array_shift($input), 'shifted off an element, same as input');
Tap::is($c->unshift($v), array_unshift($input, $v), 'unshift an element back onto the container');
Tap::is($c->all(), $input, 'after shift and unshift, input matches container');
@asort($input);
@$c->sort();