Class Xyster_Db_Gateway_Abstract

Description

A gateway and abstraction layer for database administration

  • copyright: Copyright (c) 2007-2008 Irrational Logic (http://irrationallogic.net)
  • abstract:
  • license: New BSD License

Located in /Db/Gateway/Abstract.php (line 24)


	
			
Direct descendents
Class Description
Xyster_Db_Gateway_Pdo_Pgsql A gateway and abstraction layer for MySQL
Xyster_Db_Gateway_Pdo_Sqlite A gateway and abstraction layer for SQLite
Xyster_Db_Gateway_Pdo_Mysql A gateway and abstraction layer for MySQL
Method Summary
Xyster_Db_Gateway_Abstract __construct ([ $db = null])
void addColumn (string $table, string $name,  $type, [mixed $argument = null])
void addForeign (string $table, mixed $cols, string $foreignTable, mixed $foreignCols, [ $onDelete = null], [ $onUpdate = null])
void addPrimary (string $table, mixed $cols)
Xyster_Db_Gateway_IndexBuilder createIndex (string $name, [string $schema = null])
void createSequence (string $name, [int $inc = null], [int $start = null], [int $min = null], [int $max = null])
Xyster_Db_Gateway_TableBuilder createTable (string $name, [string $schema = null])
void dropColumn (string $table, string $name)
void dropForeign (string $table, string $name)
void dropIndex (string $name, [string $table = null])
void dropPrimary (string $table, [string $name = null])
void dropSequence (string $name)
void dropTable (string $name)
Zend_Db_Adapter_Abstract getAdapter ()
void listForeignKeys ()
array listIndexes ()
array listSequences ()
void renameColumn (string $table, string $old, string $new)
void renameIndex (string $old, string $new, [string $table = null])
void renameSequence (string $old, string $new)
void renameTable (string $old, string $new)
void setDefault (string $table, string $column, mixed $default)
void setNull (string $table, string $column, [boolean $null = true])
void setType (string $table, string $column,  $type, [mixed $argument = null])
void setUnique (string $table, mixed $cols)
boolean supportsForeignKeys ()
boolean supportsSequences ()
string _getAddColumnSql (string $table, string $name,  $type, [mixed $argument = null])
string _getAddForeignSql (string $table,  $columns, string $foreignTable,  $foreignColumns, [ $onDelete = null], [ $onUpdate = null])
string _getAddPrimarySql (string $table,  $columns)
string _getCreateSequenceSql (string $name, [int $inc = null], [int $start = null], [int $min = null], [int $max = null])
string _getDropColumnSql (string $table, string $name)
string _getDropForeignSql (string $table, string $name)
string _getDropIndexSql (string $name, [string $table = null])
string _getDropPrimarySql (string $table, [string $name = null])
string _getDropSequenceSql (string $name)
string _getDropTableSql (string $name)
string _getRenameColumnSql (string $table, string $old, string $new)
string _getRenameIndexSql (string $old, string $new, [string $table = null])
string _getRenameSequenceSql (string $old, string $new)
string _getRenameTableSql (string $old, string $new)
string _getSetDefaultSql (string $table, string $column, mixed $default)
string _getSetNullSql (string $table, string $column, [boolean $null = true])
string _getSetTypeSql (string $table, string $column,  $type, [mixed $argument = null])
string _getSetUniqueSql (string $table,  $columns)
array _makeArray (mixed $object)
string _quote (mixed $thing)
string _translateType ( $type, [mixed $argument = null])
Methods
Constructor __construct (line 39)

Creates a new DB gateway

This constructor should be overloaded with one that has the concrete type hint.

  • access: public
Xyster_Db_Gateway_Abstract __construct ([ $db = null])
  • Zend_Db_Adapter_Abstract $db: The database adapter to use

Redefined in descendants as:
addColumn (line 62)

Adds a column to a table

  • access: public
void addColumn (string $table, string $name,  $type, [mixed $argument = null])
  • string $table: The table name
  • string $name: The name of the new column
  • Xyster_Db_DataType $type: The data type
  • mixed $argument: An optional argument for the data type
addForeign (line 77)

Adds a foreign key to a table

  • access: public
void addForeign (string $table, mixed $cols, string $foreignTable, mixed $foreignCols, [ $onDelete = null], [ $onUpdate = null])
  • string $table: The table name
  • mixed $cols: The string column name or an array of column names in the source table
  • string $foreignTable: The foreign table name
  • mixed $foreignCols: The string column name or an array of column names in the foreign table
  • Xyster_Db_ReferentialAction $onDelete: optional
  • Xyster_Db_ReferentialAction $onUpdate: optional
addPrimary (line 91)

Adds a primary key to a table

  • access: public
void addPrimary (string $table, mixed $cols)
  • string $table: The table name
  • mixed $cols: The string column name or an array of column names
createIndex (line 104)

Creates an index builder

  • access: public
Xyster_Db_Gateway_IndexBuilder createIndex (string $name, [string $schema = null])
  • string $name: The name of the index
  • string $schema: Optional. The schema of the index
createSequence (line 119)

Creates a sequence

  • access: public
void createSequence (string $name, [int $inc = null], [int $start = null], [int $min = null], [int $max = null])
  • string $name: The name of the sequence
  • int $inc: The amount the sequence increments
  • int $start: The starting number for the sequence
  • int $min: The sequence minimum
  • int $max: The sequence maximum
createTable (line 133)

Creates a table builder

  • access: public
Xyster_Db_Gateway_TableBuilder createTable (string $name, [string $schema = null])
  • string $name: The name of the table
  • string $schema: Optional. The table schema
dropColumn (line 145)

Removes a column from a table

  • access: public
void dropColumn (string $table, string $name)
  • string $table: The table name
  • string $name: The column name

Redefined in descendants as:
dropForeign (line 156)

Drops a foreign key from a table

  • access: public
void dropForeign (string $table, string $name)
  • string $table: The table name
  • string $name: The foreign key name
dropIndex (line 168)

Removes an index

  • access: public
void dropIndex (string $name, [string $table = null])
  • string $name: The index name
  • string $table: The table name (not required for all databases)
dropPrimary (line 179)

Removes a primary key from a table

  • access: public
void dropPrimary (string $table, [string $name = null])
  • string $table: The table name
  • string $name: The index name (not required for all databases)
dropSequence (line 189)

Drops a sequence

  • access: public
void dropSequence (string $name)
  • string $name: The sequence name
dropTable (line 200)

Drops a table

  • access: public
void dropTable (string $name)
  • string $name: The table name
executeIndexBuilder (line 210)

Executes an index builder

  • access: public
void executeIndexBuilder (Xyster_Db_Gateway_IndexBuilder $builder)
executeTableBuilder (line 220)

Creates a table from a table builder

  • access: public
void executeTableBuilder (Xyster_Db_Gateway_TableBuilder $builder)
getAdapter (line 49)

Gets the database adapter

  • access: public
Zend_Db_Adapter_Abstract getAdapter ()
listForeignKeys (line 390)

Lists all foreign keys

The return value is an associative array keyed by the key name, as returned by the RDBMS.

The value of each array element is an associative array with the following keys:

KEY_NAME => string; foreign key name SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; name of table COLUMNS => array; An array of the column names ON_UPDATE => string; ON_DELETE => string;

  • abstract:
  • access: public
void listForeignKeys ()

Redefined in descendants as:
listIndexes (line 410)

Lists all indexes

The return value is an associative array keyed by the index name, as returned by the RDBMS.

The value of each array element is an associative array with the following keys:

INDEX_NAME => string; index name SCHEMA_NAME => string; name of database or schema TABLE_NAME => string; name of table COLUMNS => array; An array of the column names PRIMARY => boolean; true if the index is a primary key UNIQUE => boolean; true if the index is a unique key

  • return: An array of string index names
  • abstract:
  • access: public
array listIndexes ()

Redefined in descendants as:
listSequences (line 239)

Lists all sequences

  • return: An array of string sequence names
  • access: public
array listSequences ()
renameColumn (line 252)

Renames a column

  • access: public
void renameColumn (string $table, string $old, string $new)
  • string $table: The table name
  • string $old: The current column name
  • string $new: The new column name

Redefined in descendants as:
renameIndex (line 265)

Renames an index

  • access: public
void renameIndex (string $old, string $new, [string $table = null])
  • string $old: The current index name
  • string $new: The new index name
  • string $table: The table name (not required on all databases)

Redefined in descendants as:
renameSequence (line 277)

Renames a sequence

  • access: public
void renameSequence (string $old, string $new)
  • string $old: The current sequence name
  • string $new: The new sequence name
renameTable (line 294)

Renames a table

  • access: public
void renameTable (string $old, string $new)
  • string $old: The current table name
  • string $new: The new table name
setDefault (line 306)

Sets the default value for a column

  • access: public
void setDefault (string $table, string $column, mixed $default)
  • string $table: The table name
  • string $column: The column name
  • mixed $default: The new column default value

Redefined in descendants as:
setNull (line 319)

Sets whether or not the column will accept null

  • access: public
void setNull (string $table, string $column, [boolean $null = true])
  • string $table: The table name
  • string $column: The column name
  • boolean $null: True for NULL, false for NOT NULL
setType (line 348)

Changes the type of a column

  • access: public
void setType (string $table, string $column,  $type, [mixed $argument = null])
  • string $table: The table name
  • string $column: The column name
  • Xyster_Db_DataType $type: The new data type
  • mixed $argument: An optional argument for the data type
setUnique (line 334)

Creates a unique index on a column or columns

This method doesn't allow you to specify a name for the unique index. Use the createIndex method if you need more control.

  • access: public
void setUnique (string $table, mixed $cols)
  • string $table: The table name
  • mixed $cols: The string column name or an array of column names

Redefined in descendants as:
supportsForeignKeys (line 359)

Whether the database supports foreign keys

  • access: public
boolean supportsForeignKeys ()

Redefined in descendants as:
supportsSequences (line 369)

Whether the database supports sequences

  • access: public
boolean supportsSequences ()

Redefined in descendants as:
_getAddColumnSql (line 499)

Gets the SQL statement to add a column

  • access: protected
string _getAddColumnSql (string $table, string $name,  $type, [mixed $argument = null])
  • string $table: The table name
  • string $name: The column name
  • Xyster_Db_DataType $type: The data type
  • mixed $argument: An argument for the data type
_getAddForeignSql (line 517)

Gets the SQL statement to add a foreign key to a table

  • access: protected
string _getAddForeignSql (string $table,  $columns, string $foreignTable,  $foreignColumns, [ $onDelete = null], [ $onUpdate = null])
  • string $table: The table name
  • array $columns: The columns in the key
  • string $foreignTable: The foreign table name
  • array $foreignColumns: The foreign columns referenced
  • Xyster_Db_ReferentialAction $onDelete: The ON DELETE action
  • Xyster_Db_ReferentialAction $onUpdate: The ON UPDATE action
_getAddPrimarySql (line 538)

Gets the SQL statement to add a primary key to a table

  • access: protected
string _getAddPrimarySql (string $table,  $columns)
  • string $table: The table name
  • array $columns: The columns in the key

Redefined in descendants as:
_getCreateIndexSql (line 752)

Gets the SQL statement to create an index

If the DBMS doesn't support FULLTEXT indexes, it's safe to ignore the setting (an exception doesn't need to be thrown).

  • abstract:
  • access: protected
string _getCreateIndexSql (Xyster_Db_Gateway_IndexBuilder $builder)

Redefined in descendants as:
_getCreateSequenceSql (line 560)

Gets the SQL statement to create a sequence

If the DBMS doesn't support sequences, this method won't be called. There is no need to throw an exception for this method, just leave an empty method body or return null.

This syntax is taken from SQL-2003

  • access: protected
string _getCreateSequenceSql (string $name, [int $inc = null], [int $start = null], [int $min = null], [int $max = null])
  • string $name: The name of the sequence
  • int $inc: The increment
  • int $start: The starting value
  • int $min: The minimum value
  • int $max: The maximum value
_getCreateTableSql (line 587)

Gets the SQL to create a table

This method does not process index/fulltext; indexes are not part of the SQL standard.

  • access: protected
string _getCreateTableSql (Xyster_Db_Gateway_TableBuilder $builder)

Redefined in descendants as:
_getDropColumnSql (line 650)

Gets the SQL statement to drop a column from a table

  • access: protected
string _getDropColumnSql (string $table, string $name)
  • string $table: The table name
  • string $name: The column name
_getDropForeignSql (line 663)

Gets the SQL statement to drop a foreign key from a table

  • access: protected
string _getDropForeignSql (string $table, string $name)
  • string $table: The table name
  • string $name: The key name

Redefined in descendants as:
_getDropIndexSql (line 761)

Gets the SQL statement to drop an index

  • abstract:
  • access: protected
string _getDropIndexSql (string $name, [string $table = null])
  • string $name: The index name
  • string $table: The table (not all dbs require this)

Redefined in descendants as:
_getDropPrimarySql (line 770)

Gets the SQL statement to drop a primary key from a table

  • abstract:
  • access: protected
string _getDropPrimarySql (string $table, [string $name = null])
  • string $table: The table name
  • string $name: The index name (not all dbs require this)

Redefined in descendants as:
_getDropSequenceSql (line 681)

Gets the SQL statement to drop a sequence

If the DBMS doesn't support sequences, this method won't be called. There is no need to throw an exception for this method, just leave an empty method body or return null.

The syntax for this statement is taken from SQL-2003

  • access: protected
string _getDropSequenceSql (string $name)
  • string $name: The sequence name
_getDropTableSql (line 692)

Gets the SQL statement to drop a table

  • access: protected
string _getDropTableSql (string $name)
  • string $name: The table name
_getListSequencesSql (line 781)

Gets the SQL statement to list the sequences

If the DBMS doesn't support sequences, this method won't be called. There is no need to throw an exception for this method, just leave an empty method body or return null.

  • abstract:
  • access: protected
string _getListSequencesSql ()

Redefined in descendants as:
_getRenameColumnSql (line 810)

Gets the SQL statement to rename a column in a table

  • abstract:
  • access: protected
string _getRenameColumnSql (string $table, string $old, string $new)
  • string $table: The table name
  • string $old: The current column name
  • string $new: The new column name

Redefined in descendants as:
_getRenameIndexSql (line 791)

Gets the SQL statement to rename an index

  • abstract:
  • access: protected
string _getRenameIndexSql (string $old, string $new, [string $table = null])
  • string $old: The current index name
  • string $new: The new index name
  • string $table: The table name (not all dbs require this)

Redefined in descendants as:
_getRenameSequenceSql (line 710)

Gets the SQL statement to rename a sequence

If the DBMS doesn't support sequences, this method won't be called. There is no need to throw an exception for this method, just leave an empty method body or return null.

SQL-2003 doesn't have an option for renaming a sequence

  • access: protected
string _getRenameSequenceSql (string $old, string $new)
  • string $old: The current sequence name
  • string $new: The new sequence name

Redefined in descendants as:
_getRenameTableSql (line 800)

Gets the SQL statement to rename a table

  • abstract:
  • access: protected
string _getRenameTableSql (string $old, string $new)
  • string $old: The current table name
  • string $new: The new table name

Redefined in descendants as:
_getSetDefaultSql (line 723)

Gets the SQL statement to set a default value on a column

  • access: protected
string _getSetDefaultSql (string $table, string $column, mixed $default)
  • string $table: The table name
  • string $column: The column name
  • mixed $default: The default value
_getSetNullSql (line 820)

Gets the SQL statement to set a column's NULL status

  • abstract:
  • access: protected
string _getSetNullSql (string $table, string $column, [boolean $null = true])
  • string $table: The table name
  • string $column: The column name
  • boolean $null: True for NULL, false for NOT NULL

Redefined in descendants as:
_getSetTypeSql (line 831)

Gets the SQL statement to set the data type of a column

  • abstract:
  • access: protected
string _getSetTypeSql (string $table, string $column,  $type, [mixed $argument = null])
  • string $table: The table name
  • string $column: The column name
  • Xyster_Db_DataType $type: The data type
  • mixed $argument: An argument for the data type

Redefined in descendants as:
_getSetUniqueSql (line 737)

Gets the SQL statement to create a UNIQUE index for one or more columns

  • access: protected
string _getSetUniqueSql (string $table,  $columns)
  • string $table: The table name
  • array $columns: The columns in the unique index
_makeArray (line 418)

Ensures the object passed is an array

  • access: protected
array _makeArray (mixed $object)
  • mixed $object
_quote (line 429)

Quotes an identifier or a group of identifiers

  • access: protected
string _quote (mixed $thing)
  • mixed $thing: Either a string identifier or an array of them
_setAdapter (line 458)

Sets the database adapter

Each class should implement a public setAdapter method with a type hint for the exact type of adapter expected. For instance, the Xyster_Db_Gateway_Pdo_Pgsql class will want a Zend_Db_Adapter_Pdo_Pgsql for its adapter.

  • return: provides a fluent interface
  • access: protected
Xyster_Db_Gateway_Abstract _setAdapter ( $db)
  • Zend_Db_Adapter_Abstract $db
_translateType (line 840)

Translates a DataType enum into the correct SQL syntax

  • abstract:
  • access: protected
string _translateType ( $type, [mixed $argument = null])
  • Xyster_Db_DataType $type
  • mixed $argument

Redefined in descendants as:

Documentation generated on Mon, 19 May 2008 17:08:08 -0400 by phpDocumentor 1.4.2