PHP Class Horde_Db_Adapter_Base_TableDefinition, horde

Author: Mike Naberezny ([email protected])
Author: Derek DeVries ([email protected])
Author: Chuck Hagenbuch ([email protected])
Inheritance: implements ArrayAccess, implements IteratorAggregate
显示文件 Open project: horde/horde Class Usage Examples

Protected Properties

Property Type Description
$_base
$_columns
$_columntypes
$_name
$_options
$_primaryKey

Public Methods

Method Description
__call ( $method, $arguments ) Use __call to provide shorthand column creation ($this->integer(), etc.)
__construct ( string $name, Horde_Db_Adapter_Base_Schema $base, array $options = [] ) Constructor.
__toString ( )
belongsTo ( $columns ) Add one or several references to foreign keys
column ( $name, string $type, array $options = [] ) : Horde_Db_Adapter_Base_TableDefinition Adds a new column to the table definition.
end ( ) Wrap up table creation block & create the table
getIterator ( ) *########################################################################## # IteratorAggregate ##########################################################################
getName ( ) : string
getOptions ( ) : array
offsetExists ( integer $offset ) : boolean ArrayAccess: Check if the given offset exists
offsetGet ( integer $offset ) : object ArrayAccess: Return the value for the given offset.
offsetSet ( integer $offset, mixed $value ) ArrayAccess: Set value for given offset
offsetUnset ( integer $offset ) ArrayAccess: remove element
primaryKey ( string $name )
references ( $columns ) Alias for the belongsTo() method
timestamps ( ) 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.

Protected Methods

Method Description
_native ( ) Get the types

Method Details

__call() public method

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

__construct() public method

Constructor.
public __construct ( string $name, Horde_Db_Adapter_Base_Schema $base, array $options = [] )
$name string
$base Horde_Db_Adapter_Base_Schema
$options array

__toString() public method

public __toString ( )

_native() protected method

Get the types
protected _native ( )

belongsTo() public method

This method returns self.
public belongsTo ( $columns )

column() public method

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
public column ( $name, string $type, array $options = [] ) : Horde_Db_Adapter_Base_TableDefinition
$type string Column type, one of: autoincrementKey, string, text, integer, float, datetime, timestamp, time, date, binary, boolean.
$options array 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 Horde_Db_Adapter_Base_TableDefinition This object.

end() public method

Wrap up table creation block & create the table
public end ( )

getIterator() public method

*########################################################################## # IteratorAggregate ##########################################################################
public getIterator ( )

getName() public method

public getName ( ) : string
return string

getOptions() public method

public getOptions ( ) : array
return array

offsetExists() public method

ArrayAccess: Check if the given offset exists
public offsetExists ( integer $offset ) : boolean
$offset integer
return boolean

offsetGet() public method

ArrayAccess: Return the value for the given offset.
public offsetGet ( integer $offset ) : object
$offset integer
return object {@link {@Horde_Db_Adapter_Base_ColumnDefinition}

offsetSet() public method

ArrayAccess: Set value for given offset
public offsetSet ( integer $offset, mixed $value )
$offset integer
$value mixed

offsetUnset() public method

ArrayAccess: remove element
public offsetUnset ( integer $offset )
$offset integer

primaryKey() public method

public primaryKey ( string $name )
$name string

references() public method

This method returns self.
public references ( $columns )

timestamps() public method

Adds created_at and updated_at columns to the table.
public timestamps ( )

toSql() public method

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 string

Property Details

$_base protected_oe property

protected $_base

$_columns protected_oe property

protected $_columns

$_columntypes protected_oe property

protected $_columntypes

$_name protected_oe property

protected $_name

$_options protected_oe property

protected $_options

$_primaryKey protected_oe property

protected $_primaryKey