A class to define columns

package Peyote
author Dave Widmer

 Methods

Below are the keys that can be used in the options parameters

__construct(string $name, string $type, array $options) 

Key Type Description
is_null boolean Can this column be null?
length string The length of a field (number fields)
options array A list of data type options (UNSIGNED, ZEROFILL, etc...)
auto_increment boolean Auto Increment the column?
default string The default value for the column

Parameters

$name

string

The name of the column

$type

string

The type of column

$options

array

See above for column options that can be set.

addOption()

addOption(string $option) : \Peyote\Column

Parameters

$option

string

The option to add

Returns

{@inheritDoc}

compile() 

getAutoIncrement()

getAutoIncrement() : boolean

Returns

boolean

getDefault()

getDefault() : mixed

Returns

mixedThe default value or null if it hasn't been set

getIsNull()

getIsNull() : boolean | null

Returns

booleannull

getLength()

getLength() : string

Returns

stringThe length of the column

getName()

getName() : string

Returns

stringThe column name

getOptions()

getOptions() : array

Returns

arrayColumn options

getType()

getType() : string

Returns

stringThe current data type

isPrimaryKey()

isPrimaryKey() : boolean

Returns

booleanIs this a primary key column?

setAutoIncrement()

setAutoIncrement(boolean $flag) : \Peyote\Column

Parameters

$flag

boolean

Set auto increment?

Returns

setDefault()

setDefault(string $value) : \Peyote\Column

Parameters

$value

string

The default value

Returns

setIsNull()

setIsNull(boolean $is_null) : \Peyote\Column

Parameters

$is_null

boolean

Should this column be null?

Returns

setLength()

setLength(string $length) : \Peyote\Column

Parameters

$length

string

The field length

Returns

setName()

setName(string $name) : \Peyote\Column

Parameters

$name

string

The new column name

Returns

setOptions()

setOptions(array $options) : \Peyote\Column

Parameters

$options

array

The column options.

Returns

setType()

setType(string $type) : \Peyote\Column

Parameters

$type

string

The data type

Returns

 Properties

 

Is this an auto increment column?

$auto_increment : boolean

 

The default value

$default : string

 

Can this column be null?

$is_null : boolean

 

The length of a field

$length : string

 

The name of the column.

$name : string

 

Column options (UNSIGNED, ZEROFILL, etc...)

$options : array

 

Is this column a primary key?

$primary_key : boolean

 

The data type for the column.

$type : string