Exponential 6.0.13 Exponential Enterprise Open Source CMS - PHP Class Reference

Public Member Functions | Public Attributes | Private Member Functions | List of all members
eZLintSchema Class Reference
Database schema abstraction layer

Provides lint checking of database schemas. More...

Inheritance diagram for eZLintSchema:

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

## Public Attributes
| $OtherSchema
| $CorrectSchema
| The corrected schema. More...
| $IsLintChecked
| Whether the schema has been checked or not. More...
Public Attributes inherited from eZDBSchemaInterface
| $DBInstance
| eZDB instance More...
| $Schema
| $Data

## Private Member Functions
| lintCheckSchema (&$schema)

## Additional Inherited Members
Protected Member Functions inherited from eZDBSchemaInterface
| fetchTableData ( $tableInfo, $offset=false, $limit=false)
| generateTableSQLList ( $tableName, $table, $params, $separateTypes)
| generateTableInsertSQLList ( $tableName, $tableDef, $dataEntries, $params, $withClosure=true)
| transformSchema (&$schema, $toLocal)
| transformData (&$data, $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().

Definition at line 40 of file ezlintschema.php.

## Constructor & Destructor Documentation

## ◆ __construct()

eZLintSchema::__construct | ( |  | $db,
|  |  | $otherSchema
| ) |  |

Initializes the lint checker with a foreign db schema.

Parameters

  array | $db | A dummy parameter, pass false.
  eZDBSchemaInterface | $otherSchema | The db schema that should be checked

Definition at line 48 of file ezlintschema.php.

## Member Function Documentation

## ◆ data()

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

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

Reimplemented from eZDBSchemaInterface.

Definition at line 397 of file ezlintschema.php.

## ◆ generateAddFieldSql()

eZLintSchema::generateAddFieldSql | ( |  | $table,
|  |  | $field_name,
|  |  | $added_field,
|  |  | $params
| ) |  |
| virtual

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

Implements eZDBSchemaInterface.

Definition at line 453 of file ezlintschema.php.

## ◆ generateAddIndexSql()

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

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

Definition at line 477 of file ezlintschema.php.

## ◆ generateAlterFieldSql()

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

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

Implements eZDBSchemaInterface.

Definition at line 461 of file ezlintschema.php.

## ◆ generateDataFile()

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

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

Reimplemented from eZDBSchemaInterface.

Definition at line 421 of file ezlintschema.php.

## ◆ generateDataValueTextSQL()

eZLintSchema::generateDataValueTextSQL | ( |  | $fieldDef,
|  |  | $value
| ) |  |

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

Reimplemented from eZDBSchemaInterface.

Definition at line 501 of file ezlintschema.php.

## ◆ generateDropFieldSql()

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

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

Reimplemented from eZDBSchemaInterface.

Definition at line 469 of file ezlintschema.php.

## ◆ generateDropIndexSql()

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

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

Definition at line 485 of file ezlintschema.php.

## ◆ generateDropTable()

eZLintSchema::generateDropTable | ( |  | $table,
|  |  | $params
| ) |  |

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

Definition at line 445 of file ezlintschema.php.

## ◆ generateSchemaFile()

eZLintSchema::generateSchemaFile | ( |  | $schema,
|  |  | $params = `array()`
| ) |  |

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

Reimplemented from eZDBSchemaInterface.

Definition at line 405 of file ezlintschema.php.

## ◆ generateTableInsert()

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

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

Reimplemented from eZDBSchemaInterface.

Definition at line 437 of file ezlintschema.php.

## ◆ generateTableSchema()

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

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

Implements eZDBSchemaInterface.

Definition at line 429 of file ezlintschema.php.

## ◆ generateUpgradeFile()

eZLintSchema::generateUpgradeFile | ( |  | $differences,
|  |  | $params = `array()`
| ) |  |

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

Reimplemented from eZDBSchemaInterface.

Definition at line 413 of file ezlintschema.php.

## ◆ isLintChecked()

eZLintSchema::isLintChecked | ( |  | ) |

Returns
  `true` if the lint checker has been run on the schema.

Definition at line 96 of file ezlintschema.php.

References $IsLintChecked.

## ◆ isMultiInsertSupported()

eZLintSchema::isMultiInsertSupported | ( |  | ) |

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

Reimplemented from eZDBSchemaInterface.

Definition at line 493 of file ezlintschema.php.

## ◆ lintCheckSchema()

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 131 of file ezlintschema.php.

References shortenIdentifier(), and eZDebug\writeWarning().

Referenced by schema(), and validate().

## ◆ otherSchema()

eZLintSchema::otherSchema | ( |  | ) |

Returns
  The schema object which is being lint checked.

Definition at line 88 of file ezlintschema.php.

References $OtherSchema.

## ◆ schema()

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 60 of file ezlintschema.php.

References $CorrectSchema, and lintCheckSchema().

## ◆ schemaName()

eZLintSchema::schemaName | ( |  | ) |
| virtual

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

Implements eZDBSchemaInterface.

Definition at line 517 of file ezlintschema.php.

## ◆ schemaType()

eZLintSchema::schemaType | ( |  | ) |
| virtual

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

Implements eZDBSchemaInterface.

Definition at line 509 of file ezlintschema.php.

## ◆ shortenIdentifier()

eZLintSchema::shortenIdentifier | ( |  | $identifier,
|  |  | $limit,
|  |  | $shortenList
| ) |  |

Returns
  A modified version of $identifier that is guaranteed to be shorter than $limit

Definition at line 104 of file ezlintschema.php.

Referenced by lintCheckSchema().

## ◆ validate()

eZLintSchema::validate | ( |  | ) |

Runs lint checker on all tables, indexes and fields.

Reimplemented from eZDBSchemaInterface.

Definition at line 80 of file ezlintschema.php.

References lintCheckSchema().

## Member Data Documentation

## ◆ $CorrectSchema

eZLintSchema::$CorrectSchema

The corrected schema.

Definition at line 526 of file ezlintschema.php.

Referenced by schema().

## ◆ $IsLintChecked

eZLintSchema::$IsLintChecked

Whether the schema has been checked or not.

Definition at line 528 of file ezlintschema.php.

Referenced by isLintChecked().

## ◆ $OtherSchema

eZLintSchema::$OtherSchema

eZDBSchemaInterface object which should be lint checked

Definition at line 524 of file ezlintschema.php.

Referenced by otherSchema().

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

- ezlintschema.php

Copyright © 1998 – 2026 7x. All rights reserved. Licensed under the GNU GPLv2+.