Skip to content

Commit

Permalink
添加整体案例
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanglei5 committed Dec 5, 2014
1 parent 0dc2610 commit d824a30
Showing 1 changed file with 23 additions and 0 deletions.
23 changes: 23 additions & 0 deletions doc/13.swoole_table.md
Original file line number Diff line number Diff line change
Expand Up @@ -165,3 +165,26 @@ lock/unlock之间的代码,应当try/catch避免抛出异常导致跳过unlock
```php
swoole_table->unlock()
```
## 整体使用案例
```php
$table = new swoole_table(1024);
$table->column('id', swoole_table::TYPE_INT, 4); //1,2,4,8
$table->column('name', swoole_table::TYPE_STRING, 64);
$table->column('num', swoole_table::TYPE_FLOAT);
$table->create();

$table->set('[email protected]', array('id' => 145, 'name' => 'rango', 'num' => 3.1415));
$table->set('[email protected]', array('id' => 358, 'name' => "Rango1234", 'num' => 3.1415));
$table->set('[email protected]', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));

$data = $table->get('[email protected]');
$table->del('[email protected]');
$table->lock();
/**
事务性处理。
**/
$table->unlock();

count($table); // 获得有多少条记录。
```
个人感觉如果要是可以获得table里所有的key就好了,因为get是要根据key来获取记录的。

0 comments on commit d824a30

Please sign in to comment.