|
eZ Publish
[4.2]
|
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) | |
| generateAlterFieldSql ($table_name, $field_name, $def, $params) | |
| generateDefaultDef ($table_name, $field_name, $def, $params) | |
| generateDropIndexSql ($table_name, $index_name, $def, $withClosure) | |
| 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) | |
| primaryKeyIndexName ($tableName, $indexName, $fields) | |
Handles schemas for PostgreSQL.
Definition at line 36 of file ezpgsqlschema.php.
| eZPgsqlSchema::convertFromStandardType | ( | $ | type, |
| &$ | length | ||
| ) |
Definition at line 354 of file ezpgsqlschema.php.
Referenced by generateFieldDef().
| eZPgsqlSchema::convertToStandardType | ( | $ | type, |
| &$ | length | ||
| ) |
Definition at line 416 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 917 of file ezpgsqlschema.php.
| eZPgsqlSchema::eZPgsqlSchema | ( | $ | db | ) |
| eZPgsqlSchema::fetchTableFields | ( | $ | table, |
| $ | params | ||
| ) | [private] |
Definition at line 141 of file ezpgsqlschema.php.
Referenced by schema().
| eZPgsqlSchema::fetchTableIndexes | ( | $ | table, |
| $ | params | ||
| ) | [private] |
Definition at line 252 of file ezpgsqlschema.php.
Referenced by schema().
| eZPgsqlSchema::generateAddFieldSql | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private, virtual] |
Implements eZDBSchemaInterface.
Definition at line 713 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateAddIndexSql | ( | $ | table_name, |
| $ | index_name, | ||
| $ | def, | ||
| $ | params, | ||
| $ | withClosure | ||
| ) | [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 507 of file ezpgsqlschema.php.
Referenced by generateTableArrays().
| eZPgsqlSchema::generateAlterFieldSql | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private, virtual] |
Implements eZDBSchemaInterface.
Definition at line 730 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateDefaultDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private] |
Definition at line 642 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateFieldDef().
| eZPgsqlSchema::generateDropIndexSql | ( | $ | table_name, |
| $ | index_name, | ||
| $ | def, | ||
| $ | withClosure | ||
| ) | [private] |
Definition at line 571 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateDropTable | ( | $ | table | ) | [private] |
Definition at line 912 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateFieldDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | add_default_not_null = true, |
||
| $ | params | ||
| ) | [private] |
Definition at line 587 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateTableArrays().
| eZPgsqlSchema::generateNullDef | ( | $ | table_name, |
| $ | field_name, | ||
| $ | def, | ||
| $ | params | ||
| ) | [private] |
Definition at line 692 of file ezpgsqlschema.php.
Referenced by generateAddFieldSql(), generateAlterFieldSql(), and generateFieldDef().
| eZPgsqlSchema::generateSchemaFile | ( | $ | schema, |
| $ | params = array() |
||
| ) |
| schema | database schema |
Reimplemented from eZDBSchemaInterface.
Definition at line 855 of file ezpgsqlschema.php.
| eZPgsqlSchema::generateTableArrays | ( | $ | table, |
| $ | table_def, | ||
| $ | params, | ||
| $ | withClosure | ||
| ) | [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 775 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 838 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 746 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 755 of file ezpgsqlschema.php.
| eZPgsqlSchema::isTypeLengthSupported | ( | $ | pgType | ) |
Definition at line 340 of file ezpgsqlschema.php.
Referenced by generateFieldDef().
| eZPgsqlSchema::parseDefault | ( | $ | default, |
| &$ | autoinc | ||
| ) |
Definition at line 456 of file ezpgsqlschema.php.
Referenced by fetchTableFields().
| eZPgsqlSchema::parseType | ( | $ | type_info, |
| &$ | length_info | ||
| ) |
Definition at line 327 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 411 of file ezpgsqlschema.php.
Referenced by fetchTableIndexes(), and generateAddIndexSql().
| eZPgsqlSchema::reservedKeywordList | ( | ) |
Definition at line 937 of file ezpgsqlschema.php.
Referenced by generateAddIndexSql(), and generateFieldDef().
| eZPgsqlSchema::schema | ( | $ | params = array() | ) | [virtual] |
Get SQL db schema
Implements eZDBSchemaInterface.
Definition at line 99 of file ezpgsqlschema.php.
| eZPgsqlSchema::schemaName | ( | ) | [virtual] |
Implements eZDBSchemaInterface.
Definition at line 929 of file ezpgsqlschema.php.
| eZPgsqlSchema::schemaType | ( | ) | [virtual] |
Implements eZDBSchemaInterface.
Definition at line 924 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 83 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 77 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 67 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 57 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 38 of file ezpgsqlschema.php.
Referenced by schema().