Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Table->column(string $name, int $type, int $size = 0): bool
The name of the column
Data type of the column, one of OpenSwoole\Table::TYPE_INT
, OpenSwoole\Table::TYPE_STRING
, OpenSwoole\Table::TYPE_FLOAT
.
The size of the column
Define the schema and columns of a row in the table.
<?php
$table = new OpenSwoole\Table(1024);
$table->column('name', OpenSwoole\Table::TYPE_STRING, 64);
$table->column('id', OpenSwoole\Table::TYPE_INT, 4); //1,2,4,8
$table->column('num', OpenSwoole\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('[email protected]', array('id' => 3, 'name' => 'swoole', 'num' => 3.1415));
var_dump($table->get('a'));
var_dump($table->get('b', 'name'));