@@ -26,7 +26,7 @@ $ make install
26
26
27
27
## Test
28
28
29
- To run tests Taranool server and PHP/PECL package are requred.
29
+ To run tests Tarantool server and PHP/PECL package are requred.
30
30
31
31
``` sh
32
32
$ ./test-run.py
@@ -42,7 +42,7 @@ $ TARANTOOL_BOX_PATH=/path/to/tarantool/bin/tarantool ./test-run.py
42
42
43
43
## Installing from PEAR
44
44
45
- Tarantool-PHP Have it's own [ PEAR repository] ( https://tarantool.github.io/tarantool-php ) .
45
+ Tarantool-PHP has its own [ PEAR repository] ( https://tarantool.github.io/tarantool-php ) .
46
46
You may install it from PEAR with just a few commands:
47
47
48
48
```
@@ -66,7 +66,6 @@ Place it into project library path in your IDE.
66
66
## Configuration file
67
67
68
68
* ` tarantool.persistent ` - Enable persistent connections (don't close connections between sessions) (defaults: True, ** can't be changed in runtime** )
69
- * ` tarantool.con_per_host ` - Count of open connections to every Tarantool server to store (defaults: 5, ** can't be changed in runtime** )
70
69
* ` tarantool.timeout ` - Connection timeout (defaults: 10 seconds, can be changed in runtime)
71
70
* ` tarantool.retry_count ` - Count of retries for connecting (defaults: 1, can be changed in runtime)
72
71
* ` tarantool.retry_sleep ` - Sleep between connecting retries (defaults: 0.1 second, can be changed in runtime)
@@ -78,11 +77,10 @@ Place it into project library path in your IDE.
78
77
79
78
1 . [ Predefined Constants] ( #predefined-constants )
80
79
2 . [ Class Tarantool] ( #class-tarantool )
81
- * [ Tarantool::_ construct ] ( #tarantool__construct )
80
+ * [ Tarantool::__ construct ] ( #tarantool__construct )
82
81
3 . [ Manipulation connection] ( #manipulation-connection )
83
82
* [ Tarantool::connect] ( #tarantoolconnect )
84
83
* [ Tarantool::disconnect] ( #tarantooldisconnect )
85
- * [ Tarantool::authenticate] ( #tarantoolauthenticate )
86
84
* [ Tarantool::flushSchema] ( #tarantoolflushschema )
87
85
* [ Tarantool::ping] ( #tarantoolping )
88
86
4 . [ Database queries] ( #database-queries )
@@ -98,45 +96,44 @@ Place it into project library path in your IDE.
98
96
99
97
_ ** Description** _ : Available Tarantool Constants
100
98
101
- * ` TARANTOOL_ITER_EQ ` - Equality iterator (ALL)
102
- * ` TARANTOOL_ITER_REQ ` - Reverse equality iterator
103
- * ` TARANTOOL_ITER_ALL ` - Get all rows
104
- * ` TARANTOOL_ITER_LT ` - Less then iterator
105
- * ` TARANTOOL_ITER_LE ` - Less and equal iterator
106
- * ` TARANTOOL_ITER_GE ` - Greater and equal iterator
107
- * ` TARANTOOL_ITER_GT ` - Gtreater then iterator
108
- * ` TARANTOOL_ITER_BITSET_ALL_SET ` - check if all given bits are set (BITSET only)
109
- * ` TARANTOOL_ITER_BITSET_ANY_SET ` - check if any given bits are set (BITSET only)
110
- * ` TARANTOOL_ITER_BITSET_ALL_NOT_SET ` - check if all given bits are not set
99
+ * ` Tarantool::ITERATOR_EQ ` - Equality iterator (ALL)
100
+ * ` Tarantool::ITERATOR_REQ ` - Reverse equality iterator
101
+ * ` Tarantool::ITERATOR_ALL ` - Get all rows
102
+ * ` Tarantool::ITERATOR_LT ` - Less then iterator
103
+ * ` Tarantool::ITERATOR_LE ` - Less and equal iterator
104
+ * ` Tarantool::ITERATOR_GE ` - Greater and equal iterator
105
+ * ` Tarantool::ITERATOR_GT ` - Gtreater then iterator
106
+ * ` Tarantool::ITERATOR_BITS_ALL_SET ` - check if all given bits are set (BITSET only)
107
+ * ` Tarantool::ITERATOR_BITS_ANY_SET ` - check if any given bits are set (BITSET only)
108
+ * ` Tarantool::ITERATOR_BITS_ALL_NOT_SET ` - check if all given bits are not set
111
109
(BITSET only)
112
- * ` TARANTOOL_ITER_OVERLAPS ` - find dots in the n-dimension cube (RTREE only)
113
- * ` TARANTOOL_ITER_NEIGHBOR ` - find nearest dots (RTREE only)
110
+ * ` Tarantool::ITERATOR_OVERLAPS ` - find dots in the n-dimension cube (RTREE only)
111
+ * ` Tarantool::ITERATOR_NEIGHBOR ` - find nearest dots (RTREE only)
114
112
115
113
### Class Tarantool
116
114
117
115
``` php
118
116
Tarantool {
119
- public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 ] ] )
120
- public bool Tarantool::connect ( void )
121
- public bool Tarantool::disconnect ( void )
122
- public Tarantool::authenticate(string $login [, string $password = NULL ] )
123
- public bool Tarantool::flushSchema ( void )
124
- public bool Tarantool::ping ( void )
125
- public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int offset = 0 [, iterator = TARANTOOL_ITER_EQ ] ] ] ] ] )
126
- public array Tarantool::insert(mixed $space, array $tuple)
127
- public array Tarantool::replace(mixed $space, array $tuple)
128
- public array Tarantool::call(string $procedure [, mixed args])
129
- public array Tarantool::evaluate(string $expression [, mixed args])
130
- public array Tarantool::delete(mixed $space, mixed $key [, mixed $index])
131
- public array Tarantool::update(mixed $space, mixed $key, array $ops [, number $index] )
132
- public array Tarantool::upsert(mixed $space, mixed $key, array $ops [, number $index] )
117
+ public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
118
+ public bool Tarantool::connect ( void )
119
+ public bool Tarantool::disconnect ( void )
120
+ public bool Tarantool::flushSchema ( void )
121
+ public bool Tarantool::ping ( void )
122
+ public array Tarantool::select (mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $offset = 0 [, $iterator = Tarantool::ITERATOR_EQ ] ] ] ] ] )
123
+ public array Tarantool::insert (mixed $space, array $tuple)
124
+ public array Tarantool::replace (mixed $space, array $tuple)
125
+ public array Tarantool::call (string $procedure [, mixed args] )
126
+ public array Tarantool::evaluate (string $expression [, mixed args] )
127
+ public array Tarantool::delete (mixed $space, mixed $key [, mixed $index] )
128
+ public array Tarantool::update (mixed $space, mixed $key, array $ops [, number $index] )
129
+ public array Tarantool::upsert (mixed $space, mixed $key, array $ops [, number $index] )
133
130
}
134
131
```
135
132
136
- #### Taratnool ::__ construct
133
+ #### Tarantool ::__ construct
137
134
138
135
```
139
- public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 ] ] )
136
+ public Tarantool::__construct ( [ string $host = 'localhost' [, int $port = 3301 [, string $user = "guest" [, string $password = NULL [, string $persistent_id = NULL ] ] ] ] ] )
140
137
```
141
138
142
139
_ ** Description** _ : Creates a Tarantool client
@@ -145,6 +142,10 @@ _**Parameters**_
145
142
146
143
* ` host ` : string, default is ` 'localhost' `
147
144
* ` port ` : number, default is ` 3301 `
145
+ * ` user ` : string, default is ` 'guest' `
146
+ * ` password ` : string
147
+ * ` persistent_id ` : string (set it, and connection will be persistent, if
148
+ ` persistent ` in config isn't set)
148
149
149
150
_ ** Return Value** _
150
151
@@ -187,36 +188,6 @@ _**Return Value**_
187
188
188
189
** BOOL** : True
189
190
190
- ### Tarantool::authenticate
191
-
192
- ``` php
193
- public Tarantool::authenticate(string $login [, string $password = NULL ] )
194
- ```
195
-
196
- _ ** Description** _ : Authenticate to Tarantool using given login/password
197
-
198
- _ ** Parameters** _
199
-
200
- * ` login ` : string - user login (mandatory)
201
- * ` password ` : string - user password (mandatory, but ignored, if user is guest)
202
-
203
- _ ** Return Value** _ NULL
204
-
205
- #### * Example*
206
-
207
- ``` php
208
- /**
209
- * - user is 'valdis'
210
- * - password is 'pelsh'
211
- */
212
- $tnt->connect('valdis', 'pelsh')
213
- /**
214
- * - user is 'guest'
215
- * - password is empty and ignored, anyway
216
- */
217
- $tnt->connect('guest')
218
- ```
219
-
220
191
### Tarantool::flushSchema
221
192
222
193
``` php
@@ -248,7 +219,7 @@ Throws `Exception` on error.
248
219
### Tarantool::select
249
220
250
221
``` php
251
- public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int offset = 0 [, iterator = TARANTOOL_ITER_EQ ] ] ] ] ] )
222
+ public array Tarantool::select(mixed $space [, mixed $key = array() [, mixed $index = 0 [, int $limit = PHP_INT_MAX [, int $ offset = 0 [, $ iterator = Tarantool::ITERATOR_EQ ] ] ] ] ] )
252
223
```
253
224
254
225
_ ** Description** _ : Execute select query from Tarantool server.
@@ -262,7 +233,11 @@ _**Parameters**_
262
233
* ` limit ` : Number, limit number of rows to return from select (INT_MAX by default)
263
234
* ` offset ` : Number, offset to select from (0 by default)
264
235
* ` iterator ` : Constant, iterator type. See [ Predefined Constants] ( #predefined-constants )
265
- for more information (` TARANTOOL_ITER_EQ ` by default)
236
+ for more information (` Tarantool::ITERATOR_EQ ` by default). You can also use
237
+ strings ` 'eq' ` , ` 'req' ` , ` 'all' ` , ` 'lt' ` , ` 'le' ` , ` 'ge' ` , ` 'gt' ` ,
238
+ ` 'bits_all_set' ` , ` 'bits_any_set' ` , ` 'bits_all_not_set' ` , ` 'overlaps' ` ,
239
+ ` 'neighbor' ` , ` 'bits_all_set' ` , ` 'bits_any_set' ` , ` 'bits_all_not_set' ` (in
240
+ both lowercase/uppercase) instead of constants
266
241
267
242
_ ** Return Value** _
268
243
@@ -274,19 +249,19 @@ request, or empty array, if nothing was found.
274
249
#### Example
275
250
276
251
``` php
277
- /* Select everything from space 'test' */
252
+ // Select everything from space 'test'
278
253
$tnt->select("test");
279
- /* Selects from space 'test' by PK with id == 1*/
254
+ // Selects from space 'test' by PK with id == 1
280
255
$tnt->select("test", 1);
281
- /* The same as previous */
256
+ // The same as previous
282
257
$tnt->select("test", array(1));
283
- /* Selects from space 'test' by secondary key from index 'isec' and == {1, 'hello'} */
258
+ // Selects from space 'test' by secondary key from index 'isec' and == {1, 'hello'}
284
259
$tnt->select("test", array(1, "hello"), "isec");
285
- /* Selects second hundred of rows from space test */
260
+ // Selects second hundred of rows from space test
286
261
$tnt->select("test", null, null, 100, 100);
287
- /* Selects second hundred of rows from space test in reverse equality order */
288
- /* It meanse: select penultimate hundred */
289
- $tnt->select("test", null, null, 100, 100, TARANTOOL_ITER_REQ );
262
+ // Selects second hundred of rows from space test in reverse equality order
263
+ // It meanse: select penultimate hundred
264
+ $tnt->select("test", null, null, 100, 100, Tarantool::ITERATOR_REQ );
290
265
```
291
266
292
267
### Tarantool::insert, Tarantool::replace
@@ -312,12 +287,12 @@ _**Return Value**_
312
287
#### Example
313
288
314
289
``` php
315
- /* It'll be processed OK, since no tuples with PK == 1 are in space 'test' */
290
+ // It'll be processed OK, since no tuples with PK == 1 are in space 'test'
316
291
$tnt->insert("test", array(1, 2, "smth"));
317
- /* We've just inserted tuple with PK == 1, so it'll fail */
318
- /* error will be ER_TUPLE_FOUND */
292
+ // We've just inserted tuple with PK == 1, so it'll fail
293
+ // error will be ER_TUPLE_FOUND
319
294
$tnt->insert("test", array(1, 3, "smth completely different"));
320
- /* But it won't be a problem for replace */
295
+ // But it won't be a problem for replace
321
296
$tnt->replace("test", array(1, 3, "smth completely different"));
322
297
```
323
298
@@ -396,11 +371,11 @@ _**Return Value**_
396
371
#### Example
397
372
398
373
``` php
399
- /* Following code will delete all tuples from space `test` */
374
+ // Following code will delete all tuples from space `test`
400
375
$tuples = $tnt->select("test");
401
376
foreach($tuples as $value) {
402
- $tnt->delete("test", Array ($value[0]));
403
- }
377
+ $tnt->delete("test", array ($value[0]));
378
+ }
404
379
```
405
380
406
381
### Tarantool::update
@@ -516,7 +491,7 @@ $tnt->update("test", 1, array(
516
491
array(
517
492
"field" => 4,
518
493
"op" => "=",
519
- "arg" => intval( 0x11111)
494
+ "arg" => 0x11111,
520
495
),
521
496
));
522
497
$tnt->update("test", 1, array(
@@ -528,21 +503,21 @@ $tnt->update("test", 1, array(
528
503
array(
529
504
"field" => 4,
530
505
"op" => "& ",
531
- "arg" => intval( 0x10101)
506
+ "arg" => 0x10101,
532
507
)
533
508
));
534
509
$tnt->update("test", 1, array(
535
510
array(
536
511
"field" => 4,
537
512
"op" => "^",
538
- "arg" => intval( 0x11100)
513
+ "arg" => 0x11100,
539
514
)
540
515
));
541
516
$tnt->update("test", 1, array(
542
517
array(
543
518
"field" => 4,
544
519
"op" => "|",
545
- "arg" => intval( 0x00010)
520
+ "arg" => 0x00010,
546
521
)
547
522
));
548
523
$tnt->update("test", 1, array(
@@ -559,7 +534,7 @@ $tnt->update("test", 1, array(
559
534
### Tarantool::upsert
560
535
561
536
``` php
562
- public array Tarantool::upsert(mixed $space, mixed $key , array $ops [, number $index] )
537
+ public array Tarantool::upsert(mixed $space, array $tuple , array $ops [, number $index] )
563
538
```
564
539
565
540
_ ** Description** _ : Update or Insert command (If tuple with PK == PK('tuple') exists,
@@ -590,3 +565,10 @@ $tnt->upsert("test", array(124, 10, "new tuple"), array(
590
565
)
591
566
));
592
567
```
568
+
569
+
570
+ ## Deprecated
571
+
572
+ * Global constants, e.g. ` TARANTOOL_ITER_<name> `
573
+ * ` Tarantool::authenticate ` method
574
+ * configuration parameter: ` tarantool.con_per_host `
0 commit comments