eZPublish  3.9
eZLintSchema Class Reference

Provides lint checking of database schemas. More...

+ Inheritance diagram for eZLintSchema:
+ Collaboration diagram for eZLintSchema:

Public Member Functions

 data ($schema=false, $tableNameList=false)
 
 eZLintSchema ($db, $otherSchema)
 
 generateAddFieldSql ($table, $field_name, $added_field, $params)
 
 generateAddIndexSql ($table, $index_name, $added_index, $params)
 
 generateAlterFieldSql ($table, $field_name, $changed_field, $params)
 
 generateDataFile ($schema, $data, $params)
 
 generateDataValueTextSQL ($fieldDef, $value)
 
 generateDropFieldSql ($table, $field_name, $params)
 
 generateDropIndexSql ($table, $index_name, $removed_index, $params)
 
 generateDropTable ($table, $params)
 
 generateSchemaFile ($schema, $params)
 
 generateTableInsert ($tableName, $tableDef, $dataEntries, $params)
 
 generateTableSchema ($table, $tableDef, $params)
 
 generateUpgradeFile ($differences, $params)
 
 isLintChecked ()
 
 isMultiInsertSupported ()
 
 otherSchema ()
 
 schema ($params=array())
 
 schemaName ()
 
 schemaType ()
 
 shortenIdentifier ($identifier, $limit, $shortenList)
 
 validate ()
 
- Public Member Functions inherited from eZDBSchemaInterface
 appendSQLComments ($def, &$sql)
 
 data ($schema=false, $tableNameList=false, $params=array())
 
 escapeSQLString ($value)
 
 eZDBSchemaInterface ($params)
 
 insertSchema ($params=array())
 
 validate ()
 
 writeArraySchemaFile ($filename, $params=array())
 
 writeSerializedSchemaFile ($filename, $params=array())
 
 writeSQLSchemaFile ($filename, $params=array())
 
 writeUpgradeFile ($differences, $filename, $params=array())
 

Private Member Functions

 lintCheckSchema (&$schema)
 

Private Attributes

 $CorrectSchema
 The corrected schema. More...
 
 $IsLintChecked
 Whether the schema has been checked or not. More...
 
 $OtherSchema
 eZDBSchemaInterface object which should be lint checked More...
 

Additional Inherited Members

- Public Attributes inherited from eZDBSchemaInterface
 $Data
 
 $DBInstance
 eZDB instance More...
 
 $Schema
 
- Protected Member Functions inherited from eZDBSchemaInterface
 fetchTableData ($tableInfo, $offset=false, $limit=false)
 
 generateAddFieldSql ($table_name, $field_name, $def)
 
 generateAlterFieldSql ($table_name, $field_name, $def)
 
 generateDataValueTextSQL ($fieldDef, $value)
 
 generateTableInsert ($tableName, $tableDef, $dataEntries, $params)
 
 generateTableInsertSQLList ($tableName, $tableDef, $dataEntries, $params, $withClosure=true)
 
 generateTableSQLList ($tableName, $table, $params, $separateTypes)
 
 isMultiInsertSupported ()
 
 transformData (&$data, $toLocal)
 
 transformSchema (&$schema, $toLocal)
 

Detailed Description

Provides lint checking of database schemas.

Checks a given schema by going trough all tables, fields and indexes and corrects any mistakes. The result is a new schema which is returned in schema(). The new schema can then be used to diff against the original and output the changes.

The current rules apply:

  • Table names must not exceed 26 characters, configurable in dbschema.ini (LintChecker/TableLimit)
  • Field names must not exceed 30 characters, configurable in dbschema.ini (LintChecker/FieldLimit)
  • Index names must not exceed 30 characters, configurable in dbschema.ini (LintChecker/IndexLimit)
  • Index names must not be the same as table names
  • String fields cannot have NOT NULL and an empty string as DEFAULT value.
  • Primary keys must be named PRIMARY

The lint checker works by taking in another DB Schema object as parameter to the constructor. All calls will be forwarded to this object so it will work as though it were a real schema. The exception are the schema(), data() and validate() methods which makes sure the schema is correct.

To check if the schema has been checked yet call isLintChecked(). To fetch the DB schema which is checked use otherSchema().

Member Function Documentation

eZLintSchema::data (   $schema = false,
  $tableNameList = false 
)

Forwards request to data() on the otherSchema() object.

eZLintSchema::eZLintSchema (   $db,
  $otherSchema 
)

Initializes the lint checker with a foreign db schema.

Parameters
$dbA dummy parameter, pass false.
$otherSchemaThe db schema that should be checked
eZLintSchema::generateAddFieldSql (   $table,
  $field_name,
  $added_field,
  $params 
)

Forwards request to generateAddFieldSql() on the otherSchema() object.

eZLintSchema::generateAddIndexSql (   $table,
  $index_name,
  $added_index,
  $params 
)

Forwards request to generateAddIndexSql() on the otherSchema() object.

eZLintSchema::generateAlterFieldSql (   $table,
  $field_name,
  $changed_field,
  $params 
)

Forwards request to generateAlterFieldSql() on the otherSchema() object.

eZLintSchema::generateDataFile (   $schema,
  $data,
  $params 
)

Forwards request to generateDataFile() on the otherSchema() object.

eZLintSchema::generateDataValueTextSQL (   $fieldDef,
  $value 
)

Forwards request to generateDataValueTextSQL() on the otherSchema() object.

eZLintSchema::generateDropFieldSql (   $table,
  $field_name,
  $params 
)

Forwards request to generateDropFieldSql() on the otherSchema() object.

eZLintSchema::generateDropIndexSql (   $table,
  $index_name,
  $removed_index,
  $params 
)

Forwards request to generateDropIndexSql() on the otherSchema() object.

eZLintSchema::generateDropTable (   $table,
  $params 
)

Forwards request to generateDropTable() on the otherSchema() object.

eZLintSchema::generateSchemaFile (   $schema,
  $params 
)

Forwards request to generateSchemaFile() on the otherSchema() object.

eZLintSchema::generateTableInsert (   $tableName,
  $tableDef,
  $dataEntries,
  $params 
)

Forwards request to generateTableInsert() on the otherSchema() object.

eZLintSchema::generateTableSchema (   $table,
  $tableDef,
  $params 
)
virtual

Forwards request to generateTableSchema() on the otherSchema() object.

Implements eZDBSchemaInterface.

eZLintSchema::generateUpgradeFile (   $differences,
  $params 
)

Forwards request to generateUpgradeFile() on the otherSchema() object.

eZLintSchema::isLintChecked ( )
Returns
true if the lint checker has been run on the schema.
eZLintSchema::isMultiInsertSupported ( )

Forwards request to isMultiInsertSupported() on the otherSchema() object.

eZLintSchema::lintCheckSchema ( $schema)
private

Goes trough all tables, fields and indexes and makes sure they have valid names.

Returns
false if something was fixed, true otherwise.

Referenced by schema(), and validate().

eZLintSchema::otherSchema ( )
Returns
The schema object which is being lint checked.
eZLintSchema::schema (   $params = array())
virtual

Runs the lint checker on the database schema in otherSchema() and returns the new schema that is correct.

Implements eZDBSchemaInterface.

eZLintSchema::schemaName ( )
virtual

Forwards request to schemaName() on the otherSchema() object.

Implements eZDBSchemaInterface.

eZLintSchema::schemaType ( )
virtual

Forwards request to schemaType() on the otherSchema() object.

Implements eZDBSchemaInterface.

eZLintSchema::shortenIdentifier (   $identifier,
  $limit,
  $shortenList 
)
Returns
A modified version of $identifier that is guaranteed to be shorter than $limit

Referenced by lintCheckSchema().

eZLintSchema::validate ( )

Runs lint checker on all tables, indexes and fields.

Member Data Documentation

eZLintSchema::$CorrectSchema
private

The corrected schema.

Referenced by schema().

eZLintSchema::$IsLintChecked
private

Whether the schema has been checked or not.

Referenced by isLintChecked().

eZLintSchema::$OtherSchema
private

eZDBSchemaInterface object which should be lint checked

Referenced by otherSchema().


The documentation for this class was generated from the following file: