\Gishiki\Database\SchemaColumn

Represent a column inside a table of a relational database.

Summary

Methods
Properties
Constants
__construct()
setAutoIncrement()
isAutoIncrement()
setNotNull()
isNotNull()
setPrimaryKey()
isPrimaryKey()
setRelation()
getRelation()
setName()
getName()
setType()
getType()
No public properties found
No constants found
No protected methods found
$name
$type
$notNull
$autoIncrement
$pkey
$relation
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name : string

Type

string — the name of the column

$type

$type : integer

Type

integer — the type of the column, expressed as one of the ColumnType constants

$notNull

$notNull : boolean

Type

boolean — TRUE if the column cannot hold null

$autoIncrement

$autoIncrement : boolean

Type

boolean — TRUE if the column is autoincrement

$pkey

$pkey : boolean

Type

boolean — TRUE if the column is a primary key

Methods

__construct()

__construct(string  $name, integer  $type) 

Initialize a column with the given name.

This function internally calls setName(), and you should catch exceptions thrown by that function.

Parameters

string $name

the name of the column

integer $type

the data type of the column

setAutoIncrement()

setAutoIncrement(boolean  $enable) : \Gishiki\Database\Schema\Column

Change the auto increment flag on the column.

Parameters

boolean $enable

TRUE is used to flag an auto increment column as such

Throws

\InvalidArgumentException

the new status is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

isAutoIncrement()

isAutoIncrement() : boolean

Retrieve the auto increment flag on the column.

Returns

boolean —

$enable true if the column is autoincrement

setNotNull()

setNotNull(boolean  $enable) : \Gishiki\Database\Schema\Column

Change the primary key flag on the column.

Parameters

boolean $enable

TRUE is used to flag a not null column as such

Throws

\InvalidArgumentException

the new status is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

isNotNull()

isNotNull() : boolean

Retrieve the not null flag on the column.

Returns

boolean —

$enable true if the column cannot contains null

setPrimaryKey()

setPrimaryKey(boolean  $enable) : \Gishiki\Database\Schema\Column

Change the primary key flag on the column.

Parameters

boolean $enable

TRUE is used to flag a primary key column as such

Throws

\InvalidArgumentException

the new status is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

isPrimaryKey()

isPrimaryKey() : boolean

Retrieve the auto increment flag on the column.

Returns

boolean —

$enable true if the column is a primary key

setRelation()

setRelation(\Gishiki\Database\Schema\ColumnRelation  $rel) : \Gishiki\Database\Schema\Column

Change the relation of the current column.

Parameters

\Gishiki\Database\Schema\ColumnRelation $rel

the column relation

Throws

\InvalidArgumentException

the column name is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

getRelation()

getRelation() : \Gishiki\Database\Schema\ColumnRelation|null

Retrieve the relation of the column.

Returns

\Gishiki\Database\Schema\ColumnRelation|null —

the column relation or null

setName()

setName(string  $name) : \Gishiki\Database\Schema\Column

Change the name of the current column.

Parameters

string $name

the name of the column

Throws

\InvalidArgumentException

the column name is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

getName()

getName() : string

Retrieve the name of the column.

Returns

string —

the column name

setType()

setType(string  $type) : \Gishiki\Database\Schema\Column

Change the type of the current table passing as argument one of the ColumnType constants.

Parameters

string $type

the type of the column

Throws

\InvalidArgumentException

the column name is invalid

Returns

\Gishiki\Database\Schema\Column

a reference to the modified Column

getType()

getType() : integer

Retrieve the type of the column.

Returns

integer —

the column name