Documentation

TableDefinition
in package
implements ArrayAccess, IteratorAggregate

Tags
author

Mike Naberezny mike@maintainable.com

author

Derek DeVries derek@maintainable.com

author

Chuck Hagenbuch chuck@horde.org

category

Horde

copyright

2007 Maintainable Software, LLC

copyright

2008-2021 Horde LLC

license

http://www.horde.org/licenses/bsd

subpackage

Adapter

Interfaces, Classes, Traits and Enums

ArrayAccess
IteratorAggregate

Table of Contents

$base  : mixed
$columns  : mixed
$columntypes  : mixed
$name  : mixed
$options  : array<string|int, mixed>
$primaryKey  : mixed
__call()  : mixed
Use __call to provide shorthand column creation ($this->integer(), etc.)
__construct()  : mixed
Constructor.
__toString()  : mixed
belongsTo()  : mixed
Add one or several references to foreign keys
column()  : TableDefinition
Adds a new column to the table definition.
end()  : mixed
Wrap up table creation block & create the table
getIterator()  : mixed
getName()  : string
getOptions()  : array<string|int, mixed>
offsetExists()  : bool
ArrayAccess: Check if the given offset exists
offsetGet()  : object
ArrayAccess: Return the value for the given offset.
offsetSet()  : mixed
ArrayAccess: Set value for given offset
offsetUnset()  : mixed
ArrayAccess: remove element
primaryKey()  : mixed
references()  : mixed
Alias for the belongsTo() method
timestamps()  : mixed
Adds created_at and updated_at columns to the table.
toSql()  : string
Returns a String whose contents are the column definitions concatenated together. This string can then be pre and appended to to generate the final SQL to create the table.
native()  : mixed
Get the types

Properties

$columntypes

protected mixed $columntypes = array('string', 'text', 'integer', 'float', 'datetime', 'timestamp', 'time', 'date', 'binary', 'boolean')

Methods

__call()

Use __call to provide shorthand column creation ($this->integer(), etc.)

public __call(mixed $method, mixed $arguments) : mixed
Parameters
$method : mixed
$arguments : mixed
Return values
mixed

__construct()

Constructor.

public __construct(string $name, Schema $base[, array<string|int, mixed> $options = [] ]) : mixed
Parameters
$name : string
$base : Schema
$options : array<string|int, mixed> = []
Return values
mixed

belongsTo()

Add one or several references to foreign keys

public belongsTo(mixed $columns) : mixed

This method returns self.

Parameters
$columns : mixed
Return values
mixed

column()

Adds a new column to the table definition.

public column(mixed $name, string $type[, array<string|int, mixed> $options = [] ]) : TableDefinition

Examples: // Assuming $def is an instance of Horde_Db_Adapter_Base_TableDefinition

$def->column('granted', 'boolean'); // => granted BOOLEAN

$def->column('picture', 'binary', 'limit' => 4096); // => picture BLOB(4096)

$def->column('sales_stage', 'string', array('limit' => 20, 'default' => 'new', 'null' => false)); // => sales_stage VARCHAR(20) DEFAULT 'new' NOT NULL

Parameters
$name : mixed
$type : string

Column type, one of: autoincrementKey, string, text, integer, float, datetime, timestamp, time, date, binary, boolean.

$options : array<string|int, mixed> = []

Column options:

  • autoincrement: (boolean) Whether the column is an autoincrement column. Restrictions are RDMS specific.
  • default: (mixed) The column's default value. You cannot explicitly set the default value to NULL. Simply leave off this option if you want a NULL default value.
  • limit: (integer) Maximum column length (string, text, binary or integer columns only)
  • null: (boolean) Whether NULL values are allowed in the column.
  • precision: (integer) The number precision (float columns only).
  • scale: (integer) The number scaling (float columns only).
  • unsigned: (boolean) Whether the column is an unsigned number (integer columns only).
Return values
TableDefinition

This object.

end()

Wrap up table creation block & create the table

public end() : mixed
Return values
mixed

getOptions()

public getOptions() : array<string|int, mixed>
Return values
array<string|int, mixed>

offsetExists()

ArrayAccess: Check if the given offset exists

public offsetExists(int $offset) : bool
Parameters
$offset : int
Return values
bool

offsetGet()

ArrayAccess: Return the value for the given offset.

public offsetGet(int $offset) : object
Parameters
$offset : int
Return values
object

offsetSet()

ArrayAccess: Set value for given offset

public offsetSet(int $offset, mixed $value) : mixed
Parameters
$offset : int
$value : mixed
Return values
mixed

offsetUnset()

ArrayAccess: remove element

public offsetUnset(int $offset) : mixed
Parameters
$offset : int
Return values
mixed

primaryKey()

public primaryKey(string $name) : mixed
Parameters
$name : string
Return values
mixed

references()

Alias for the belongsTo() method

public references(mixed $columns) : mixed

This method returns self.

Parameters
$columns : mixed
Return values
mixed

timestamps()

Adds created_at and updated_at columns to the table.

public timestamps() : mixed
Return values
mixed

toSql()

Returns a String whose contents are the column definitions concatenated together. This string can then be pre and appended to to generate the final SQL to create the table.

public toSql() : string
Return values
string

native()

Get the types

protected native() : mixed
Return values
mixed

Search results