-
Notifications
You must be signed in to change notification settings - Fork 3.2k
/
Copy pathiterator.php
33 lines (29 loc) · 1.19 KB
/
iterator.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
<?php
$table = new Swoole\Table(1024);
$table->column('name', Swoole\Table::TYPE_STRING, 64);
$table->column('id', Swoole\Table::TYPE_INT, 4); //1,2,4,8
$table->column('num', Swoole\Table::TYPE_FLOAT);
$table->create();
$table->set('[email protected]', array('id' => 145, 'name' => 'rango1', 'num' => 3.1415));
$table->set('[email protected]', array('id' => 358, 'name' => "Rango2", 'num' => 3.1415));
$table->set('[email protected]', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));
var_dump($table->get('[email protected]'));
var_dump($table->get('[email protected]', 'name'));
foreach($table as $key => $value)
{
var_dump($key, $value);
}
echo "======================= Total Elements: {$table->count()} ============================\n";
$table->del('[email protected]'); // delete a exist element
foreach($table as $key => $value)
{
var_dump($key, $value);
}
echo "======================= Total Elements: {$table->count()} ============================\n";
$ret = $table->del('a invalid key'); // delete a invalid element
var_dump($ret);
foreach($table as $key => $value)
{
var_dump($key, $value);
}
echo "======================= Total Elements: {$table->count()} ============================\n";