|
eZ Publish
[trunk]
|
Handles schemas for PostgreSQL. More...
Inheritance diagram for eZPgsqlSchema:
Collaboration diagram for eZPgsqlSchema:Public Member Functions | |
| convertFromStandardType ($type, &$length) | |
| convertToStandardType ($type, &$length) | |
| escapeSQLString ($value) | |
| eZPgsqlSchema ($db) | |
| generateSchemaFile ($schema, $params=array()) | |
| generateTableInsertSQLList ($tableName, $tableDef, $dataEntries, $params, $withClosure=true) | |
| generateTableSchema ($table, $table_def, $params) | |
| generateTableSQLList ($table, $table_def, $params, $separateTypes) | |
| isTypeLengthSupported ($pgType) | |
| parseDefault ($default, &$autoinc) | |
| parseType ($type_info, &$length_info) | |
| reservedKeywordList () | |
| schema ($params=array()) | |
| schemaName () | |
| schemaType () | |
Public Attributes | |
| const | FETCH_INDEX_COL_NAMES_QUERY |
| const | FETCH_INDEX_DEF_QUERY |
| const | FETCH_TABLE_DEF_QUERY |
| const | FETCH_TABLE_OID_QUERY |
| const | SHOW_TABLES_QUERY |
Private Member Functions | |
| fetchTableFields ($table, $params) | |
| fetchTableIndexes ($table, $params) | |
| generateAddFieldSql ($table_name, $field_name, $def, $params) | |
| generateAddIndexSql ($table_name, $index_name, $def, $params, $withClosure=true) | |
| generateAlterFieldSql ($table_name, $field_name, $def, $params) | |
| generateDefaultDef ($table_name, $field_name, $def, $params) | |
| generateDropFieldSql ($table_name, $field_name, $params) | |
| generateDropIndexSql ($table_name, $index_name, $def, $withClosure=true) | |
| generateDropTable ($table) | |
| generateFieldDef ($table_name, $field_name, $def, $add_default_not_null=true, $params) | |
| generateNullDef ($table_name, $field_name, $def, $params) | |
| generateTableArrays ($table, $table_def, $params, $withClosure=true) | |
| primaryKeyIndexName ($tableName, $indexName, $fields) | |
Handles schemas for PostgreSQL.
Definition at line 18 of file ezpgsqlschema.php.
| eZPgsqlSchema::convertFromStandardType | ( | $ | type, |
| &$ | length | ||
| ) |
Definition at line 337 of file ezpgsqlschema.php.
Referenced by generateFieldDef().
| eZPgsqlSchema::convertToStandardType | ( | $ | type, |
| &$ | length | ||
| ) |
Definition at line 388 of file ezpgsqlschema.php.
Referenced by parseType().
| eZPgsqlSchema::escapeSQLString | ( | $ | value | ) | [virtual] |
This escapes the string according to the current database type and returns it.
Implements eZDBSchemaInterface.
Definition at line 904 of file ezpgsqlschema.php.
| eZPgsqlSchema::eZPgsqlSchema | ( | $ | db | ) |
| eZPgsqlSchema::fetchTableFields | ( | $ | table, |
| $ | params | ||
| ) | [private] |
Definition at line 123 of file ezpgsqlschema.php.
Referenced by schema().
| eZPgsqlSchema::fetchTableIndexes | ( | $ | table, |
| $ | params | ||
| ) | [private] |
Definition at line 234 of file ezpgsqlschema.php.
Referenced by schema().
| eZPgsqlSchema::generateAddFieldSql | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private, virtual] |
Implements eZDBSchemaInterface.
Definition at line 685 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateAddIndexSql | ( | $ | table_name, |
| $ | index_name, | ||
| $ | def, | ||
| $ | params, | ||
| $ | withClosure = true |
||
| ) | [private] |
| $table_name | The table name |
| $index_name | The index name |
| $def | The index structure, see eZDBSchemaInterface for more details |
| $params | An associative array with optional parameters which controls the output of SQLs |
| $withClosure | If true then the SQLs will contain semi-colons to close them. |
Definition at line 474 of file ezpgsqlschema.php.
Referenced by generateTableArrays().
| eZPgsqlSchema::generateAlterFieldSql | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private, virtual] |
Implements eZDBSchemaInterface.
Definition at line 717 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateDefaultDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private] |
Definition at line 610 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateFieldDef().
| eZPgsqlSchema::generateDropFieldSql | ( | $ | table_name, |
| $ | field_name, | ||
| $ | params | ||
| ) | [private] |
Reimplemented from eZDBSchemaInterface.
Definition at line 702 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateDropIndexSql | ( | $ | table_name, |
| $ | index_name, | ||
| $ | def, | ||
| $ | withClosure = true |
||
| ) | [private] |
Definition at line 538 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateDropTable | ( | $ | table | ) | [private] |
Definition at line 899 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateFieldDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | add_default_not_null = true, |
||
| $ | params | ||
| ) | [private] |
Definition at line 555 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateTableArrays().
| eZPgsqlSchema::generateNullDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private] |
Definition at line 664 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateFieldDef().
| eZPgsqlSchema::generateSchemaFile | ( | $ | schema, |
| $ | params = array() |
||
| ) |
| schema | database schema |
Reimplemented from eZDBSchemaInterface.
Definition at line 842 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateTableArrays | ( | $ | table, |
| $ | table_def, | ||
| $ | params, | ||
| $ | withClosure = true |
||
| ) | [private] |
| $table | The table name |
| $table_def | The table structure, see eZDBSchemaInterface for more details |
| $params | An associative array with optional parameters which controls the output of SQLs |
| $withClosure | If true then the SQLs will contain semi-colons to close them. |
Definition at line 762 of file ezpgsqlschema.php.
Referenced by generateSchemaFile(), generateTableSchema(), and generateTableSQLList().
| eZPgsqlSchema::generateTableInsertSQLList | ( | $ | tableName, |
| $ | tableDef, | ||
| $ | dataEntries, | ||
| $ | params, | ||
| $ | withClosure = true |
||
| ) |
This calls eZDBSchemaInterface::generateTableInsertSQLList() and adds a setval SQL if the table has auto increments.
Reimplemented from eZDBSchemaInterface.
Definition at line 825 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateTableSchema | ( | $ | tableName, |
| $ | table, | ||
| $ | params | ||
| ) | [virtual] |
Generates the necessary SQLs to create the table and returns them all in a string.
| $tableName | The table name |
| $table | The table structure, see class definition for more details |
Implements eZDBSchemaInterface.
Definition at line 733 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateTableSQLList | ( | $ | tableName, |
| $ | table, | ||
| $ | params, | ||
| $ | separateTypes | ||
| ) | [virtual] |
Generates the necessary SQLs to create the table and returns them all in an array.
| $tableName | The table name |
| $table | The table structure, see class definition for more details |
| $params | An associative array with optional parameters which controls the output of SQLs |
| $separateTypes | If true then the returned array must be an associative array containing the SQL arrays split into multiple groups. The groups are:
|
Implements eZDBSchemaInterface.
Definition at line 742 of file ezpgsqlschema.php.
| eZPgsqlSchema::isTypeLengthSupported | ( | $ | pgType | ) |
Definition at line 322 of file ezpgsqlschema.php.
Referenced by generateFieldDef().
| eZPgsqlSchema::parseDefault | ( | $ | default, |
| &$ | autoinc | ||
| ) |
Definition at line 423 of file ezpgsqlschema.php.
Referenced by fetchTableFields().
| eZPgsqlSchema::parseType | ( | $ | type_info, |
| &$ | length_info | ||
| ) |
Definition at line 309 of file ezpgsqlschema.php.
Referenced by fetchTableFields().
| eZPgsqlSchema::primaryKeyIndexName | ( | $ | tableName, |
| $ | indexName, | ||
| $ | fields | ||
| ) | [private] |
The name will consist of the table name and _pkey, since it is only allowed to have one primary key pre table that shouldn't be a problem.
Definition at line 383 of file ezpgsqlschema.php.
Referenced by fetchTableIndexes(), generateAddIndexSql(), and generateDropIndexSql().
Definition at line 922 of file ezpgsqlschema.php.
Referenced by generateAddIndexSql(), generateDropFieldSql(), and generateFieldDef().
| eZPgsqlSchema::schema | ( | $ | params = array() | ) | [virtual] |
Gets SQL db schema definition by analyzing the current DB instance and return it in array format. NB: once the schema is generated, it might be cached.
| $params | supported options are 'meta_data' and 'format' |
Implements eZDBSchemaInterface.
Definition at line 81 of file ezpgsqlschema.php.
| eZPgsqlSchema::schemaName | ( | ) | [virtual] |
Implements eZDBSchemaInterface.
Definition at line 914 of file ezpgsqlschema.php.
| eZPgsqlSchema::schemaType | ( | ) | [virtual] |
Implements eZDBSchemaInterface.
Definition at line 909 of file ezpgsqlschema.php.
' SELECT a.attnum, a.attname FROM pg_catalog.pg_attribute a WHERE a.attrelid = \'<<indexrelid>>\' AND a.attnum IN (<<attids>>) AND NOT a.attisdropped ORDER BY a.attnum'
Definition at line 65 of file ezpgsqlschema.php.
Referenced by fetchTableIndexes().
' SELECT c.relname, i.* FROM pg_catalog.pg_index i, pg_catalog.pg_class c WHERE indrelid = \'<<oid>>\' AND i.indexrelid = c.oid'
Definition at line 59 of file ezpgsqlschema.php.
Referenced by fetchTableIndexes().
' SELECT a.attname, pg_catalog.format_type(a.atttypid, a.atttypmod), (SELECT substring(d.adsrc for 128) FROM pg_catalog.pg_attrdef d WHERE d.adrelid = a.attrelid AND d.adnum = a.attnum AND a.atthasdef) as default, a.attnotnull, a.attnum FROM pg_catalog.pg_attribute a WHERE a.attrelid = \'<<oid>>\' AND a.attnum > 0 AND NOT a.attisdropped ORDER BY a.attnum'
Definition at line 49 of file ezpgsqlschema.php.
Referenced by fetchTableFields().
' SELECT c.oid, n.nspname, c.relname FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE pg_catalog.pg_table_is_visible(c.oid) AND c.relname ~ \'^<<tablename>>$\' ORDER BY 2, 3'
Definition at line 39 of file ezpgsqlschema.php.
Referenced by fetchTableFields(), and fetchTableIndexes().
' SELECT n.nspname as "Schema", c.relname as "Name", CASE c.relkind WHEN \'r\' THEN \'table\' WHEN \'v\' THEN \'view\' WHEN \'i\' THEN \'index\' WHEN \'S\' THEN \'sequence\' WHEN \'s\' THEN \'special\' END as "Type", u.usename as "Owner" FROM pg_catalog.pg_class c LEFT JOIN pg_catalog.pg_user u ON u.usesysid = c.relowner LEFT JOIN pg_catalog.pg_namespace n ON n.oid = c.relnamespace WHERE c.relkind IN (\'r\',\'\') AND n.nspname NOT IN (\'pg_catalog\', \'pg_toast\') AND pg_catalog.pg_table_is_visible(c.oid) ORDER BY 1, 2'
Definition at line 20 of file ezpgsqlschema.php.
Referenced by schema().