Path

ez components / documentation / api reference / 1.1.1 / databaseschema


eZ Components 1.1.1

DatabaseSchema: ezcDbSchemaCommonSqlWriter

[ Tutorial ] [ Class tree ] [ Element index ] [ ChangeLog ] [ Credits ]

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.

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

Method Description
ezcDbSchemaMysqlWriter::generateAddFieldSql() Adds a "alter table" query to add the field $fieldName to $tableName with the definition $fieldDefinition.

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

Method Description
ezcDbSchemaMysqlWriter::generateAddIndexSql() Adds a "alter table" query to add the index $indexName to the table $tableName with definition $indexDefinition to the internal list of queries

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

Method Description
ezcDbSchemaMysqlWriter::generateChangeFieldSql() Adds a "alter table" query to change the field $fieldName to $tableName with the definition $fieldDefinition.

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

Name Type Description
$tableName string  
$tableDefinition ezcDbSchemaTable  

Redefined in descendants as

Method Description
ezcDbSchemaMysqlWriter::generateCreateTableSql() Adds a "create table" query for the table $tableName with definition $tableDefinition to the internal list of queries.

generateDefault

string generateDefault( string $type, mixed $value )
Returns an appropriate default value for $type with $value.

Parameters

Name Type Description
$type string  
$value mixed  

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

void generateDiffSchemaTableAsSql( string $tableName, ezcDbSchemaTableDiff $tableDiff )
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

Method Description
ezcDbSchemaMysqlWriter::generateDiffSchemaTableAsSql() Generates queries to upgrade a the table $tableName with the differences in $tableDiff.

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

Method Description
ezcDbSchemaMysqlWriter::generateDropFieldSql() Adds a "alter table" query to drop the field $fieldName from $tableName.

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

Method Description
ezcDbSchemaMysqlWriter::generateDropIndexSql() Adds a "alter table" query to remote the index $indexName from the table $tableName to the internal list of queries.

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

Method Description
ezcDbSchemaMysqlWriter::generateDropTableSql() Adds a "drop table" query for the table $tableName to the internal list of queries.

generateFieldSql

string generateFieldSql( string $fieldName, ezcDbSchemaField $fieldDefinition )
Returns a column definition for $fieldName with definition $fieldDefinition.

Parameters

Name Type Description
$fieldName string  
$fieldDefinition ezcDbSchemaField  

Redefined in descendants as

Method Description
ezcDbSchemaMysqlWriter::generateFieldSql() Returns a column definition for $fieldName with definition $fieldDefinition.

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: Thu, 01 Nov 2007