SequoiaDB
 All Classes Files Functions Variables Pages
Public Member Functions | Public Attributes | List of all members
SequoiaDB Class Reference
Inheritance diagram for SequoiaDB:
SecureSdb

Public Member Functions

 __construct (array|string $address, string $userName="", string $password="", boolean $useSSL=false)
 
 install (array|string $options=null)
 
 getError ()
 
 connect (array|string $address="127.0.0.1:11810", string $userName="", string $password="", boolean $useSSL=false)
 
 close ()
 
 isValid ()
 
 snapshot (integer $type, array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 resetSnapshot (array|string $condition=null)
 
 list (integer $type, array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 listCS (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 selectCS (string $name, array|string $options=null)
 
 selectCS (string $name, integer $pageSize=null)
 
 createCS (string $name, array|string $options=null)
 
 getCS (string $name)
 
 dropCS (string $name)
 
 listCL (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 getCL (string $fullName)
 
 truncate (string $fullName)
 
 listDomain (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 createDomain (string $name, array|string $options=null)
 
 getDomain (string $name)
 
 dropDomain (string $name)
 
 listGroup (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 getGroup (string $name)
 
 createGroup (string $name)
 
 removeGroup (string $name)
 
 createCataGroup (string $hostName, string $serviceName, string $databasePath, array|string $configure=null)
 
 execSQL (string $sql)
 
 execUpdateSQL (string $sql)
 
 createUser (string $userName, string $passwd)
 
 removeUser (string $userName, string $passwd)
 
 flushConfigure (array|string $options)
 
 listProcedure (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 createJsProcedure (string $code)
 
 removeProcedure (string $name)
 
 evalJs (string $code)
 
 transactionBegin ()
 
 transactionCommit ()
 
 transactionRollback ()
 
 backupOffline (array|string $options)
 
 listBackup (array|string $options, array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 removeBackup (array|string $options)
 
 listTask (array|string $condition=null, array|string $selector=null, array|string $orderBy=null, array|string $hint=null)
 
 waitTask (array|integer|SequoiaInt64 $taskID)
 
 cancelTask (integer|SequoiaInt64 $taskID, boolean $isAsync=true)
 
 setSessionAttr (array|string $options)
 
 forceSession (integer|SequoiaINT64 $sessionID)
 
 getList (integer $type, array|string $condition=null, array|string $selector=null, array|string $orderBy=null)
 
 getSnapshot (integer $type, array|string $condition=null, array|string $selector=null, array|string $orderBy=null)
 
 selectCS (string $name, integer $pageSize=4096)
 
 listCSs ()
 
 dropCollectionSpace (string $name)
 
 listCollections ()
 
 listDomains ()
 
 selectGroup (string $name)
 

Public Attributes

const SDB_SNAP_CONTEXTS 0
 
const SDB_SNAP_CONTEXTS_CURRENT 1
 
const SDB_SNAP_SESSIONS 2
 
const SDB_SNAP_SESSIONS_CURRENT 3
 
const SDB_SNAP_COLLECTION 4
 
const SDB_SNAP_COLLECTIONSPACE 5
 
const SDB_SNAP_DATABASE 6
 
const SDB_SNAP_SYSTEM 7
 
const SDB_SNAP_CATALOG 8
 
const SDB_SNAP_TRANSACTION_CURRENT 9
 
const SDB_SNAP_TRANSACTION 10
 
const SDB_LIST_CONTEXTS 0
 
const SDB_LIST_CONTEXTS_CURRENT 1
 
const SDB_LIST_SESSIONS 2
 
const SDB_LIST_SESSIONS_CURRENT 3
 
const SDB_LIST_COLLECTIONS 4
 
const SDB_LIST_COLLECTIONSPACES 5
 
const SDB_LIST_STORAGEUNITS 6
 
const SDB_LIST_GROUPS 7
 
const SDB_LIST_SHARDS 8
 
const SDB_LIST_DOMAINS 9
 
const SDB_LIST_TASKS 10
 
const SDB_LIST_CS_IN_DOMAIN 11
 
const SDB_LIST_CL_IN_DOMAIN 12
 

Detailed Description

Class for create an object of the db

Constructor & Destructor Documentation

SequoiaDB::__construct ( array|string  $address,
string  $userName = "",
string  $password = "",
boolean  $useSSL = false 
)

SequoiaDB class constructor.

Parameters
$addressan array or the string argument. The Host Name or IP Address and The Service Name or Port of Database Server.
$userNamethe string argument. The User's Name of the account.
$passwordthe string argument. The Password of the account.
$useSSLa boolean argument. Connect to database with ssl.

Example: 1. Using the connect function to connect to the database.

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 2. Connect to the database.

$db = new SequoiaDB( "192.168.1.10:11810" ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 3. Connect to the database, using the default service name. The default service name is 11810.

$db = new SequoiaDB( "192.168.1.10" ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 4. Connect to the running database one.

$db = new SequoiaDB( [ "192.168.1.10:11810", "192.168.1.11:11810", "192.168.1.12:11810" ] ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 5. Connect to the authentication database.

$db = new SequoiaDB( "192.168.1.10:11810", "admin", "123456" ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 6. Connect to the running authentication database one.

$db = new SequoiaDB( [ "192.168.1.10:11810", "192.168.1.11:11810", "192.168.1.12:11810" ], "admin", "123456" ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 7. Connect to the database with ssl.

$db = new SequoiaDB( "192.168.1.10:11810", "", "", true ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database with ssl, error code: ".$err['errno'] ;
return ;
}

Example: 8. Using the connect function to connect to the database with ssl.

$db = new SecureSdb() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database with ssl, error code: ".$err['errno'] ;
return ;
}

Example: 9. Connect to the database with ssl.

$db = new SecureSdb( "192.168.1.10:11810" ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database with ssl, error code: ".$err['errno'] ;
return ;
}

Member Function Documentation

SequoiaDB::backupOffline ( array|string  $options)

Backup the whole database or specifed replica group.

Parameters
$optionsan array or the string argument. Contains a series of backup configuration infomations. Backup the whole cluster if null. The "options" contains 5 options as below. All the elements in options are optional. e.g.
array( 'GroupName' => array( 'RGName1', 'RGName2' ), 'Path' => '/opt/sequoiadb/backup', 'Name' => 'backupName', 'Description' => 'It is my backup', 'EnsureInc' => true, 'OverWrite' => true )
GroupID : The id(s) of replica group(s) which to be backuped
GroupName : The replica groups which to be backuped
Path : The backup path, if not assign, use the backup path assigned in the configuration file,
the path support to use wildcard(%g/%G:group name, %h/%H:host name, %s/%S:service name).
e.g.
array( 'Path' => '/opt/sequoiadb/backup/%g' )
isSubDir : Whether the path specified by paramer "Path" is a subdirectory of the path specified in the configuration file, default to be false
Name : The name for the backup
Prefix : The prefix of name for the backup, default to be null.
e.g.
array( 'Prefix' => '%g_bk_' )
EnableDateDir : Whether turn on the feature which will create subdirectory named to current date like "YYYY-MM-DD" automatically, default to be false
Description : The description for the backup
EnsureInc : Whether excute increment synchronization, default to be false
OverWrite : Whether overwrite the old backup file, default to be false
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> backupOffline( array( 'Name' => 'myBackup_1' ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call backupOffline, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::cancelTask ( integer|SequoiaInt64  $taskID,
boolean  $isAsync = true 
)

Cancel the specified task.

Parameters
$taskIDan integer argument. The task id.
$isAsynca boolean argument. The operation "cancel task" is async or not, "true" for async, "false" for sync. Default sync.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> cancelTask( 1, false ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call cancelTask, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::close ( )

Disconnect to database.

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$db -> close() ;
SequoiaDB::connect ( array|string  $address = "127.0.0.1:11810",
string  $userName = "",
string  $password = "",
boolean  $useSSL = false 
)

Connect to database.

Parameters
$addressan array or the string argument. The Host Name or IP Address and The Service Name or Port of Database Server.
$userNamethe string argument. The User's Name of the account.
$passwordthe string argument. The Password of the account.
$useSSLa boolean argument. Connect to database with ssl.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example: 1. Connect to the default address of the database. The default address is 127.0.0.1:11810.

$db = new SequoiaDB() ;
$err = $db -> connect() ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 2. Connect to the database.

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 3. Connect to the database, using the default service name. The default service name is 11810.

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 4. Connect to the running database one.

$db = new SequoiaDB() ;
$err = $db -> connect( [ "192.168.1.10:11810", "192.168.1.11:11810", "192.168.1.12:11810" ] ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 5. Connect to the authentication database.

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810", "admin", "123456" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 6. Connect to the running authentication database one.

$db = new SequoiaDB() ;
$err = $db -> connect( [ "192.168.1.10:11810", "192.168.1.11:11810", "192.168.1.12:11810" ], "admin", "123456" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}

Example: 7. Connect to the database with ssl.

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810", "", "", true ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database with ssl, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createCataGroup ( string  $hostName,
string  $serviceName,
string  $databasePath,
array|string  $configure = null 
)

Create a catalog replica group.

Parameters
$hostNamethe string argument. The hostname for the catalog replica group.
$serviceNamethe string argument. The servicename for the catalog replica group.
$databasePaththe string argument. The path for the catalog replica group.
$configurethe string argument. The configurations for the catalog replica group.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createCataGroup( 'host1', '11900', '/opt/sequoiadb/database/catalog/11900' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create catalog group, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createCS ( string  $name,
array|string  $options = null 
)

Create the specified collection space.

Parameters
$namethe string argument. The collection space name.
$optionsan array or the string argument. The options specified by use. e.g.
array( 'PageSize' => 4096, 'Domain' => 'myDomain' )
PageSize : Assign the pagesize of the collection space
Domain : Assign which domain does current collection space belong to
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createCS( 'foo', array( 'PageSize' => 4096 ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call createCS, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createDomain ( string  $name,
array|string  $options = null 
)

Create a domain.

Parameters
$namethe string argument. The name of the domain.
$optionsan array or the string argument. The options for the domain. The options are as below:
Groups : The list of replica groups names which the domain is going to contain.
eg: array( 'Groups' => array( "group1", "group2", "group3" ) )
If this argument is not included, the domain will contain all replica groups in the cluster.
AutoSplit : If this option is set to be true, while creating collection(ShardingType is "hash") in this domain,
the data of this collection will be split(hash split) into all the groups in this domain automatically.
However, it not automatically split data into those groups which were add into this domain later.
eg: array( 'Groups' => array( "group1", "group2", "group3" ), 'AutoSplit' => true )
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createDomain( 'myDomain', array( 'Groups' => array( "group1", "group2", "group3" ), 'AutoSplit' => true ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create domain, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createGroup ( string  $name)

Create the specified replica group.

Parameters
$namethe string argument. The name of the replica group.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createGroup( 'myGroup' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create group, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createJsProcedure ( string  $code)

Create a store procedure.

Parameters
$codethe string argument. The code of store procedures.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createJsProcedure( 'function sum( a,b ){ return a + b ; }' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call createJsProcedure, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::createUser ( string  $userName,
string  $passwd 
)

Create an account.

Parameters
$userNamethe string argument. The user name of the account.
$passwdthe string argument. The password of the account.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> createUser( 'mike', '123456789' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create user, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::dropCollectionSpace ( string  $name)

Drop the specified collection space.

See Also
dropCS().
Deprecated:
This function is deprecated, use the function dropCS() instead.
SequoiaDB::dropCS ( string  $name)

Drop the specified collection space.

Parameters
$namethe string argument. The collection space name.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> dropCS( 'foo' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to drop collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::dropDomain ( string  $name)

Drop a domain.

Parameters
$namethe string argument. The name of the domain.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> dropDomain( 'myDomain' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to drop domain, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::evalJs ( string  $code)

Eval javascript code.

Parameters
$codethe string argument. The code to eval.
Returns
Returns javascript return value
Return values
void
string
integer
SequoiaINT64
double
arrayrecord
stringrecord
boolean
SequoiaCursorObject
SequoiaCSObject
SequoiaCLObject
SequoiaGroupObject
SequoiaNodeObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$result = $db -> evalJs( 'sum( 1, 2 );' ) ;
$err = $db -> getError() ;
if( $err['errno'] != 0 ) ) {
echo "Failed to call evalJs, error code: ".$err['errno'] ;
if( strlen( $result ) > 0 )
{
echo $result ;
}
return ;
}
$type = gettype( $result ) ;
switch( $type )
{
case 'boolean':
case 'integer':
case 'double':
case 'string':
echo "Value is ".$result ;
break ;
case 'array':
echo "Value is " ;
var_dump( $result ) ;
break ;
case 'resource':
$resourceType = get_resource_type( $result ) ;
if( $resourceType == 'SequoiaINT64' )
{
echo "Value is ".$result ;
}
else if( $resourceType == 'SequoiaCS' )
{
echo "Get a collection space object" ;
}
else if( $resourceType == 'SequoiaCL' )
{
echo "Get a collection object" ;
}
else if( $resourceType == 'SequoiaGroup' )
{
echo "Get a group object" ;
}
else if( $resourceType == 'SequoiaNode' )
{
echo "Get a node object" ;
}
else if( $resourceType == 'SequoiaCursor' )
{
while( $record = $result -> next() ) {
var_dump( $record ) ;
}
}
break ;
}
SequoiaDB::execSQL ( string  $sql)

Executing SQL command.

Parameters
$sqlthe string argument. The SQL command.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> execSQL( 'select * from foo.bar' ) ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call execSQL, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::execUpdateSQL ( string  $sql)

Executing SQL command for updating.

Parameters
$sqlthe string argument. The SQL command.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> execUpdateSQL( 'create collectionspace foo' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call execUpdateSQL, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::flushConfigure ( array|string  $options)

Flush the options to configure file.

Parameters
$optionsan array or the string argument. The configure infomation. e.g.
array( 'Global' => true )
Global : In cluster environment, passing array( 'Global' => true ) will flush data and catalog configuration file, while passing array( 'Global' => false ) will flush coord configuration file.
In stand-alone environment, both them have the same behaviour.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> flushConfigure( array( 'Global' => true ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call flushConfigure, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::forceSession ( integer|SequoiaINT64  $sessionID)

Interrupte the session.

Parameters
$sessionIDan integer or the SequoiaINT64 Object argument. The id of the session which we want to inerrupt.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example: integer type

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> forceSession( 1 ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call forceSession, error code: ".$err['errno'] ;
return ;
}

Example: SequoiaINT64 type

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> forceSession( new SequoiaINT64( '1' ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call forceSession, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::getCL ( string  $fullName)

Get the specified collection.

Parameters
$fullNamethe string argument. The collection full name.
Returns
Returns a new SequoiaCL object.
Return values
SequoiaCLObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cl = $db -> getCL( 'foo.bar' ) ;
if( empty( $cl ) ) {
$err = $db -> getError() ;
echo "Failed to call getCL, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::getCS ( string  $name)

Get the specified collection space.

Parameters
$namethe string argument. The collection space name.
Returns
Returns a new SequoiaCS object.
Return values
SequoiaCSObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cs = $db -> getCS( 'foo' ) ;
if( empty( $cs ) ) {
$err = $db -> getError() ;
echo "Failed to call getCS, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::getDomain ( string  $name)

Get a domain.

Parameters
$namethe string argument. The name of the domain.
Returns
Returns a new SequoiaDomain object.
Return values
SequoiaDomainObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$domainObj = $db -> getDomain( 'myDomain' ) ;
if( empty( $domainObj ) ) {
$err = $db -> getError() ;
echo "Failed to call getDomain, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::getError ( )

When function return value is result, the return content contains the error code. but a small part of function does not return an error code, So you can call getError() to retrieve the error code.

Returns
Returns the result of the last operation, default return array, set the return type by using the install() function.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 )
{
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cl = $db -> getCL( "foo.bar" ) ;
echo "Get the error code for the getCL function." ;
$err = $db -> getError() ;
var_dump( $err ) ;
SequoiaDB::getGroup ( string  $name)

Get the specified replica group.

Returns
Returns a new SequoiaGroup object.
Return values
SequoiaGroupObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$groupObj = $db -> getGroup( 'myGroup' ) ;
if( empty( $groupObj ) ) {
$err = $db -> getError() ;
echo "Failed to call getGroup, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::getList ( integer  $type,
array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null 
)

Get the specified list.

See Also
list().
Deprecated:
This function is deprecated, use the function list() instead.
SequoiaDB::getSnapshot ( integer  $type,
array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null 
)

Get the snapshot.

See Also
snapshot().
Deprecated:
This function is deprecated, use the function snapshot() instead.
SequoiaDB::install ( array|string  $options = null)

SequoiaDB class constructor.

Parameters
$optionsan array or the string argument. Set driver options and return the current options. the options are as below:
install: Set the type of return value for all return result function.
The default is true, return an array;
set the false, return the string.
Returns
Returns the current options.
Return values
arrayarray( 'install' => true )
string{ "install": false }

Example: 1. Set to return an array type

$db = new SequoiaDB() ;
$db -> install( array( 'install' => true ) ) ;
$err = $db -> getError() ;
echo "The result is an array type. " ;
var_dump( $err ) ;
//output: array(1){ ["errno"] => int(0) }

Example: 2. Set to return the string type

$db = new SequoiaDB() ;
$db -> install( array( 'install' => false ) ) ;
$err = $db -> getError() ;
echo "The result is the string type. " ;
var_dump( $err ) ;
//output: string(14) "{ "errno": 0 }"

Example: 3. Get the driver current options

$db = new SequoiaDB() ;
$options = $db -> install() ;
var_dump( $options ) ;
SequoiaDB::isValid ( )

Judge whether the connection is valid.

Returns
Returns the result.
Return values
booleanisConnect

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$status = $db -> isValid() ;
echo "Current connection status: ".$status ;
$db -> close() ;
$status = $db -> isValid() ;
echo "Current connection status: ".$status ;
SequoiaDB::list ( integer  $type,
array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

Get the specified list.

Parameters
$typean integer argument. The list type as below:
$conditionan array or the string argument. The matching rule, match all the documents if null.
$selectoran array or the string argument. The selective rule, return the whole document if null.
$orderByan array or the string argument. The ordered rule, never sort if null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> list( SDB_LIST_CONTEXTS ) ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call list, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listBackup ( array|string  $options,
array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List the backups.

Parameters
$optionsan array or the string argument. Contains configuration infomations for remove backups, list all the backups in the default backup path if null. The "options" contains 3 options as below. All the elements in options are optional. e.g.
array( 'GroupName' => array( 'RGName1', 'RGName2' ), 'Path' => '/opt/sequoiadb/backup', 'Name' => 'backupName' )
GroupName : Assign the backups of specifed replica groups to be list
Path : Assign the backups in specifed path to be list, if not assign, use the backup path asigned in the configuration file
Name : Assign the backups with specifed name to be list
$conditionan array or the string argument. The matching rule, return all the record if null.
$selectoran array or the string argument. The selective rule, return the whole record if null.
$orderByan array or the string argument. The ordered rule, never sort if null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listBackup( array( 'Name' => 'myBackup_1' ) ) ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listBackup, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listCL ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List all collection of current database(not include temporary collection of temporary collection space)

Parameters
$conditionan array or the string argument. This parameter is reserved and must be null.
$selectoran array or the string argument. This parameter is reserved and must be null.
$orderByan array or the string argument. This parameter is reserved and must be null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listCL() ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listCL, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listCollections ( )

List all collection of current database(not include temporary collection of temporary collection space)

See Also
listCL().
Deprecated:
This function is deprecated, use the function listCL() instead.
SequoiaDB::listCS ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List all collection space of current database(include temporary collection space)

Parameters
$conditionan array or the string argument. This parameter is reserved and must be null.
$selectoran array or the string argument. This parameter is reserved and must be null.
$orderByan array or the string argument. This parameter is reserved and must be null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listCS() ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listCS, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listCSs ( )

Get the specified list.

See Also
listCS().
Deprecated:
This function is deprecated, use the function listCS() instead.
SequoiaDB::listDomain ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List the domain.

Parameters
$conditionan array or the string argument. The matching rule, return all the record if null.
$selectoran array or the string argument. The selective rule, return the whole record if null.
$orderByan array or the string argument. The The ordered rule, never sort if null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listDomain() ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listDomains, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listDomains ( )

List the domain.

See Also
listDomain().
Deprecated:
This function is deprecated, use the function listDomain() instead.
SequoiaDB::listGroup ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List all the replica groups of current database.

Parameters
$conditionan array or the string argument. This parameter is reserved and must be null.
$selectoran array or the string argument. This parameter is reserved and must be null.
$orderByan array or the string argument. This parameter is reserved and must be null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listGroup() ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listGroup, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listProcedure ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List store procedures.

Parameters
$conditionan array or the string argument. The condition of list.
$selectoran array or the string argument. This parameter is reserved and must be null.
$orderByan array or the string argument. This parameter is reserved and must be null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listProcedure( array( 'name' => 'sum' ) ) ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listProcedure, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::listTask ( array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

List the tasks.

Parameters
$conditionan array or the string argument. The matching rule, return all the record if null.
$selectoran array or the string argument. The selective rule, return the whole record if null.
$orderByan array or the string argument. The The ordered rule, never sort if null.
$hintan array or the string argument. The hint, automatically match the optimal hint if null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> listTask() ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call listTask, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::removeBackup ( array|string  $options)

Remove the backups.

Parameters
$optionsan array or the string argument. Contains configuration infomations for remove backups, list all the backups in the default backup path if null. The "options" contains 3 options as below. All the elements in options are optional. eg: array( 'GroupName' => array( 'RGName1', 'RGName2' ), 'Path' => '/opt/sequoiadb/backup', 'Name' => 'backupName' )
GroupName : Assign the backups of specifed replica groups to be list
Path : Assign the backups in specifed path to be list, if not assign, use the backup path asigned in the configuration file
Name : Assign the backups with specifed name to be list
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> removeBackup( array( 'Name' => 'myBackup_1' ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to remove backup, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::removeGroup ( string  $name)

Remove the specified replica group.

Parameters
$namethe string argument. The name of the replica group.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> removeGroup( 'myGroup' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to remove group, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::removeProcedure ( string  $name)

Remove a store procedure.

Parameters
$namethe string argument. The name of store procedure.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> removeProcedure( 'sum' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call removeProcedure, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::removeUser ( string  $userName,
string  $passwd 
)

Delete an account.

Parameters
$userNamethe string argument. The user name of the account.
$passwdthe string argument. The password of the account.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> removeUser( 'mike', '123456789' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to remove user, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::resetSnapshot ( array|string  $condition = null)

Reset the snapshot.

Parameters
$conditionan array or the string argument. The matching rule, usually specifies the node in sharding environment in standalone mode, this option is ignored
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> resetSnapshot() ;
if( $err['errno'] != 0 ) {
echo "Failed to reset snapshot, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::selectCS ( string  $name,
integer  $pageSize = 4096 
)

Get the specified collection space, if is not exist,will auto create.

Parameters
$namethe string argument. The collection space name.
$pageSizean integer argument. When the collection space is created, $pageSize into force. The $pageSize as below:
4096
8192
16384
32768
65536
Returns
Returns a new SequoiaCS object.
Return values
SequoiaCSObject
Deprecated:
This function is deprecated, use the function selectCS( string $name, array|string $options = NULL ) instead.

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cs = $db -> selectCS( 'foo', 4096 ) ;
if( empty( $cs ) ) {
$err = $db -> getError() ;
echo "Failed to call selectCS, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::selectCS ( string  $name,
array|string  $options = null 
)

Get the specified collection space, if is not exist,will auto create.

Parameters
$namethe string argument. The collection space name.
$optionsan array or the string argument. When the collection space is created, $options into force. The options specified by use. e.g.
array( 'PageSize' => 4096, 'Domain' => 'mydomain' )
PageSize : Assign the pagesize of the collection space
Domain : Assign which domain does current collection space belong to
Returns
Returns a new SequoiaCS object.
Return values
SequoiaCSObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cs = $db -> selectCS( 'foo', array( 'PageSize' => 4096 ) ) ;
if( empty( $cs ) ) {
$err = $db -> getError() ;
echo "Failed to call selectCS, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::selectCS ( string  $name,
integer  $pageSize = null 
)

Get the specified collection space, if is not exist,will auto create.

Parameters
$namethe string argument. The collection space name.
$pageSizean integer argument. Assign the pagesize of the collection space.
Returns
Returns a new SequoiaCS object.
Return values
SequoiaCSObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cs = $db -> selectCS( 'foo', 4096 ) ;
if( empty( $cs ) ) {
$err = $db -> getError() ;
echo "Failed to call selectCS, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::selectGroup ( string  $name)

Get the specified replica group.

See Also
getGroup().
Deprecated:
This function is deprecated, use the function getGroup() instead.
SequoiaDB::setSessionAttr ( array|string  $options)

Set the attributes of the session.

Parameters
$optionsan array or the string argument. The configuration options for session.The options are as below:
PreferedInstance : indicate which instance to respond read request in current session.
master => 'm' or 'M'
slave => 's' or 'S'
anyone => 'a' or 'A'
node1 => 1
node2 => 2
node3 => 3
node4 => 4
node5 => 5
node6 => 6
node7 => 7
e.g. array( 'PreferedInstance' => 'm' ).
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> setSessionAttr( array( 'PreferedInstance' => 'm' ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call setSessionAttr, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::snapshot ( integer  $type,
array|string  $condition = null,
array|string  $selector = null,
array|string  $orderBy = null,
array|string  $hint = null 
)

Get the snapshot.

Parameters
$typean integer argument. The snapshot type as below:
$conditionan array or the string argument. The matching rule, match all the documents if null.
$selectoran array or the string argument. The selective rule, return the whole document if null.
$orderByan array or the string argument. The ordered rule, never sort if null.
$hintan array or the string argument. This parameter is reserved and must be null.
Returns
Returns a new SequoiaCursor object.
Return values
SequoiaCursorObject

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cursor = $db -> snapshot( SDB_SNAP_CONTEXTS ) ;
if( empty( $cursor ) ) {
$err = $db -> getError() ;
echo "Failed to call snapshot, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaDB::transactionBegin ( )

Transaction begin.

Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cl = $db -> getCL( 'foo.bar' ) ;
if( empty( $cl ) ) {
$err = $db -> getError() ;
echo "Failed to call getCL, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionBegin() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionBegin, error code: ".$err['errno'] ;
return ;
}
$err = $cl -> insert( array( 'a' => 1 ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call insert, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionCommit() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionCommit, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::transactionCommit ( )

Transaction commit.

Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cl = $db -> getCL( 'foo.bar' ) ;
if( empty( $cl ) ) {
$err = $db -> getError() ;
echo "Failed to call getCL, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionBegin() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionBegin, error code: ".$err['errno'] ;
return ;
}
$err = $cl -> insert( array( 'a' => 1 ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call insert, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionCommit() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionCommit, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::transactionRollback ( )

Transaction rollback.

Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$cl = $db -> getCL( 'foo.bar' ) ;
if( empty( $cl ) ) {
$err = $db -> getError() ;
echo "Failed to call getCL, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionBegin() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionBegin, error code: ".$err['errno'] ;
return ;
}
$err = $cl -> insert( array( 'a' => 1 ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call insert, error code: ".$err['errno'] ;
return ;
}
$err = $db -> transactionRollback() ;
if( $err['errno'] != 0 ) {
echo "Failed to call transactionRollback, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::truncate ( string  $fullName)

Truncate the collection.

Parameters
$fullNamethe string argument. The collection full name.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> truncate( 'foo.bar' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to truncate the collection, error code: ".$err['errno'] ;
return ;
}
SequoiaDB::waitTask ( array|integer|SequoiaInt64  $taskID)

Remove the backups.

Parameters
$taskIDan array or an integer argument. The array of task id or the integer of task id ;
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example: array type

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> waitTask( array( 1, 2, new SequoiaInt64( '3' ) ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call waitTask, error code: ".$err['errno'] ;
return ;
}

Example: integer type

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> waitTask( 1 ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call waitTask, error code: ".$err['errno'] ;
return ;
}

Example: SequoiaInt64 type

$db = new SequoiaDB() ;
$err = $db -> connect( "192.168.1.10:11810" ) ;
if( $err['errno'] != 0 ) {
echo "Failed to connect database, error code: ".$err['errno'] ;
return ;
}
$err = $db -> waitTask( new SequoiaInt64( '1' ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call waitTask, error code: ".$err['errno'] ;
return ;
}

Member Data Documentation

const SequoiaDB::SDB_LIST_CL_IN_DOMAIN 12

Get the list of the collections in specified domain.

const SequoiaDB::SDB_LIST_COLLECTIONS 4

Get the list of the collections.

const SequoiaDB::SDB_LIST_COLLECTIONSPACES 5

Get the list of the collecion spaces.

const SequoiaDB::SDB_LIST_CONTEXTS 0

Get the list of the contexts.

const SequoiaDB::SDB_LIST_CONTEXTS_CURRENT 1

Get the list of current context.

const SequoiaDB::SDB_LIST_CS_IN_DOMAIN 11

Get the list of the collection spaces in specified domain.

const SequoiaDB::SDB_LIST_DOMAINS 9

Get the list of the domains ( only applicable in sharding env ).

const SequoiaDB::SDB_LIST_GROUPS 7

Get the list of the replica groups ( only applicable in sharding env ).

const SequoiaDB::SDB_LIST_SESSIONS 2

Get the list of the sessions.

const SequoiaDB::SDB_LIST_SESSIONS_CURRENT 3

Get the list of current session.

const SequoiaDB::SDB_LIST_SHARDS 8

Get the list of the stored procedures ( only applicable in sharding env ).

const SequoiaDB::SDB_LIST_STORAGEUNITS 6

Get the list of the storage units.

const SequoiaDB::SDB_LIST_TASKS 10

Get the list of the tasks ( only applicable in sharding env ).

const SequoiaDB::SDB_SNAP_CATALOG 8

Get the snapshot of the catalog.

const SequoiaDB::SDB_SNAP_COLLECTION 4

Get the snapshot of all the collections.

const SequoiaDB::SDB_SNAP_COLLECTIONSPACE 5

Get the snapshot of all the collection spaces.

const SequoiaDB::SDB_SNAP_CONTEXTS 0

Get the snapshot of all the contexts.

const SequoiaDB::SDB_SNAP_CONTEXTS_CURRENT 1

Get the snapshot of current context

const SequoiaDB::SDB_SNAP_DATABASE 6

Get the snapshot of the database.

const SequoiaDB::SDB_SNAP_SESSIONS 2

Get the snapshot of all the sessions.

const SequoiaDB::SDB_SNAP_SESSIONS_CURRENT 3

Get the snapshot of current session.

const SequoiaDB::SDB_SNAP_SYSTEM 7

Get the snapshot of the system.

const SequoiaDB::SDB_SNAP_TRANSACTION 10

Get the snapshot of all the transactions.

const SequoiaDB::SDB_SNAP_TRANSACTION_CURRENT 9

Get the snapshot of current transaction.


The documentation for this class was generated from the following files: