Creates a new DB gateway
This constructor should be overloaded with one that has the concrete type hint.
Xyster_Db_Gateway_Abstract
__construct
([ $db = null])
-
Zend_Db_Adapter_Abstract
$db: The database adapter to use
Redefined in descendants as:
Adds a column to a table
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
Adds a foreign key to a table
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
Adds a primary key to a table
void
addPrimary
(string $table, mixed $cols)
-
string
$table: The table name
-
mixed
$cols: The string column name or an array of column names
Creates an index builder
-
string
$name: The name of the index
-
string
$schema: Optional. The schema of the index
Creates a sequence
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
Creates a table builder
-
string
$name: The name of the table
-
string
$schema: Optional. The table schema
Removes a column from a table
void
dropColumn
(string $table, string $name)
-
string
$table: The table name
-
string
$name: The column name
Redefined in descendants as:
Drops a foreign key from a table
void
dropForeign
(string $table, string $name)
-
string
$table: The table name
-
string
$name: The foreign key name
Removes an index
void
dropIndex
(string $name, [string $table = null])
-
string
$name: The index name
-
string
$table: The table name (not required for all databases)
Removes a primary key from a table
void
dropPrimary
(string $table, [string $name = null])
-
string
$table: The table name
-
string
$name: The index name (not required for all databases)
Drops a sequence
void
dropSequence
(string $name)
-
string
$name: The sequence name
Drops a table
void
dropTable
(string $name)
-
string
$name: The table name
Executes an index builder
Creates a table from a table builder
Gets the database adapter
Zend_Db_Adapter_Abstract
getAdapter
()
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;
void
listForeignKeys
()
Redefined in descendants as:
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
array
listIndexes
()
Redefined in descendants as:
Lists all sequences
array
listSequences
()
Renames a column
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:
Renames an index
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:
Renames a sequence
void
renameSequence
(string $old, string $new)
-
string
$old: The current sequence name
-
string
$new: The new sequence name
Renames a table
void
renameTable
(string $old, string $new)
-
string
$old: The current table name
-
string
$new: The new table name
Sets the default value for a column
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:
Sets whether or not the column will accept null
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
Changes the type of a column
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
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.
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:
Whether the database supports foreign keys
boolean
supportsForeignKeys
()
Redefined in descendants as:
Whether the database supports sequences
boolean
supportsSequences
()
Redefined in descendants as:
Gets the SQL statement to add a column
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
Gets the SQL statement to add a foreign key to a table
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
Gets the SQL statement to add a primary key to a table
string
_getAddPrimarySql
(string $table, $columns)
-
string
$table: The table name
-
array
$columns: The columns in the key
Redefined in descendants as:
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).
Redefined in descendants as:
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
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
Gets the SQL to create a table
This method does not process index/fulltext; indexes are not part of the SQL standard.
Redefined in descendants as:
Gets the SQL statement to drop a column from a table
string
_getDropColumnSql
(string $table, string $name)
-
string
$table: The table name
-
string
$name: The column name
Gets the SQL statement to drop a foreign key from a table
string
_getDropForeignSql
(string $table, string $name)
-
string
$table: The table name
-
string
$name: The key name
Redefined in descendants as:
Gets the SQL statement to drop an index
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:
Gets the SQL statement to drop a primary key from a table
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:
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
string
_getDropSequenceSql
(string $name)
-
string
$name: The sequence name
Gets the SQL statement to drop a table
string
_getDropTableSql
(string $name)
-
string
$name: The table name
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.
string
_getListSequencesSql
()
Redefined in descendants as:
Gets the SQL statement to rename a column in a table
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:
Gets the SQL statement to rename an index
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:
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
string
_getRenameSequenceSql
(string $old, string $new)
-
string
$old: The current sequence name
-
string
$new: The new sequence name
Redefined in descendants as:
Gets the SQL statement to rename a table
string
_getRenameTableSql
(string $old, string $new)
-
string
$old: The current table name
-
string
$new: The new table name
Redefined in descendants as:
Gets the SQL statement to set a default value on a column
string
_getSetDefaultSql
(string $table, string $column, mixed $default)
-
string
$table: The table name
-
string
$column: The column name
-
mixed
$default: The default value
Gets the SQL statement to set a column's NULL status
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:
Gets the SQL statement to set the data type of a column
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:
Gets the SQL statement to create a UNIQUE index for one or more columns
string
_getSetUniqueSql
(string $table, $columns)
-
string
$table: The table name
-
array
$columns: The columns in the unique index
Ensures the object passed is an array
array
_makeArray
(mixed $object)
Quotes an identifier or a group of identifiers
string
_quote
(mixed $thing)
-
mixed
$thing: Either a string identifier or an array of them
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.
-
Zend_Db_Adapter_Abstract
$db
Translates a DataType enum into the correct SQL syntax
string
_translateType
( $type, [mixed $argument = null])
-
Xyster_Db_DataType
$type
-
mixed
$argument
Redefined in descendants as: