DatabaseSchema: ezcDbSchema
[ ]
[ ]
[ ]
[ ]
[ ]
Class: ezcDbSchema
|
ezcDbSchema is the main class for schema operations. [
source]
ezcDbSchema represents the schema itself and provide proxy methods to the handlers that are able to load/save schemas from/to files, databases or other sources/destinations, depending on available schema handlers.
A database schema is a definition of all the tables inside a database, including field definitions and indexes.
Constants
DATABASE
= 2
|
Used by reader and writer classes to inform that it implements a database based handler. |
FILE
= 1
|
Used by reader and writer classes to inform that it implements a file based handler. |
Member Variables
|
public array(string) |
$supportedTypes
= array( 'integer', 'boolean', 'float', 'decimal', 'timestamp', 'time', 'date', 'text', 'blob', 'clob' )
A list of all the supported database filed types |
Method Summary
|
public ezcDbSchema |
__construct(
$schema, [$data = array()] )
Constructs a new ezcDbSchema object with schema definition $schema. |
|
public array(string) |
convertToDDL(
$db )
Returns the $db specific SQL queries that would create the tables defined in the schema. |
|
public static void |
createFromDb(
$db )
Factory method to create a ezcDbSchema object from the database $db. |
|
public static void |
createFromFile(
$format, $file )
Factory method to create a ezcDbSchema object from the file $file with the format $format. |
|
public array |
getData(
)
Returns the internal data. |
|
public array(string=>ezcDbSchemaTable) |
getSchema(
)
Returns the internal schema. |
|
public void |
writeToDb(
$db )
Creates the tables defined in the schema into the database specified through $db. |
|
public void |
writeToFile(
$format, $file )
Writes the schema to the file $file in format $format. |
Methods
__construct
ezcDbSchema __construct(
$schema, [array
$data = array()] )
Constructs a new ezcDbSchema object with schema definition $schema.
Parameters
| Name |
Type |
Description |
$schema |
array(ezcDbSchemaTable) |
|
$data |
array |
|
convertToDDL
array(string) convertToDDL(
$db )
Returns the $db specific SQL queries that would create the tables defined in the schema.
Parameters
Throws
| Class | Description |
ezcDbSchemaInvalidWriterClassException |
if the handler associated with the $format is not a database schema writer. |
createFromDb
void createFromDb(
$db )
Factory method to create a ezcDbSchema object from the database $db.
Parameters
Throws
| Class | Description |
ezcDbSchemaInvalidReaderClassException |
if the handler associated with the $format is not a database schema reader. |
createFromFile
void createFromFile(
string
$format, string
$file )
Factory method to create a ezcDbSchema object from the file $file with the format $format.
Parameters
| Name |
Type |
Description |
$format |
string |
|
$file |
string |
|
Throws
| Class | Description |
ezcDbSchemaInvalidReaderClassException |
if the handler associated with the $format is not a file schema reader. |
getData
array getData(
)
Returns the internal data.
This data is not used anywhere though.
getSchema
array(string=>ezcDbSchemaTable) getSchema(
)
Returns the internal schema.
writeToDb
void writeToDb(
$db )
Creates the tables defined in the schema into the database specified through $db.
Parameters
Throws
| Class | Description |
ezcDbSchemaInvalidWriterClassException |
if the handler associated with the $format is not a database schema writer. |
writeToFile
void writeToFile(
string
$format, string
$file )
Writes the schema to the file $file in format $format.
Parameters
| Name |
Type |
Description |
$format |
string |
|
$file |
string |
|
Throws
| Class | Description |
ezcDbSchemaInvalidWriterClassException |
if the handler associated with the $format is not a file schema writer. |
Last updated: Thu, 01 Nov 2007