Swoole\Table->column

4.x is outdated, please check the latest version 22.x


Latest version: pecl install openswoole-22.1.2

Declaration

<?php Swoole\Table->column(string $name, int $type, int $size = 0): bool

Parameters

name

The name of the column

type

Data type of the column, one of Swoole\Table::TYPE_INT, Swoole\Table::TYPE_STRING, Swoole\Table::TYPE_FLOAT.

size

The size of the column

Return

Description

Define the schema and columns of a row in the table.

Example

<?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('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'));
Last updated on August 31, 2022