Example #1
0
 /**
  * @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 testselect
  */
 public function testdrop(SequoiaDB $sdb)
 {
     $array = $sdb->dropCollectionSpace("cs_test");
     $this->assertEquals(0, $array['errno']);
 }
Example #3
0
 /**
  * @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);
 }
Example #4
0
 /**
  * @depends testconnect
  */
 public function testselectCS(SequoiaDB $sdb)
 {
     $cs = $sdb->selectCS("cs_test");
     $this->assertNotEmpty($cs);
     return $cs;
 }
Example #5
0
                $db_t = new SequoiaDB();
                $arr = $db_t->connect($address, $user, $pwd);
                $rc = $arr['errno'];
                if ($arr['errno'] == 0) {
                    $link_result = "连接成功";
                } else {
                    $rc = $arr['errno'];
                    $link_result = "连接失败:" . (array_key_exists($rc, $errno_cn) ? $errno_cn[$rc] : $rc);
                }
                $return_arr = array('errno' => $rc, 'message' => $link_result);
            } else {
                if ($model == "connect") {
                    $_SESSION['sdb_monitor_address'] = $address;
                    $_SESSION['sdb_monitor_user'] = $user;
                    $_SESSION['sdb_monitor_password'] = $pwd;
                    $db_t = new SequoiaDB();
                    $arr = $db_t->connect($address, $user, $pwd);
                    $rc = $arr['errno'];
                    $return_arr = array('errno' => $rc, 'message' => array_key_exists($rc, $errno_cn) ? $errno_cn[$rc] : $rc);
                }
            }
        }
    }
}
$array_temp = array();
$error_record = 0;
if (file_exists($path)) {
    $file = fopen($path, "r+");
    while (!feof($file)) {
        $str = fgets($file, 163840);
        if ($str[0] != ",") {
 /**
  * @depends testexecUpdate
  */
 public function testdrop(SequoiaDB $sdb)
 {
     $array = $sdb->execUpdateSQL("drop collectionspace cs_test");
     $this->assertEquals(0, $array['errno']);
 }
Example #7
0
<?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>';
Example #8
0
$space = empty($_POST['space']) ? "" : $_POST['space'];
$collectname = empty($_POST['collectname']) ? "" : $_POST['collectname'];
$condition = empty($_POST['condition']) ? NULL : $_POST['condition'];
$selected = empty($_POST['selected']) ? NULL : $_POST['selected'];
$orderBy = empty($_POST['orderBy']) ? NULL : $_POST['orderBy'];
$hint = empty($_POST['hint']) ? NULL : $_POST['hint'];
$numToSkip = empty($_POST['numToSkip']) ? 0 : $_POST['numToSkip'];
$numToReturn = empty($_POST['numToReturn']) ? -1 : $_POST['numToReturn'];
$rule = empty($_POST['rule']) ? NULL : $_POST['rule'];
$indexDef = empty($_POST['indexDef']) ? NULL : $_POST['indexDef'];
$indexpName = empty($_POST['indexpName']) ? NULL : $_POST['indexpName'];
$isUnique = empty($_POST['isUnique']) ? NULL : $_POST['isUnique'];
$obj = empty($_POST['obj']) ? "" : $_POST['obj'];
$listType = empty($_POST['listType']) ? 0 : $_POST['listType'];
$pName = empty($_POST['pName']) ? NULL : $_POST['pName'];
$sequoia_db = new SequoiaDB($addr);
if ($sequoia_db) {
    if ($work == "create_coll_space") {
        $sequoia_db->selectCS($space);
        if ($sequoia_db) {
            echo "true";
        }
    } else {
        if ($work == "del_coll_space") {
            $cs = $sequoia_db->selectCS($space);
            if ($cs) {
                var_dump($cs->drop());
            }
        } else {
            if ($work == "list_coll_space") {
                $cursor = $sequoia_db->listCSs();