CakePHP
  • Documentation
    • Book
    • API
    • Videos
    • Reporting Security Issues
    • Privacy Policy
    • Logos & Trademarks
  • Business Solutions
  • Swag
  • Road Trip
  • Team
  • Community
    • Community
    • Get Involved
    • Issues (Github)
    • Bakery
    • Featured Resources
    • Training
    • Meetups
    • My CakePHP
    • CakeFest
    • Newsletter
    • Linkedin
    • YouTube
    • Facebook
    • Twitter
    • Mastodon
    • Help & Support
    • Forum
    • Stack Overflow
    • IRC
    • Slack
    • Paid Support
CakePHP

C CakePHP 5.3 Chiffon API

  • Project:
    • CakePHP
      • CakePHP
      • Authentication
      • Authorization
      • Chronos
      • Elastic Search
      • Queue
  • Version:
    • 5.3
      • 5.3
      • 5.2
      • 5.1
      • 5.0
      • 4.6
      • 4.5
      • 4.4
      • 4.3
      • 4.2
      • 4.1
      • 4.0
      • 3.10
      • 3.9
      • 3.8
      • 3.7
      • 3.6
      • 3.5
      • 3.4
      • 3.3
      • 3.2
      • 3.1
      • 3.0
      • 2.10
      • 2.9
      • 2.8
      • 2.7
      • 2.6
      • 2.5
      • 2.4
      • 2.3
      • 2.2
      • 2.1
      • 2.0
      • 1.3
      • 1.2

Namespaces

  • Global
  • Cake
    • Cache
    • Collection
    • Command
    • Console
    • Controller
    • Core
    • Database
      • Driver
      • Exception
      • Expression
      • Log
      • Query
      • Retry
      • Schema
      • Statement
      • Type
    • Datasource
    • Error
    • Event
    • Form
    • Http
    • I18n
    • Log
    • Mailer
    • Network
    • ORM
    • Routing
    • TestSuite
    • Utility
    • Validation
    • View

Class Column

Schema metadata for a single column

Used by TableSchema when reflecting schema or creating tables.

Namespace: Cake\Database\Schema

Method Summary

  • __construct() public

    Constructor.

  • getAfter() public

    Returns the name of the column to add this column after.

  • getBaseType() public

    Get the base type if defined. Will fallback to type if not set.

  • getCollate() public

    Gets the column collation.

  • getComment() public

    Gets the column comment.

  • getDefault() public

    Gets the default column value.

  • getFixed() public

    Gets whether the column is fixed-length.

  • getGenerated() public

    Gets generated option for identity columns. Null otherwise

  • getIdentity() public

    Gets whether the column is an identity column.

  • getIncrement() public

    Gets the column identity increment.

  • getLength() public

    Gets the column length.

  • getName() public

    Gets the column name.

  • getNull() public

    Gets whether the column allows nulls.

  • getOnUpdate() public

    Returns the value of the ON UPDATE column function.

  • getPrecision() public

    Gets the number precision for decimal or float column.

  • getSrid() public

    Gets the column SRID from geometry fields.

  • getType() public

    Gets the column type.

  • getUnsigned() public

    Gets whether field should be unsigned.

  • getValidOptions() protected

    Gets all allowed options. Each option must have a corresponding setFoo method.

  • isFixed() public

    Is the column fixed-length?

  • isIdentity() public

    Is the column an identity column?

  • isNull() public

    Does the column allow nulls?

  • isSigned() public

    Should the column be signed?

  • isUnsigned() public

    Should the column be unsigned?

  • setAfter() public

    Sets the name of the column to add this column after.

  • setAttributes() public

    Utility method that maps an array of column attributes to this object's methods.

  • setBaseType() public

    Sets the base type of the column.

  • setCollate() public

    Sets the column collation.

  • setComment() public

    Sets the column comment.

  • setDefault() public

    Sets the default column value.

  • setFixed() public

    Sets whether the column is fixed-length.

  • setGenerated() public

    Sets generated option for identity columns. Ignored otherwise.

  • setIdentity() public

    Sets whether the column is an identity column.

  • setIncrement() public

    Sets the column identity increment.

  • setLength() public

    Sets the column length.

  • setName() public

    Sets the column name.

  • setNull() public

    Sets whether the column allows nulls.

  • setOnUpdate() public

    Sets the 'ON UPDATE' mysql column function.

  • setPrecision() public

    Sets the number precision for decimal or float column.

  • setSrid() public

    Sets the column SRID for geometry fields.

  • setType() public

    Sets the column type.

  • setUnsigned() public

    Sets whether field should be unsigned.

  • toArray() public

    Convert an index into an array that is compatible with the Column constructor.

Method Detail

__construct() ¶ public

__construct(string $name, string $type, bool $null = null, mixed $default = null, int|null $length = null, bool $identity = false, string|null $generated = null, int|null $precision = null, int|null $increment = null, string|null $after = null, string|null $onUpdate = null, string|null $comment = null, bool|null $unsigned = null, string|null $collate = null, int|null $srid = null, string|null $baseType = null, bool|null $fixed = null)

Constructor.

Parameters
string $name

Name of the column

string $type

Type of the column

bool $null optional

Whether the column allows null values

mixed $default optional

Default value for the column

int|null $length optional

Length of the column

bool $identity optional

Whether the column is an identity column

string|null $generated optional

Postgres identity option (always|default)

int|null $precision optional

Precision for decimal or float columns

int|null $increment optional

Increment for identity columns

string|null $after optional

Name of the column to add this column after

string|null $onUpdate optional

MySQL 'ON UPDATE' function

string|null $comment optional

Comment for the column

bool|null $unsigned optional

Whether the column is unsigned

string|null $collate optional

Collation for the column

int|null $srid optional

SRID for geometry fields

string|null $baseType optional

The basic schema type if the column type is a complex/custom type.

bool|null $fixed optional

Whether the column is fixed-length (BINARY vs VARBINARY)

getAfter() ¶ public

getAfter(): string|null

Returns the name of the column to add this column after.

Used by MySQL and MariaDB in ALTER TABLE statements.

Returns
string|null

getBaseType() ¶ public

getBaseType(): string|null

Get the base type if defined. Will fallback to type if not set.

Used to get the base type of a column when the column type is a complex/custom type.

Returns
string|null

getCollate() ¶ public

getCollate(): string|null

Gets the column collation.

Returns
string|null

getComment() ¶ public

getComment(): string

Gets the column comment.

Returns
string

getDefault() ¶ public

getDefault(): mixed

Gets the default column value.

Returns
mixed

getFixed() ¶ public

getFixed(): bool|null

Gets whether the column is fixed-length.

Returns
bool|null

getGenerated() ¶ public

getGenerated(): string|null

Gets generated option for identity columns. Null otherwise

Returns
string|null

getIdentity() ¶ public

getIdentity(): bool

Gets whether the column is an identity column.

Returns
bool

getIncrement() ¶ public

getIncrement(): int|null

Gets the column identity increment.

Returns
int|null

getLength() ¶ public

getLength(): int|null

Gets the column length.

Returns
int|null

getName() ¶ public

getName(): string|null

Gets the column name.

Returns
string|null

getNull() ¶ public

getNull(): bool|null

Gets whether the column allows nulls.

Returns
bool|null

getOnUpdate() ¶ public

getOnUpdate(): string|null

Returns the value of the ON UPDATE column function.

Returns
string|null

getPrecision() ¶ public

getPrecision(): int|null

Gets the number precision for decimal or float column.

For example DECIMAL(5,2), 5 is the length and 2 is the precision, and the column could store value from -999.99 to 999.99.

Returns
int|null

getSrid() ¶ public

getSrid(): int|null

Gets the column SRID from geometry fields.

Returns
int|null

getType() ¶ public

getType(): string

Gets the column type.

Returns
string

getUnsigned() ¶ public

getUnsigned(): bool|null

Gets whether field should be unsigned.

Returns
bool|null

getValidOptions() ¶ protected

getValidOptions(): array

Gets all allowed options. Each option must have a corresponding setFoo method.

Returns
array

isFixed() ¶ public

isFixed(): bool

Is the column fixed-length?

Returns
bool

isIdentity() ¶ public

isIdentity(): bool

Is the column an identity column?

Returns
bool

isNull() ¶ public

isNull(): bool

Does the column allow nulls?

Returns
bool

isSigned() ¶ public

isSigned(): bool

Should the column be signed?

Returns
bool

isUnsigned() ¶ public

isUnsigned(): bool

Should the column be unsigned?

Returns
bool

setAfter() ¶ public

setAfter(string $after): $this

Sets the name of the column to add this column after.

Parameters
string $after

After

Returns
$this

setAttributes() ¶ public

setAttributes(array<string, mixed> $attributes): $this

Utility method that maps an array of column attributes to this object's methods.

Parameters
array<string, mixed> $attributes

Attributes

Returns
$this
Throws
RuntimeException

setBaseType() ¶ public

setBaseType(string|null $baseType): $this

Sets the base type of the column.

Used to set the base type of a column when the column type is a complex/custom type.

Parameters
string|null $baseType

Base type

Returns
$this

setCollate() ¶ public

setCollate(string $collation): $this

Sets the column collation.

Parameters
string $collation

Collation

Returns
$this

setComment() ¶ public

setComment(string|null $comment): $this

Sets the column comment.

Parameters
string|null $comment

Comment

Returns
$this

setDefault() ¶ public

setDefault(mixed $default): $this

Sets the default column value.

Parameters
mixed $default

Default

Returns
$this

setFixed() ¶ public

setFixed(bool $fixed): $this

Sets whether the column is fixed-length.

Used for binary columns to distinguish between BINARY and VARBINARY.

Parameters
bool $fixed

Fixed

Returns
$this

setGenerated() ¶ public

setGenerated(string|null $generated): $this

Sets generated option for identity columns. Ignored otherwise.

Parameters
string|null $generated

Generated option

Returns
$this

setIdentity() ¶ public

setIdentity(bool $identity): $this

Sets whether the column is an identity column.

Parameters
bool $identity

Identity

Returns
$this

setIncrement() ¶ public

setIncrement(int $increment): $this

Sets the column identity increment.

Parameters
int $increment

Number increment

Returns
$this

setLength() ¶ public

setLength(int|null $length): $this

Sets the column length.

Parameters
int|null $length

Length

Returns
$this

setName() ¶ public

setName(string $name): $this

Sets the column name.

Parameters
string $name

Name

Returns
$this

setNull() ¶ public

setNull(bool $null): $this

Sets whether the column allows nulls.

Parameters
bool $null

Null

Returns
$this

setOnUpdate() ¶ public

setOnUpdate(string $update): $this

Sets the 'ON UPDATE' mysql column function.

Used by MySQL and MariaDB in ALTER TABLE statements.

Parameters
string $update

On Update function

Returns
$this

setPrecision() ¶ public

setPrecision(int|null $precision): $this

Sets the number precision for decimal or float column.

For example DECIMAL(5,2), 5 is the length and 2 is the precision, and the column could store value from -999.99 to 999.99.

Parameters
int|null $precision

Number precision

Returns
$this

setSrid() ¶ public

setSrid(int $srid): $this

Sets the column SRID for geometry fields.

Parameters
int $srid

SRID

Returns
$this

setType() ¶ public

setType(string $type): $this

Sets the column type.

Type names are not validated, as drivers and dialects may implement platform specific types that are not known by cakephp.

Drivers are expected to handle unknown types gracefully.

Parameters
string $type

Column type

Returns
$this

setUnsigned() ¶ public

setUnsigned(bool $unsigned): $this

Sets whether field should be unsigned.

Parameters
bool $unsigned

Signed

Returns
$this

toArray() ¶ public

toArray(): array

Convert an index into an array that is compatible with the Column constructor.

Returns
array
OpenHub
Pingping
Linode
  • Business Solutions
  • Showcase
  • Documentation
  • Book
  • API
  • Videos
  • Reporting Security Issues
  • Privacy Policy
  • Logos & Trademarks
  • Community
  • Get Involved
  • Issues (Github)
  • Bakery
  • Featured Resources
  • Training
  • Meetups
  • My CakePHP
  • CakeFest
  • Newsletter
  • Linkedin
  • YouTube
  • Facebook
  • Twitter
  • Mastodon
  • Help & Support
  • Forum
  • Stack Overflow
  • IRC
  • Slack
  • Paid Support

Generated using CakePHP API Docs