v1.10

Document

How to Start SequoiaDB

Basic Operation

Data Model

Database Management

Aggregation

Index

Replication

Cluster

Connector

Reference

Development

Release Note

FAQ

  • Content
  • Comments
  • History

PHP Development Foundation

Here's how to use PHP database-driven interface written using SepuoiaDB program. For simplicity, this example is not entirely complete code, only play an exemplary role. Available to the installation directory /client/samples/php obtained under the corresponding complete code. More View PHP API

Data Manipulation

  • Connect to the database
    //Create SequoiaDB object
    $db = new Sequoiadb();
    //Connect to database
    $array = $db -> connect("localhost:11810");
    //Test connection results returned by default php array type, the data is array(0){"errno"=>0}
    //If errno is 0, then the connection is successful
    if($array['errno'] !=0 )
    { 
      exit();
    }
  • Select the collection space
    //Select the name of "foo" is a collection of space, if does not exist, it is automatically created
    //Return SequoiaCS object
    $cs = $db -> selectCs("foo");
    //Test results, if successful, returns an object, failed to return NULL
    if( empty($cs) )
    { 
      exit();
    }
  • Choose a collection
    //Select the name of "big" collection, and of not, is automatically created
    //Return SequoiaCollection object
    $cl = $cs -> selectCollection("big");
    //Test results, if successful, returns an object, failed to return NULL
    if( empty($cl) )
    { 
      exit();
    }
  • Insert
    //Insert json
    $arr = $cl -> insert("{test:1}");
    //Test results
    if($array['errno'] !=0 )
    { 
      exit();
    }
    //Insert array
    $arr = $cl -> insert(array("test">=2));
    //Test results
    if($arr['errno'] !=0 )
    { 
      exit();
    }
  • Inquiry
    //Set all the records in the query
    //Return SequoiaCursor object
    $cursor = $cl -> find();
    //Loop through all records
    while($record = $cursor -> getNext())
    {
      var_dump($record);
    }
  • Update
    //Modify the collection of more than a record, the value of the field test was revised to 0
    $arr = $cl -> update("{$set:{test:0}}");
    //Test results
    if($arr['errno'] !=0 )
    { 
      exit();
    }
  • Delete
    //Delete all records collection
    $arr = $cl -> remove();
    //Test results
    if($arr['errno'] !=0 )
    { 
      exit();
    }

Cluster operation

  • Select Group
    //Select the name of "group" of the group, if you do not exist, it is automatically created
    //Return SequoiaShard object
    $group = $db -> selectGroup("group");
    //Test results, if successful, returns an object, failed to return NULL
    if( empty($group) )
    { 
      exit();
    }
  • Boot replica group
    //boot replica group for the first time will automatically activate
    //Return operation information
    $arr = $group -> start() ;
    //Check the restlts
    If ( $arr['errno'] != 0 )
    {
       Exit() ;
       }
  • Select the node
    //Get the name, of "node" node
    //Return SequoiaNode object
    $node = $group -> getNode( 'node') ;
    //Check whether the object is empty
    If ( empty( $node ) )
    {
       Exit() ;
    }
please login to comment.
Latest Comment
  • 2015-03-14

About Us

SequoiaDB is a financial-level distributed database vendor and is the first Chinese database listed in Gartner’s Magic Quadrant OPDBMS report. SequoiaDB has recently released version 3.0.
SequoiaDB is now penetrating the vertical sector Financial Industry quickly and had more than 50 banking clients and hundreds of enterprise customers in industries including government, telecommunication, Internet and IoT.

Beijing:
Tower R, No.8 North Star East Road, Chaoyang District, Beijing,China
Guangzhou:
Tower A, No.22 Qinglan Street, Panyu District, Guangzhou,China
Shenzhen:
Tsing Hua Tech Park, Nanshan District, Shenzhen,China
Tel:400-8038-339
E-mail:contact@sequoiadb.com