コード例 #1
0
 function test_a_b_with_dead_node()
 {
     $this->cb->set("a", '{"a":1}');
     $this->cb->set("b", '{"a":2}');
     $view = new Couchbase_View();
     $view->setMapFunction("function(doc) { emit(doc.a, 1); }");
     $this->cb->addView("default", "cluster", $view);
     sleep(10);
     $this->kill_node(1);
     $view = $this->cb->getView("default", "cluster");
     $result = $view->getResult();
     $this->assertInstanceOf("Couchbase_ViewResult", $result);
     $this->assertEquals(2, count($result->rows));
     $this->assertEquals("1", $result->rows[0]->key);
     $this->assertEquals("2", $result->rows[1]->key);
 }
コード例 #2
0
ファイル: lib.php プロジェクト: heweida/php-couchbase-v2
    function prepare_ddoc($with_reduce = false)
    {
        $map_fun = <<<EOC_JS
        function(doc) {
            if(doc.name) {
                emit(doc.name, 1);
            }
        }
EOC_JS;
        $view = new Couchbase_View("default", "name");
        $view->setMapFunction($map_fun);
        if ($with_reduce) {
            $reduce_fun = <<<EOC_JS
            function(k,v,r) {
                return sum(v);
            }
EOC_JS;
            $view->setReduceFunction($reduce_fun);
        }
        $this->cb->addView($view);
    }
コード例 #3
0
ファイル: View.php プロジェクト: heweida/php-couchbase-v2
 /**
  * Constructor, fake ddoc and view names
  */
 function __construct()
 {
     parent::__construct("_builtin", "_all_docs");
 }