SequoiaDB
 All Classes Files Functions Variables Pages
Public Member Functions | List of all members
SequoiaCS Class Reference

Public Member Functions

 drop ()
 
 getName ()
 
 selectCL (string $name, array|string $options=null)
 
 createCL (string $name, array|string $options=null)
 
 getCL (string $name)
 
 listCL ()
 
 dropCL (string $name)
 
 renameCL (string $oldName, string $newName, array|string $options=null)
 
 alter (array|string $options)
 
 setDomain (array|string $options)
 
 getDomainName ()
 
 removeDomain ()
 
 enableCapped ()
 
 disableCapped ()
 
 setAttributes (array|string $options)
 
 selectCollection (string $name, array|string $options=NULL)
 
 dropCollection (string $name)
 

Detailed Description

SequoiaCS Class. To get this Class object must be call SequoiaDB::selectCS or SequoiaDB::getCS.

Class for create an object of the collection space

Member Function Documentation

SequoiaCS::alter ( array|string  $options)

Alter the specified collection space.

Parameters
$optionsthe array or string argument. The options to alter.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $cs -> alter( array( 'PageSize' => 4096 ) ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::createCL ( string  $name,
array|string  $options = null 
)

Create the specified collection.

Parameters
$namethe string argument. The collection name.
$optionsThe options are as following:
ShardingKey : Assign the sharding key, foramt: { ShardingKey: { <key name>: <1/-1>} },
1 indicates positive order, -1 indicates reverse order.
e.g. array( "ShardingKey" => array( "a" => 1 ) )
ShardingType : Assign the sharding type, default is "hash"
Partition : The number of partition, it is valid when ShardingType is "hash",
the range is [2^3, 2^20], default is 4096
ReplSize : Assign how many replica nodes need to be synchronized when a write
request (insert, update, etc) is executed, default is 1
Compressed : Whether to enable data compression, default is true
CompressionType : The compression type of data, could be "snappy" or "lzw", default is "lzw"
AutoSplit : Whether to enable the automatic partitioning, it is valid when ShardingType
is "hash", defalut is false
Group : Assign the data group to which it belongs, default: The collection will
be created in any data group of the domain that the collection belongs to
AutoIndexId : Whether to build "$id" index, default is true
EnsureShardingIndex : Whether to build sharding index, default is true
StrictDataMode : Whether to enable strict date mode in numeric operations, default is false
AutoIncrement : Assign attributes of an autoincrement field or batch autoincrement fields
e.g. array( "AutoIncrement" => array( "Field" => "a", "MaxValue" => 2000 ) ),
array( "AutoIncrement" => array( array( "Field" => "a", "MaxValue" => 2000 ), array( "Field" => "a", "MaxValue" => 4000 ) ) )
LobShardingKeyFormat : Assign the format of lob sharding key, could be "YYYYMMDD", "YYYYMM" or "YYYY".
It is valid when the collection is main collection
IsMainCL : Main collection or not, default is false, which means it is not main collection
DataSource : The name of the date soure used
Mapping : The name of the collection to be mapped
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $cs -> createCL( 'bar', array( 'Compressed' => true ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create collection, error code: ".$err['errno'] ;
return ;
}

Example: create auto increment collection

$err = $cs -> createCL( 'bar', array( 'AutoIncrement' => array( 'Field' => 'a', 'MaxValue' => 20000 ) ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to create collection, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::disableCapped ( )

Alter the specified collection space to disable capped.

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

Example:

$err = $cs -> disableCapped() ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::drop ( )

Drop collection space.

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

Example:

$err = $cs -> drop() ;
if( $err['errno'] != 0 ) {
echo "Failed to drop collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::dropCL ( string  $name)

Drop the specified collection.

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

Example:

$err = $cs -> dropCL( 'bar' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to drop collection, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::dropCollection ( string  $name)

Drop the specified collection.

See Also
dropCL().
Deprecated:
This function is deprecated, use the function dropCL() instead.
SequoiaCS::enableCapped ( )

Alter the specified collection space to enable capped.

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

Example:

$err = $cs -> enableCapped() ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::getCL ( string  $name)

Get the specified collection.

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

Example:

$cl = $cs -> getCL( 'bar' ) ;
if( empty( $cl ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to call getCL, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::getDomainName ( )

Get the Domain name of current collection space.

Returns
Returns the domain name ( If the collection space does not belong to any domain, return "" ) on success, or NULL on failure.
Return values
string<domain_name> or NULL

Example:

$domainName = $cs -> getDomainName() ;
if( $domainName === NULL ) {
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get collection space name, error code: ".$err['errno'] ;
return ;
}
echo "Domain name is: ".$domainName ;
SequoiaCS::getName ( )

Get the specified collection space name.

Returns
Returns the collection space name.
Return values
string<cs_name>

Example:

$csName = $cs -> getName() ;
$err = $db -> getLastErrorMsg() ;
if( $err['errno'] != 0 ) {
echo "Failed to get collection space name, error code: ".$err['errno'] ;
return ;
}
echo "Collection space name is: ".$csName ;
SequoiaCS::listCL ( )

List all collections in current collection space.

Returns
Returns SequoiaCursor object on success, or NULL on failure.
Return values
SequoiaCursorobject or NULL.

Example:

$cursor = $cs -> listCL() ;
if( empty( $cursor ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to call listCL, error code: ".$err['errno'] ;
return ;
}
while( $record = $cursor -> next() ) {
var_dump( $record ) ;
}
SequoiaCS::removeDomain ( )

Alter the specified collection space to remove domain.

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

Example:

$err = $cs -> removeDomain() ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::renameCL ( string  $oldName,
string  $newName,
array|string  $options = null 
)

Rename collection name

Parameters
$oldNameThe old collection name
$newNameThe new collection name
$optionsReserved
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $cs -> renameCL( 'bar', 'new_bar' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to rename collection, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::selectCL ( string  $name,
array|string  $options = null 
)

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

Parameters
$namethe string argument. The collection name.
$optionsan array or the string argument. Please reference here to get the $options's info of create collection.
Returns
Returns a new SequoiaCL object.
Return values
SequoiaCLObject

Example:

$cl = $cs -> selectCL( 'bar', array( 'Compressed' => true ) ) ;
if( empty( $cl ) ) {
$err = $db -> getLastErrorMsg() ;
echo "Failed to call selectCL, error code: ".$err['errno'] ;
return ;
}

Example: create auto increment collection

$err = $cs -> selectCL( 'bar', array( 'AutoIncrement' => array( 'Field' => 'a', 'MaxValue' => 20000 ) ) ) ;
if( $err['errno'] != 0 ) {
echo "Failed to call selectCL, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::selectCollection ( string  $name,
array|string  $options = NULL 
)

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

See Also
selectCL().
Deprecated:
This function is deprecated, use the function selectCL() instead.
SequoiaCS::setAttributes ( array|string  $options)

Alter the specified collection space.

Parameters
$optionsthe array or string argument. The options to alter.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $cs -> setAttributes( array( 'PageSize' => 4096 ) ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}
SequoiaCS::setDomain ( array|string  $options)

Alter the specified collection space to set domain.

Parameters
$optionsthe array or string argument. The options to alter.
Returns
Returns the result, default return array.
Return values
arrayarray( 'errno' => 0 )
string{ "errno": 0 }

Example:

$err = $cs -> setDomain( array( 'Domain' => 'domain' ) ;
if( $err['errno'] != 0 ) {
echo "Failed to alter collection space, error code: ".$err['errno'] ;
return ;
}

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