Swoole\Table->column

Declaration

<?php
Swoole\Table->column(string $name, string $type [, int $size ])

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('id', Swoole\Table::TYPE_INT);
$table->column('name', Swoole\Table::TYPE_STRING, 64);
$table->column('num', Swoole\Table::TYPE_FLOAT);
$table->create();

$table['apple'] = array('id' => 145, 'name' => 'iPhone', 'num' => 3.1415);
$table['google'] = array('id' => 358, 'name' => "AlphaGo", 'num' => 3.1415);
$table['microsoft']['name'] = "Windows";
$table['microsoft']['num'] = '1997.03';

var_dump($table['apple']);
var_dump($table['microsoft']);
$table['google']['num'] = 500.90;
var_dump($table['google']);