class JsonColumn

This class provides static functions to update the definition of columns in a JsonSQL database

Methods

static void
add(Engine $engine, string $table, string $column, stdClass $columnDef, array $required = array())

Adds a column in a table of the database

static void
rename(Engine $engine, $table, $column, $newname)

Renames a column

static void
drop(Engine $engine, string $table, string $column, bool $ifexists = false)

Drops a column

static void
setType(Engine $engine, $table, $column, $type, $format = '', $datatype = '')

Changes the type of a column

static void
setNotNull(Engine $engine, string $table, string $column, bool $allownull = false)

Changes whether a column is marked to allow null values or to reject null values

static void
setDefault(Engine $engine, string $table, string $column, string|bool $default = false)

Set or remove the default value for a column.

static void
setPrimaryKey(Engine $engine, string $table, string $column, bool $remove = false)

Set or remove primary key for a column.

static void
setAutoincrement(Engine $engine, string $table, string $column, bool $remove = false)

Set or remove autoincrement for a column.

static void
setTitle(Engine $engine, string $table, string $column, string|bool $title = false)

Set or remove the title of a column.

static void
setDescription(Engine $engine, string $table, string $column, string|bool $description = false)

Set or remove the description of a column.

static void
checkColumn(Engine $engine, string $table, string $column)

Checks the existence of a column

Details

at line 50
static void add(Engine $engine, string $table, string $column, stdClass $columnDef, array $required = array())

Adds a column in a table of the database

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The name of the new column
stdClass $columnDef The column definition
array $required An array with the column name if required

Return Value

void

Exceptions

JsonSQLException

at line 82
static void rename(Engine $engine, $table, $column, $newname)

Renames a column

Parameters

Engine $engine
$table
$column
$newname

Return Value

void

Exceptions

JsonSQLException

at line 112
static void drop(Engine $engine, string $table, string $column, bool $ifexists = false)

Drops a column

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name to drop in the table
bool $ifexists if true, don't throw an error if the table or the column doesn't exists

Return Value

void

Exceptions

JsonSQLException

at line 148
static void setType(Engine $engine, $table, $column, $type, $format = '', $datatype = '')

Changes the type of a column

Parameters

Engine $engine
$table
$column
$type
$format
$datatype

Return Value

void

Exceptions

JsonSQLException

at line 374
static void setNotNull(Engine $engine, string $table, string $column, bool $allownull = false)

Changes whether a column is marked to allow null values or to reject null values

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
bool $allownull if true, the column allow null value

Return Value

void

Exceptions

JsonSQLException

at line 405
static void setDefault(Engine $engine, string $table, string $column, string|bool $default = false)

Set or remove the default value for a column.

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
string|bool $default The default value. If false, remove the default

Return Value

void

Exceptions

JsonSQLException

at line 432
static void setPrimaryKey(Engine $engine, string $table, string $column, bool $remove = false)

Set or remove primary key for a column.

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
bool $remove if true, remove the primary key

Return Value

void

Exceptions

JsonSQLException

at line 488
static void setAutoincrement(Engine $engine, string $table, string $column, bool $remove = false)

Set or remove autoincrement for a column.

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
bool $remove if true, remove the primary key

Return Value

void

Exceptions

JsonSQLException

at line 542
static void setTitle(Engine $engine, string $table, string $column, string|bool $title = false)

Set or remove the title of a column.

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
string|bool $title The title content. If false, remove the title

Return Value

void

Exceptions

JsonSQLException

at line 572
static void setDescription(Engine $engine, string $table, string $column, string|bool $description = false)

Set or remove the description of a column.

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name
string|bool $description The description content. If false, remove the description

Return Value

void

Exceptions

JsonSQLException

at line 602
static private void checkColumn(Engine $engine, string $table, string $column)

Checks the existence of a column

Parameters

Engine $engine The engine using this function
string $table The table name
string $column The actual column name

Return Value

void

Exceptions

JsonSQLException if the column doesn't exists