DatabaseSchema: ezcDbSchemaCommonSqlWriter
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcDbSchemaCommonSqlWriter
|
An abstract class that implements some common functionality required by multiple database backends. [
source]
Descendents
| Child Class |
Description |
| ezcDbSchemaMysqlWriter |
Handler for storing database schemas and applying differences that uses MySQL as backend.
|
| ezcDbSchemaPgsqlWriter |
Handler for storing database schemas and applying differences that uses PostgreSQL as backend.
|
| ezcDbSchemaOracleWriter |
Handler for storing database schemas and applying differences that uses Oracle as backend.
|
| ezcDbSchemaSqliteWriter |
Handler for storing database schemas and applying differences that uses SQLite as backend.
|
Member Variables
|
protected array(string) |
$queries
Stores a list of queries that is generated by the various Database writing backends. |
|
protected ezcDbSchema |
$schema
Stores the schema definition where the generators operate on. |
Method Summary
|
protected abstract void |
generateAddFieldSql(
$tableName, $fieldName, $fieldDefinition )
Adds a "alter table" query to add the field $fieldName to $tableName with the definition $fieldDefinition. |
|
protected abstract void |
generateAddIndexSql(
$tableName, $indexName, $indexDefinition )
Adds a "alter table" query to add the index $indexName to the table $tableName with definition $indexDefinition to the internal list of queries |
|
protected abstract void |
generateChangeFieldSql(
$tableName, $fieldName, $fieldDefinition )
Adds a "alter table" query to change the field $fieldName to $tableName with the definition $fieldDefinition. |
|
protected void |
generateCreateTableSql(
$tableName, $tableDefinition )
Adds a "create table" query for the table $tableName with definition $tableDefinition to the internal list of queries. |
|
protected string |
generateCreateTableSqlStatement(
$tableName )
Returns a "CREATE TABLE" SQL statement part for the table $tableName. |
|
protected string |
generateDefault(
$type, $value )
Returns an appropriate default value for $type with $value. |
|
protected void |
generateDiffSchemaAsSql(
)
Generates queries to upgrade an existing database with the changes stored in $this->diffSchema. |
|
protected void |
generateDiffSchemaTableAsSql(
$tableName, $tableDiff )
Generates queries to upgrade a the table $tableName with the differences in $tableDiff. |
|
protected abstract void |
generateDropFieldSql(
$tableName, $fieldName )
Adds a "alter table" query to drop the field $fieldName from $tableName. |
|
protected abstract void |
generateDropIndexSql(
$tableName, $indexName )
Adds a "alter table" query to remote the index $indexName from the table $tableName to the internal list of queries. |
|
protected abstract void |
generateDropTableSql(
$tableName )
Adds a "drop table" query for the table $tableName to the internal list of queries. |
|
protected abstract string |
generateFieldSql(
$fieldName, $fieldDefinition )
Returns a column definition for $fieldName with definition $fieldDefinition. |
|
protected void |
generateSchemaAsSql(
)
Creates SQL DDL statements from a schema definitin. |
Methods
generateAddFieldSql
void generateAddFieldSql(
string
$tableName, string
$fieldName,
ezcDbSchemaField
$fieldDefinition )
Adds a "alter table" query to add the field $fieldName to $tableName with the definition $fieldDefinition.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$fieldName |
string |
|
$fieldDefinition |
ezcDbSchemaField |
|
Redefined in descendants as
generateAddIndexSql
void generateAddIndexSql(
string
$tableName, string
$indexName,
ezcDbSchemaIndex
$indexDefinition )
Adds a "alter table" query to add the index $indexName to the table $tableName with definition $indexDefinition to the internal list of queries
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$indexName |
string |
|
$indexDefinition |
ezcDbSchemaIndex |
|
Redefined in descendants as
generateChangeFieldSql
void generateChangeFieldSql(
string
$tableName, string
$fieldName,
ezcDbSchemaField
$fieldDefinition )
Adds a "alter table" query to change the field $fieldName to $tableName with the definition $fieldDefinition.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$fieldName |
string |
|
$fieldDefinition |
ezcDbSchemaField |
|
Redefined in descendants as
generateCreateTableSql
void generateCreateTableSql(
string
$tableName,
ezcDbSchemaTable
$tableDefinition )
Adds a "create table" query for the table $tableName with definition $tableDefinition to the internal list of queries.
Parameters
Redefined in descendants as
generateCreateTableSqlStatement
string generateCreateTableSqlStatement(
string
$tableName )
Returns a "CREATE TABLE" SQL statement part for the table $tableName.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
Redefined in descendants as
generateDefault
string generateDefault(
string
$type, mixed
$value )
Returns an appropriate default value for $type with $value.
Parameters
| Name |
Type |
Description |
$type |
string |
|
$value |
mixed |
|
Redefined in descendants as
generateDiffSchemaAsSql
void generateDiffSchemaAsSql(
)
Generates queries to upgrade an existing database with the changes stored in $this->diffSchema.
This method generates queries to migrate a database to a new version with the changes that are stored in the $this->diffSchema property. It will call different subfunctions for the different types of changes, and those functions will add queries to the internal list of queries that is stored in $this->queries.
generateDiffSchemaTableAsSql
Generates queries to upgrade a the table $tableName with the differences in $tableDiff.
This method generates queries to migrate a table to a new version with the changes that are stored in the $tableDiff property. It will call different subfunctions for the different types of changes, and those functions will add queries to the internal list of queries that is stored in $this->queries.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$tableDiff |
string |
|
Redefined in descendants as
generateDropFieldSql
void generateDropFieldSql(
string
$tableName, string
$fieldName )
Adds a "alter table" query to drop the field $fieldName from $tableName.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$fieldName |
string |
|
Redefined in descendants as
generateDropIndexSql
void generateDropIndexSql(
string
$tableName, string
$indexName )
Adds a "alter table" query to remote the index $indexName from the table $tableName to the internal list of queries.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
$indexName |
string |
|
Redefined in descendants as
generateDropTableSql
void generateDropTableSql(
string
$tableName )
Adds a "drop table" query for the table $tableName to the internal list of queries.
Parameters
| Name |
Type |
Description |
$tableName |
string |
|
Redefined in descendants as
generateFieldSql
Returns a column definition for $fieldName with definition $fieldDefinition.
Parameters
Redefined in descendants as
generateSchemaAsSql
void generateSchemaAsSql(
)
Creates SQL DDL statements from a schema definitin.
Loops over the tables in the schema definition in $this->schema and creates SQL SSL statements for this which it stores internally into the $this->queries array.
Last updated: Mon, 17 Dec 2007