eZ Publish  [4.2]
eZLintSchema Class Reference

Provides lint checking of database schemas. More...

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

List of all members.

Public Member Functions

 data ($schema=false, $tableNameList=false, $params=array())
 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=array())
 generateTableInsert ($tableName, $tableDef, $dataEntries, $params)
 generateTableSchema ($table, $tableDef, $params)
 generateUpgradeFile ($differences, $params=array())
 isLintChecked ()
 isMultiInsertSupported ()
 otherSchema ()
 schema ($params=array())
 schemaName ()
 schemaType ()
 shortenIdentifier ($identifier, $limit, $shortenList)
 validate ()

Public Attributes

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

Private Member Functions

 lintCheckSchema (&$schema)

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().

Definition at line 60 of file ezlintschema.php.


Member Function Documentation

eZLintSchema::data ( schema = false,
tableNameList = false,
params = array() 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 417 of file ezlintschema.php.

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

Definition at line 68 of file ezlintschema.php.

eZLintSchema::generateAddFieldSql ( table,
field_name,
added_field,
params 
) [virtual]

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

Implements eZDBSchemaInterface.

Definition at line 473 of file ezlintschema.php.

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

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

Definition at line 497 of file ezlintschema.php.

eZLintSchema::generateAlterFieldSql ( table,
field_name,
changed_field,
params 
) [virtual]

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

Implements eZDBSchemaInterface.

Definition at line 481 of file ezlintschema.php.

eZLintSchema::generateDataFile ( schema,
data,
params 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 441 of file ezlintschema.php.

eZLintSchema::generateDataValueTextSQL ( fieldDef,
value 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 521 of file ezlintschema.php.

eZLintSchema::generateDropFieldSql ( table,
field_name,
params 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 489 of file ezlintschema.php.

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

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

Definition at line 505 of file ezlintschema.php.

eZLintSchema::generateDropTable ( table,
params 
)

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

Definition at line 465 of file ezlintschema.php.

eZLintSchema::generateSchemaFile ( schema,
params = array() 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 425 of file ezlintschema.php.

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

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

Reimplemented from eZDBSchemaInterface.

Definition at line 457 of file ezlintschema.php.

eZLintSchema::generateTableSchema ( table,
tableDef,
params 
) [virtual]

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

Implements eZDBSchemaInterface.

Definition at line 449 of file ezlintschema.php.

eZLintSchema::generateUpgradeFile ( differences,
params = array() 
)

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

Reimplemented from eZDBSchemaInterface.

Definition at line 433 of file ezlintschema.php.

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

Definition at line 116 of file ezlintschema.php.

eZLintSchema::isMultiInsertSupported ( )

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

Reimplemented from eZDBSchemaInterface.

Definition at line 513 of file ezlintschema.php.

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.

Definition at line 151 of file ezlintschema.php.

Referenced by schema(), and validate().

eZLintSchema::otherSchema ( )
Returns:
The schema object which is being lint checked.

Definition at line 108 of file ezlintschema.php.

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.

Definition at line 80 of file ezlintschema.php.

eZLintSchema::schemaName ( ) [virtual]

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

Implements eZDBSchemaInterface.

Definition at line 537 of file ezlintschema.php.

eZLintSchema::schemaType ( ) [virtual]

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

Implements eZDBSchemaInterface.

Definition at line 529 of file ezlintschema.php.

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

Definition at line 124 of file ezlintschema.php.

Referenced by lintCheckSchema().

eZLintSchema::validate ( )

Runs lint checker on all tables, indexes and fields.

Reimplemented from eZDBSchemaInterface.

Definition at line 100 of file ezlintschema.php.


Member Data Documentation

eZLintSchema::$CorrectSchema

The corrected schema.

Definition at line 546 of file ezlintschema.php.

eZLintSchema::$IsLintChecked

Whether the schema has been checked or not.

Definition at line 548 of file ezlintschema.php.

eZLintSchema::$OtherSchema

eZDBSchemaInterface object which should be lint checked

Definition at line 544 of file ezlintschema.php.


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