\Horde_Db_Adapter_Base_TableDefinition

Summary

Methods
Properties
Constants
__construct()
getName()
getOptions()
primaryKey()
column()
timestamps()
belongsTo()
references()
__call()
end()
toSql()
__toString()
offsetExists()
offsetGet()
offsetSet()
offsetUnset()
getIterator()
No public properties found
No constants found
_native()
$_name
$_base
$_options
$_columns
$_primaryKey
$_columntypes
N/A
No private methods found
No private properties found
N/A

Properties

$_name

$_name : 

Type

$_base

$_base : 

Type

$_options

$_options : 

Type

$_columns

$_columns : 

Type

$_primaryKey

$_primaryKey : 

Type

$_columntypes

$_columntypes : 

Type

Methods

__construct()

__construct(string  $name, \Horde_Db_Adapter_Base_Schema  $base, array  $options = array()) 

Constructor.

Parameters

string $name
\Horde_Db_Adapter_Base_Schema $base
array $options

getName()

getName() : string

Returns

string

getOptions()

getOptions() : array

Returns

array

primaryKey()

primaryKey(string  $name) 

Parameters

string $name

column()

column(  $name, string  $type, array  $options = array()) : \Horde_Db_Adapter_Base_TableDefinition

Adds a new column to the table definition.

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
string $type

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

array $options

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).

Returns

\Horde_Db_Adapter_Base_TableDefinition

This object.

timestamps()

timestamps() 

Adds created_at and updated_at columns to the table.

belongsTo()

belongsTo(  $columns) 

Add one or several references to foreign keys

This method returns self.

Parameters

$columns

references()

references(  $columns) 

Alias for the belongsTo() method

This method returns self.

Parameters

$columns

__call()

__call(  $method,   $arguments) 

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

Parameters

$method
$arguments

end()

end() 

Wrap up table creation block & create the table

toSql()

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.

Returns

string

__toString()

__toString() 

offsetExists()

offsetExists(integer  $offset) : boolean

ArrayAccess: Check if the given offset exists

Parameters

integer $offset

Returns

boolean

offsetGet()

offsetGet(integer  $offset) : object

ArrayAccess: Return the value for the given offset.

Parameters

integer $offset

Returns

object —

{@link {@Horde_Db_Adapter_Base_ColumnDefinition}

offsetSet()

offsetSet(integer  $offset, mixed  $value) 

ArrayAccess: Set value for given offset

Parameters

integer $offset
mixed $value

offsetUnset()

offsetUnset(integer  $offset) 

ArrayAccess: remove element

Parameters

integer $offset

getIterator()

getIterator() 

_native()

_native() 

Get the types