Skip to content

Commit

Permalink
Update swoole_table examples (#4357)
Browse files Browse the repository at this point in the history
  • Loading branch information
sy-records authored Aug 9, 2021
1 parent 49e992e commit 29b6c2c
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 20 deletions.
18 changes: 0 additions & 18 deletions examples/table/array.php

This file was deleted.

2 changes: 1 addition & 1 deletion examples/table/server.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
$table->create();

$serv = new swoole_server('127.0.0.1', 9501);
$serv->set(['dispatch_mode' => 1]);
$serv->set(['dispatch_mode' => 2]);
$serv->table = $table;

$serv->on('connect', function($serv, $fd, $reactor_id){
Expand Down
2 changes: 1 addition & 1 deletion examples/table/simulation.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php
/**
* The script is used for simulating the usage of swoole_table() and guaranting its usability.
* The script is used for simulating the usage of swoole_table() and guarantying its usability.
*/
$table = new swoole_table(1024);
$table->column('name', swoole_table::TYPE_STRING, 64);
Expand Down
13 changes: 13 additions & 0 deletions examples/table/usage.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<?php
$table = new swoole_table(1024);
$table->column('id', swoole_table::TYPE_INT);
$table->column('name', swoole_table::TYPE_STRING, 64);
$table->column('num', swoole_table::TYPE_FLOAT);
$table->create();

$table->set('a', array('id' => 1, 'name' => 'swoole-co-uk', 'num' => 3.1415));
$table->set('b', array('id' => 2, 'name' => "swoole-uk", 'num' => 3.1415));
$table->set('hello@swoole.co.uk', array('id' => 3, 'name' => 'swoole', 'num' => 3.1415));

var_dump($table->get('a'));
var_dump($table->get('b', 'name'));

0 comments on commit 29b6c2c

Please sign in to comment.