| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Name | Name | Last commit date | ||
|---|---|---|---|---|
PECL PHP driver for Tarantool.
If you're looking for 1.5 version, check out branch 'stable'.
To build Tarantool PHP extenstion PHP-devel package is required. The package should contain phpize utility.
$ phpize
$ ./configure
$ make
$ make installTo run tests Tarantool server and PHP/PECL package are requred.
$ ./test-run.pyIt'll automaticly find and start Tarantool and, then, run phpunit.phar based tests. If Tarantool doesn't defined in PATH variable, you may define it in TARANTOOL_BOX_PATH enviroment variable.
$ TARANTOOL_BOX_PATH=/path/to/tarantool/bin/tarantool ./test-run.pyTarantool-PHP has its own PEAR repository. You may install it from PEAR with just a few commands:
pecl channel-discover tarantool.github.io/tarantool-php/pecl pecl install Tarantool-PHP/Tarantool-beta
For building packages - please, read README.PACK.md
Stubs can be found at tarantool/tarantool-php-stubs. Place it into project library path in your IDE.
Description: Available Tarantool Constants
Tarantool {
public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
public bool Tarantool::connect ( void )
public bool Tarantool::disconnect ( void )
public bool Tarantool::flushSchema ( void )
public bool Tarantool::ping ( void )
public array Tarantool::select (mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = Tarantool::ITERATOR_EQ ] ] ] ] ] )
public array Tarantool::insert (mixed $space, array $tuple)
public array Tarantool::replace (mixed $space, array $tuple)
public array Tarantool::call (string $procedure [, mixed args [, array $opts ] ] )
public array Tarantool::evaluate (string $expression [, mixed args] )
public array Tarantool::delete (mixed $space, mixed $key [, mixed $index] )
public array Tarantool::update (mixed $space, mixed $key, array $ops [, number $index] )
public array Tarantool::upsert (mixed $space, mixed $key, array $ops [, number $index] )
}public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
Description: Creates a Tarantool client
Parameters
Return Value
Tarantool class instance
$tnt = new Tarantool(); // -> new Tarantool('localhost', 3301);
$tnt = new Tarantool('tarantool.org'); // -> new Tarantool('tarantool.org', 3301);
$tnt = new Tarantool('localhost', 16847);public bool Tarantool::connect ( void )Description: Explicit connect to Tarantool Server. If not used, then connection will be opened on demand.
Return Value
BOOL: True on success Raises Exception if can't connect to Tarantool.
public bool Tarantool::disconnect ( void )Description: Explicitly close connection to Tarantool Server. If you're using persistent connections, then it'll be saved to connection pool.
Return Value
BOOL: True
public bool Tarantool::flushSchema ( void )Description: Remove space/index schema from client.
Return Value
BOOL: True
public bool Tarantool::ping ( void )Description: Ping Tarantool server.
Return Value
BOOL: True
Throws Exception on error.
public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = Tarantool::ITERATOR_EQ ] ] ] ] ] )Description: Execute select query from Tarantool server.
Parameters
Return Value
Array of arrays: in case of success - list of tuples that satisfy your request, or empty array, if nothing was found.
BOOL: False and raises Exception in case of error.
// Select everything from space 'test'
$tnt->select("test");
// Selects from space 'test' by PK with id == 1
$tnt->select("test", 1);
// The same as previous
$tnt->select("test", array(1));
// Selects from space 'test' by secondary key from index 'isec' and == {1, 'hello'}
$tnt->select("test", array(1, "hello"), "isec");
// Selects second hundred of rows from space test
$tnt->select("test", null, null, 100, 100);
// Selects second hundred of rows from space test in reverse equality order
// It meanse: select penultimate hundred
$tnt->select("test", null, null, 100, 100, Tarantool::ITERATOR_REQ);public array Tarantool::insert(mixed $space, array $tuple)
public array Tarantool::replace(mixed $space, array $tuple)Description: Insert (if not exists query with same PK) or Replace tuple.
Parameters
Return Value
Array in case of success - tuple that was inserted into Tarantool.
BOOL: False and raises Exception in case of error.
// It'll be processed OK, since no tuples with PK == 1 are in space 'test'
$tnt->insert("test", array(1, 2, "smth"));
// We've just inserted tuple with PK == 1, so it'll fail
// error will be ER_TUPLE_FOUND
$tnt->insert("test", array(1, 3, "smth completely different"));
// But it won't be a problem for replace
$tnt->replace("test", array(1, 3, "smth completely different"));public array Tarantool::call(string $procedure [, mixed args [, array $opts]])Description: Call stored procedure
Parameters
Options
array( "call_16" => <bool> ),
Return Value
BOOL: False and raises Exception in case of error.
call_16 mode (default):
Array of arrays in case of success - tuples that were returned by stored procedure.
call_17 mode:
Any value, that was returned by stored procedure.
$tnt->call("test_2");
$tnt->call("test_3", array(3, 4), array('call_16' => false));public array Tarantool::evaluate(string $expression [, mixed args])Description: Evaluate given lua code (demands current user to have 'execute' rights for 'universe' in Tarantool)
Parameters
Return Value
Any value, that was returned from evaluated code.
BOOL: False and raises Exception in case of error.
$tnt->eval("return test_2()");
$tnt->eval("return test_3(...)", array(3, 4));
$tnt->evaluate("return test_3(...)", array(3, 4));public array Tarantool::delete(mixed $space, mixed $key [, mixed $index])Description: Delete record with given key.
Parameters
Return Value
Array in case of success - tuple that was deleted by query.
BOOL: False and raises Exception in case of error.
// Following code will delete all tuples from space `test`
$tuples = $tnt->select("test");
foreach($tuples as $value) {
$tnt->delete("test", array($value[0]));
}public array Tarantool::update(mixed $space, mixed $key, array $ops [, number $index] )Description: Update record with given key (update in Tarantool is apply multiple given operations to tuple)
Parameters
Operations
<serializable> - any simple type which converts to MsgPack (scalar/array).
array( "field" => <number>, "op" => ":", "offset"=> <number>, "length"=> <number>, "list" => <string> ),
array(
"field" => <number>,
"op" => ("+"|"-"|"&"|"^"|"|"),
"arg" => <number>
),
array( "field" => <number>, "op" => "#", "arg" => <number> )
array(
"field" => <number>,
"op" => ("="|"!"),
"arg" => <serializable>
)
array(
array(
"field" => <number>,
"op" => ":",
"offset"=> <number>,
"length"=> <number>,
"list" => <string>
),
array(
"field" => <number>,
"op" => ("+"|"-"|"&"|"^"|"|"),
"arg" => <number>
),
array(
"field" => <number>,
"op" => "#",
"arg" => <number>
),
array(
"field" => <number>,
"op" => ("="|"!"),
"arg" => <serializable>
)
)
Return Value
Array in case of success - tuple after it was updated.
BOOL: False and raises Exception in case of error.
$tnt->update("test", 1, array(
array(
"field" => 1,
"op" => "+",
"arg" => 16
),
array(
"field" => 3,
"op" => "=",
"arg" => 98
),
array(
"field" => 4,
"op" => "=",
"arg" => 0x11111,
),
));
$tnt->update("test", 1, array(
array(
"field" => 3,
"op" => "-",
"arg" => 10
),
array(
"field" => 4,
"op" => "&",
"arg" => 0x10101,
)
));
$tnt->update("test", 1, array(
array(
"field" => 4,
"op" => "^",
"arg" => 0x11100,
)
));
$tnt->update("test", 1, array(
array(
"field" => 4,
"op" => "|",
"arg" => 0x00010,
)
));
$tnt->update("test", 1, array(
array(
"field" => 2,
"op" => ":",
"offset" => 2,
"length" => 2,
"list" => "rrance and phillipe show"
)
));public array Tarantool::upsert(mixed $space, array $tuple, array $ops [, number $index] )Description: Update or Insert command (If tuple with PK == PK('tuple') exists, then it'll update this tuple with 'ops', otherwise 'tuple' will be inserted)
Parameters
Return Value
Nothing. In simple cases - it mustn't throw errors and returns nothing, but sometimes it'll, check out documentation
BOOL: False and raises Exception in case of error.
$tnt->upsert("test", array(124, 10, "new tuple"), array(
array(
"field" => 1,
"op" => "+",
"arg" => 10
)
));| Back | FazBrowse Home | New Git URL |