forked from mpremus/lmdb-php
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexample.php
572 lines (411 loc) · 13.1 KB
/
example.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
<?php
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 3.0.5
*
* This file is not intended to be easily readable and contains a number of
* coding conventions designed to improve portability and efficiency. Do not make
* changes to this file unless you know what you are doing--modify the SWIG
* interface file instead.
* ----------------------------------------------------------------------------- */
// Try to load our extension if it's not already loaded.
if (!extension_loaded('example')) {
if (strtolower(substr(PHP_OS, 0, 3)) === 'win') {
if (!dl('php_example.dll')) return;
} else {
// PHP_SHLIB_SUFFIX gives 'dylib' on MacOS X but modules are 'so'.
if (PHP_SHLIB_SUFFIX === 'dylib') {
if (!dl('example.so')) return;
} else {
if (!dl('example.'.PHP_SHLIB_SUFFIX)) return;
}
}
}
abstract class example {
const MDB_VERSION_MAJOR = MDB_VERSION_MAJOR;
const MDB_VERSION_MINOR = MDB_VERSION_MINOR;
const MDB_VERSION_PATCH = MDB_VERSION_PATCH;
const MDB_VERSION_FULL = MDB_VERSION_FULL;
const MDB_VERSION_DATE = MDB_VERSION_DATE;
const MDB_VERSION_STRING = MDB_VERSION_STRING;
const MDB_FIXEDMAP = MDB_FIXEDMAP;
const MDB_NOSUBDIR = MDB_NOSUBDIR;
const MDB_NOSYNC = MDB_NOSYNC;
const MDB_RDONLY = MDB_RDONLY;
const MDB_NOMETASYNC = MDB_NOMETASYNC;
const MDB_WRITEMAP = MDB_WRITEMAP;
const MDB_MAPASYNC = MDB_MAPASYNC;
const MDB_NOTLS = MDB_NOTLS;
const MDB_NOLOCK = MDB_NOLOCK;
const MDB_NORDAHEAD = MDB_NORDAHEAD;
const MDB_NOMEMINIT = MDB_NOMEMINIT;
const MDB_REVERSEKEY = MDB_REVERSEKEY;
const MDB_DUPSORT = MDB_DUPSORT;
const MDB_INTEGERKEY = MDB_INTEGERKEY;
const MDB_DUPFIXED = MDB_DUPFIXED;
const MDB_INTEGERDUP = MDB_INTEGERDUP;
const MDB_REVERSEDUP = MDB_REVERSEDUP;
const MDB_CREATE = MDB_CREATE;
const MDB_NOOVERWRITE = MDB_NOOVERWRITE;
const MDB_NODUPDATA = MDB_NODUPDATA;
const MDB_CURRENT = MDB_CURRENT;
const MDB_RESERVE = MDB_RESERVE;
const MDB_APPEND = MDB_APPEND;
const MDB_APPENDDUP = MDB_APPENDDUP;
const MDB_MULTIPLE = MDB_MULTIPLE;
const MDB_CP_COMPACT = MDB_CP_COMPACT;
const MDB_FIRST = 0;
const MDB_FIRST_DUP = MDB_FIRST_DUP;
const MDB_GET_BOTH = MDB_GET_BOTH;
const MDB_GET_BOTH_RANGE = MDB_GET_BOTH_RANGE;
const MDB_GET_CURRENT = MDB_GET_CURRENT;
const MDB_GET_MULTIPLE = MDB_GET_MULTIPLE;
const MDB_LAST = MDB_LAST;
const MDB_LAST_DUP = MDB_LAST_DUP;
const MDB_NEXT = MDB_NEXT;
const MDB_NEXT_DUP = MDB_NEXT_DUP;
const MDB_NEXT_MULTIPLE = MDB_NEXT_MULTIPLE;
const MDB_NEXT_NODUP = MDB_NEXT_NODUP;
const MDB_PREV = MDB_PREV;
const MDB_PREV_DUP = MDB_PREV_DUP;
const MDB_PREV_NODUP = MDB_PREV_NODUP;
const MDB_SET = MDB_SET;
const MDB_SET_KEY = MDB_SET_KEY;
const MDB_SET_RANGE = MDB_SET_RANGE;
const MDB_SUCCESS = MDB_SUCCESS;
const MDB_KEYEXIST = MDB_KEYEXIST;
const MDB_NOTFOUND = MDB_NOTFOUND;
const MDB_PAGE_NOTFOUND = MDB_PAGE_NOTFOUND;
const MDB_CORRUPTED = MDB_CORRUPTED;
const MDB_PANIC = MDB_PANIC;
const MDB_VERSION_MISMATCH = MDB_VERSION_MISMATCH;
const MDB_INVALID = MDB_INVALID;
const MDB_MAP_FULL = MDB_MAP_FULL;
const MDB_DBS_FULL = MDB_DBS_FULL;
const MDB_READERS_FULL = MDB_READERS_FULL;
const MDB_TLS_FULL = MDB_TLS_FULL;
const MDB_TXN_FULL = MDB_TXN_FULL;
const MDB_CURSOR_FULL = MDB_CURSOR_FULL;
const MDB_PAGE_FULL = MDB_PAGE_FULL;
const MDB_MAP_RESIZED = MDB_MAP_RESIZED;
const MDB_INCOMPATIBLE = MDB_INCOMPATIBLE;
const MDB_BAD_RSLOT = MDB_BAD_RSLOT;
const MDB_BAD_TXN = MDB_BAD_TXN;
const MDB_BAD_VALSIZE = MDB_BAD_VALSIZE;
const MDB_BAD_DBI = MDB_BAD_DBI;
const MDB_LAST_ERRCODE = MDB_LAST_ERRCODE;
static function mdb_version($major,$minor,$patch) {
return mdb_version($major,$minor,$patch);
}
static function mdb_strerror($err) {
return mdb_strerror($err);
}
static function mdb_env_copy($env,$path) {
return mdb_env_copy($env,$path);
}
static function mdb_env_copyfd($env,$fd) {
return mdb_env_copyfd($env,$fd);
}
static function mdb_env_copy2($env,$path,$flags) {
return mdb_env_copy2($env,$path,$flags);
}
static function mdb_env_copyfd2($env,$fd,$flags) {
return mdb_env_copyfd2($env,$fd,$flags);
}
static function mdb_env_sync($env,$force) {
return mdb_env_sync($env,$force);
}
static function mdb_env_close($env) {
mdb_env_close($env);
}
static function mdb_env_set_flags($env,$flags,$onoff) {
return mdb_env_set_flags($env,$flags,$onoff);
}
static function mdb_env_set_mapsize($env,$size) {
return mdb_env_set_mapsize($env,$size);
}
static function mdb_env_set_maxreaders($env,$readers) {
return mdb_env_set_maxreaders($env,$readers);
}
static function mdb_env_set_maxdbs($env,$dbs) {
return mdb_env_set_maxdbs($env,$dbs);
}
static function mdb_env_get_maxkeysize($env) {
return mdb_env_get_maxkeysize($env);
}
static function mdb_env_get_userctx($env) {
return mdb_env_get_userctx($env);
}
static function mdb_txn_env($txn) {
return mdb_txn_env($txn);
}
static function mdb_txn_id($txn) {
return mdb_txn_id($txn);
}
static function mdb_txn_commit($txn) {
return mdb_txn_commit($txn);
}
static function mdb_txn_abort($txn) {
mdb_txn_abort($txn);
}
static function mdb_txn_reset($txn) {
mdb_txn_reset($txn);
}
static function mdb_txn_renew($txn) {
return mdb_txn_renew($txn);
}
static function mdb_dbi_close($env,$dbi) {
mdb_dbi_close($env,$dbi);
}
static function mdb_drop($txn,$dbi,$del) {
return mdb_drop($txn,$dbi,$del);
}
static function mdb_get($txn,$dbi,$key,$data) {
return mdb_get($txn,$dbi,$key,$data);
}
static function mdb_put($txn,$dbi,$key,$data,$flags) {
return mdb_put($txn,$dbi,$key,$data,$flags);
}
static function mdb_del($txn,$dbi,$key,$data) {
return mdb_del($txn,$dbi,$key,$data);
}
static function mdb_cursor_close($cursor) {
mdb_cursor_close($cursor);
}
static function mdb_cursor_renew($txn,$cursor) {
return mdb_cursor_renew($txn,$cursor);
}
static function mdb_cursor_txn($cursor) {
return mdb_cursor_txn($cursor);
}
static function mdb_cursor_dbi($cursor) {
return mdb_cursor_dbi($cursor);
}
static function mdb_cursor_get($cursor,$key,$data,$op) {
return mdb_cursor_get($cursor,$key,$data,$op);
}
static function mdb_cursor_put($cursor,$key,$data,$flags) {
return mdb_cursor_put($cursor,$key,$data,$flags);
}
static function mdb_cursor_del($cursor,$flags) {
return mdb_cursor_del($cursor,$flags);
}
static function mdb_cmp($txn,$dbi,$a,$b) {
return mdb_cmp($txn,$dbi,$a,$b);
}
static function mdb_dcmp($txn,$dbi,$a,$b) {
return mdb_dcmp($txn,$dbi,$a,$b);
}
static function mdb_reader_list($env,$func,$ctx) {
return mdb_reader_list($env,$func,$ctx);
}
static function mdb_env_info($env) {
$r=mdb_env_info($env);
if (is_resource($r)) {
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
if (class_exists($c)) return new $c($r);
return new MDB_envinfo($r);
}
return $r;
}
static function mdb_env_stat($env) {
$r=mdb_env_stat($env);
if (is_resource($r)) {
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
if (class_exists($c)) return new $c($r);
return new MDB_stat($r);
}
return $r;
}
static function mdb_set_relctx($txn,$dbi,$value) {
return mdb_set_relctx($txn,$dbi,$value);
}
static function mdb_stat($txn,$dbi) {
$r=mdb_stat($txn,$dbi);
if (is_resource($r)) {
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
if (class_exists($c)) return new $c($r);
return new MDB_stat($r);
}
return $r;
}
static function mdb_reader_check($env) {
return mdb_reader_check($env);
}
static function mdb_cursor_count($cursor) {
return mdb_cursor_count($cursor);
}
static function mdb_dbi_flags($txn,$dbi) {
return mdb_dbi_flags($txn,$dbi);
}
static function mdb_env_set_userctx($env,$value) {
return mdb_env_set_userctx($env,$value);
}
static function mdb_env_get_userctx_swig($env) {
return mdb_env_get_userctx_swig($env);
}
static function mdb_env_get_flags($env) {
return mdb_env_get_flags($env);
}
static function mdb_env_get_path($env) {
return mdb_env_get_path($env);
}
static function mdb_env_get_fd($env) {
return mdb_env_get_fd($env);
}
static function mdb_env_get_maxreaders($env) {
return mdb_env_get_maxreaders($env);
}
static function mdb_env_create() {
return mdb_env_create();
}
static function mdb_env_open($env,$path,$flags,$mode) {
return mdb_env_open($env,$path,$flags,$mode);
}
static function mdb_txn_begin($env,$parent,$flags) {
return mdb_txn_begin($env,$parent,$flags);
}
static function mdb_dbi_open($txn,$name,$flags) {
return mdb_dbi_open($txn,$name,$flags);
}
static function mdb_cursor_open($txn,$dbi) {
return mdb_cursor_open($txn,$dbi);
}
static function mdb_val_create($value) {
$r=mdb_val_create($value);
if (is_resource($r)) {
$c=substr(get_resource_type($r), (strpos(get_resource_type($r), '__') ? strpos(get_resource_type($r), '__') + 2 : 3));
if (class_exists($c)) return new $c($r);
return new MDB_val($r);
}
return $r;
}
static function mdb_val_size($key) {
return mdb_val_size($key);
}
static function mdb_val_data($key) {
return mdb_val_data($key);
}
static function mdb_stat_psize($stat) {
return mdb_stat_psize($stat);
}
static function mdb_stat_depth($stat) {
return mdb_stat_depth($stat);
}
static function mdb_stat_branch_pages($stat) {
return mdb_stat_branch_pages($stat);
}
static function mdb_stat_leaf_pages($stat) {
return mdb_stat_leaf_pages($stat);
}
static function mdb_stat_overflow_pages($stat) {
return mdb_stat_overflow_pages($stat);
}
static function mdb_stat_entries($stat) {
return mdb_stat_entries($stat);
}
static function mdb_info_mapaddr($info) {
return mdb_info_mapaddr($info);
}
static function mdb_info_mapsize($info) {
return mdb_info_mapsize($info);
}
static function mdb_info_last_pgno($info) {
return mdb_info_last_pgno($info);
}
static function mdb_info_last_txnid($info) {
return mdb_info_last_txnid($info);
}
static function mdb_info_maxreaders($info) {
return mdb_info_maxreaders($info);
}
static function mdb_info_numreaders($info) {
return mdb_info_numreaders($info);
}
}
/* PHP Proxy Classes */
class MDB_val {
public $_cPtr=null;
protected $_pData=array();
function __set($var,$value) {
if ($var === 'mv_size') return MDB_val_mv_size_set($this->_cPtr,$value);
if ($var === 'mv_data') return MDB_val_mv_data_set($this->_cPtr,$value);
if ($var === 'thisown') return swig_example_alter_newobject($this->_cPtr,$value);
$this->_pData[$var] = $value;
}
function __get($var) {
if ($var === 'mv_size') return MDB_val_mv_size_get($this->_cPtr);
if ($var === 'mv_data') return MDB_val_mv_data_get($this->_cPtr);
if ($var === 'thisown') return swig_example_get_newobject($this->_cPtr);
return $this->_pData[$var];
}
function __isset($var) {
if (function_exists('MDB_val_'.$var.'_get')) return true;
if ($var === 'thisown') return true;
return array_key_exists($var, $this->_pData);
}
function __construct($res=null) {
if (is_resource($res) && get_resource_type($res) === '_p_MDB_val') {
$this->_cPtr=$res;
return;
}
$this->_cPtr=new_MDB_val();
}
}
class MDB_stat {
public $_cPtr=null;
protected $_pData=array();
function __set($var,$value) {
$func = 'MDB_stat_'.$var.'_set';
if (function_exists($func)) return call_user_func($func,$this->_cPtr,$value);
if ($var === 'thisown') return swig_example_alter_newobject($this->_cPtr,$value);
$this->_pData[$var] = $value;
}
function __get($var) {
$func = 'MDB_stat_'.$var.'_get';
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
if ($var === 'thisown') return swig_example_get_newobject($this->_cPtr);
return $this->_pData[$var];
}
function __isset($var) {
if (function_exists('MDB_stat_'.$var.'_get')) return true;
if ($var === 'thisown') return true;
return array_key_exists($var, $this->_pData);
}
function __construct($res=null) {
if (is_resource($res) && get_resource_type($res) === '_p_MDB_stat') {
$this->_cPtr=$res;
return;
}
$this->_cPtr=new_MDB_stat();
}
}
class MDB_envinfo {
public $_cPtr=null;
protected $_pData=array();
function __set($var,$value) {
$func = 'MDB_envinfo_'.$var.'_set';
if (function_exists($func)) return call_user_func($func,$this->_cPtr,$value);
if ($var === 'thisown') return swig_example_alter_newobject($this->_cPtr,$value);
$this->_pData[$var] = $value;
}
function __get($var) {
$func = 'MDB_envinfo_'.$var.'_get';
if (function_exists($func)) return call_user_func($func,$this->_cPtr);
if ($var === 'thisown') return swig_example_get_newobject($this->_cPtr);
return $this->_pData[$var];
}
function __isset($var) {
if (function_exists('MDB_envinfo_'.$var.'_get')) return true;
if ($var === 'thisown') return true;
return array_key_exists($var, $this->_pData);
}
function __construct($res=null) {
if (is_resource($res) && get_resource_type($res) === '_p_MDB_envinfo') {
$this->_cPtr=$res;
return;
}
$this->_cPtr=new_MDB_envinfo();
}
}
?>