/** * @depends testconnect */ public function testinstall(SequoiaDB $sdb) { $array_install = array("install" => false); $sdb->install($array_install); $sdb->selectCS("cs_test"); $str = $sdb->getError(); $this->assertEquals('{"errno":0}', $str); $array_install = array("install" => true); $sdb->install($array_install); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->install('{ "install":false }'); $str = $sdb->dropCollectionSpace("cs_test"); $this->assertEquals('{"errno":0}', $str); $sdb->install('{ "install":true }'); $array = $sdb->dropCollectionSpace("cs_test"); $this->assertEquals(-34, $array["errno"]); $sdb->install('{ "install":false }'); $str = $sdb->getError(); $this->assertEquals('{"errno":-34}', $str); }
/** * @depends testconnect */ public function test_whether_cluster(SequoiaDB $sdb) { $isCluster = TRUE; $snapshot = $sdb->getSnapshot(SDB_SNAP_DATABASE); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $record = $snapshot->getNext(); if (array_key_exists("Role", $record)) { $isCluster = false; } else { $isCluster = true; } return $isCluster; }
/** * @depends testexecUpdate */ public function testexec(SequoiaDB $sdb) { $sdb->execSQL("list collections"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("select * from cs_test.cl_test"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("list collectionspaces"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("select age,count(name) as Ô±¹¤×ÜÊý from cs_test.cl_test group by age "); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("select * from cs_test.cl_test order by age desc"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("select * from cs_test.cl_test limit 5"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); $sdb->execSQL("select * from cs_test.cl_test offset 5"); $array = $sdb->getError(); $this->assertEquals(0, $array['errno']); }
<?php /* * In PHP, single quotation are not the pass of the compiler analysis, * but double quotes are compiler analysis. */ // create a new connection object echo '<p>1. connect to server</p>'; $sdb = new SequoiaDB("localhost:50000"); var_dump($sdb->getError()); if ($sdb) { // create a new collection space object echo '<p>2. create collection space foo</p>'; $cs = $sdb->selectCS("foo"); var_dump($sdb->getError()); if ($cs) { // create a new collection object echo '<p>3. create collection test</p>'; $cl = $cs->selectCollection("test"); if ($cl) { // create a new list collection space cursor object echo '<p>4. list collection spaces</p>'; $sdb_cursor = $sdb->listCSs(); if ($sdb_cursor) { while ($arr = $sdb_cursor->getNext()) { var_dump($arr); echo "<br><br>"; } } // rename this collection name echo '<p>5. rename this collection name</p>';
} } } } } } } } } } } } } } } } } } } } } } var_dump($sequoia_db->getError()); } $sequoia_db->close(); ?> </head> </html>