swoole_table->set

设置行的数据,swoole_table使用key-value的方式来访问数据。

swoole_table->set(string $key, array $array)

swoole_table->set() 可以设置全部字段的值,也可以只修改部分字段
swoole_table->set() 未设置前,该行数据的所有字段均为空
set/get/del 是自带行锁,所以不需要调用lock加锁

$table->set('tianfenghan@qq.com', array('id' => 145, 'name' => 'rango', 'num' => 3.1415));
$table->set('350749960@qq.com', array('id' => 358, 'name' => "Rango1234", 'num' => 3.1415));
$table->set('hello@qq.com', array('id' => 189, 'name' => 'rango3', 'num' => 3.1415));

设置超过最大长度字符串

如果传入字符串长度超过了列定义时设定的最大尺寸,底层会自动截断。

示例:

$table->column('str_value', swoole_table::TYPE_STRING, 5);
$table->set('hello', array('str_value' => 'world 123456789'));