![]() |
FOSSology
4.7.0-rc1
Open Source License Compliance by Open Source Software
|
Class to handle database schema. More...

Public Member Functions | |
| __construct (DbManager &$dbManager) | |
| setDriver (Driver &$dbDriver) | |
| applyOrEchoOnce ($sql, $stmt='') | |
| applySchema ($filename=NULL, $debug=false, $catalog='fossology', $migrateColumns=array()) | |
| Make schema match $Filename. This is a single transaction. More... | |
| applySequences () | |
| Add sequences to the database. More... | |
| applyClusters () | |
| Add clusters. More... | |
| updateSequences () | |
| Add sequences. More... | |
| applyTables ($inherits=false) | |
| Add tables/columns (dependent on sequences for default values) More... | |
| applyViews () | |
| dropConstraints () | |
| Delete constraints. More... | |
| dropIndexes () | |
| applyIndexes () | |
| applyConstraints () | |
| dropViews ($catalog) | |
| Delete views. More... | |
| dropColumnsFromTable ($columns, $table) | |
| getCurrSchema () | |
| Load the schema from the db into an array. | |
| addInheritedRelations () | |
| addTables () | |
| addViews ($viewowner) | |
| addSequences ($referencedSequencesInTableColumns) | |
| addConstraints () | |
| addIndexes () | |
| addFunctions ($schema) | |
| writeArrayEntries ($fout, $key, $value, $varname) | |
| exportSchema ($filename=NULL) | |
| Export the schema of the connected database to a file in the format readable by GetSchema(). More... | |
| makeFunctions () | |
| Create any required DB functions. | |
| applyInheritedRelations () | |
Public Attributes | |
| $debug = false | |
Private Member Functions | |
| ensureDriver () | |
Private Attributes | |
| $dbman | |
| $schema = array() | |
| $currSchema = array() | |
Class to handle database schema.
Definition at line 28 of file libschema.php.
| fo_libschema::__construct | ( | DbManager & | $dbManager | ) |
Constructor for fo_libschema
| DbManager | $dbManager |
Definition at line 58 of file libschema.php.
| fo_libschema::addConstraints | ( | ) |
Add constraints to the current schema
Definition at line 745 of file libschema.php.
| fo_libschema::addFunctions | ( | $schema | ) |
Add functions to the given schema
| array | $schema | Schema in which the functions are to be added |
FUNCTION key Definition at line 934 of file libschema.php.
| fo_libschema::addIndexes | ( | ) |
Add indexes to the current schema
Definition at line 907 of file libschema.php.
| fo_libschema::addInheritedRelations | ( | ) |
Add inherited relations to the current schema.
Definition at line 600 of file libschema.php.
| fo_libschema::addSequences | ( | $referencedSequencesInTableColumns | ) |
Add sequences to the current schema
| array | $referencedSequencesInTableColumns | Array from addTables() |
Definition at line 708 of file libschema.php.
| fo_libschema::addTables | ( | ) |
Add tables to the current schema
Definition at line 619 of file libschema.php.
| fo_libschema::addViews | ( | $viewowner | ) |
Add views to the current schema
| string | $viewowner | Owner of the view |
Definition at line 691 of file libschema.php.
| fo_libschema::applyClusters | ( | ) |
Add clusters.
The function first checks if the cluster already exists or not. The cluster is only created only if it does not exists.
Definition at line 237 of file libschema.php.
| fo_libschema::applyConstraints | ( | ) |
Add constraints (dependent on columns, views, and indexes)
Definition at line 478 of file libschema.php.
| fo_libschema::applyIndexes | ( | ) |
Add indexes (dependent on columns)
Definition at line 444 of file libschema.php.
| fo_libschema::applyInheritedRelations | ( | ) |
Apply inherits relations from schema on DB
Definition at line 1086 of file libschema.php.
| fo_libschema::applyOrEchoOnce | ( | $sql, | |
$stmt = '' |
|||
| ) |
Apply or echo the SQL statement based on the debugging status.
| string | $sql | Statement to be applied |
| string | $stmt | Name of the statement (for caching) |
Definition at line 100 of file libschema.php.
| fo_libschema::applySchema | ( | $filename = NULL, |
|
$debug = false, |
|||
$catalog = 'fossology', |
|||
$migrateColumns = array() |
|||
| ) |
Make schema match $Filename. This is a single transaction.
| string | $filename | Schema file written by schema-export.php |
| bool | $debug | Turn on debugging (echo sql as it is being executed) |
| string | $catalog | Optional database name |
| array[] | $migrateColumns | array('tablename'=>array('col1','col2'),...) of columns which should not be deleted |
Definition at line 119 of file libschema.php.
| fo_libschema::applySequences | ( | ) |
Add sequences to the database.
The function first checks if the sequence already exists or not. The sequence is only created only if it does not exists.
Definition at line 214 of file libschema.php.
| fo_libschema::applyTables | ( | $inherits = false | ) |
Add tables/columns (dependent on sequences for default values)
The function creates new tables in the database. The function also drops columns which are missing from schema and add new columns as well.
Definition at line 284 of file libschema.php.
| fo_libschema::applyViews | ( | ) |
Add views (dependent on columns)
Definition at line 365 of file libschema.php.
| fo_libschema::dropColumnsFromTable | ( | $columns, | |
| $table | |||
| ) |
Delete columns from tables
| array | $columns | Name of columns to be dropped |
| string | $table | Name of the table |
Definition at line 551 of file libschema.php.
| fo_libschema::dropConstraints | ( | ) |
Delete constraints.
Delete now, so they won't interfere with migrations.
Definition at line 389 of file libschema.php.
| fo_libschema::dropIndexes | ( | ) |
Delete indexes
Definition at line 421 of file libschema.php.
| fo_libschema::dropViews | ( | $catalog | ) |
Delete views.
Get current tables and columns used by all views. Delete if: uses table I know and column I do not know. Without this delete, we won't be able to drop columns.
| string | $catalog | Name of the catalog |
Definition at line 522 of file libschema.php.
|
private |
Ensure a driver is set on the DbManager before any query is executed.
Definition at line 76 of file libschema.php.
| fo_libschema::exportSchema | ( | $filename = NULL | ) |
Export the schema of the connected database to a file in the format readable by GetSchema().
| string | $filename | Path to the file to store the schema in. |
Definition at line 991 of file libschema.php.
| fo_libschema::setDriver | ( | Driver & | $dbDriver | ) |
Set the Driver for the DbManager
| Driver | $dbDriver |
Definition at line 67 of file libschema.php.
| fo_libschema::updateSequences | ( | ) |
Add sequences.
The function executes the UPDATE statement of the sequence.
Definition at line 261 of file libschema.php.
| fo_libschema::writeArrayEntries | ( | $fout, | |
| $key, | |||
| $value, | |||
| $varname | |||
| ) |
Write array entries to $fout as string representation
| resource | $fout | |
| string | $key | |
| array | $value | |
| string | $varname |
Definition at line 969 of file libschema.php.
|
private |
Current schema of the DB
Definition at line 52 of file libschema.php.
|
private |
DB manager to use
Definition at line 40 of file libschema.php.
| bool fo_libschema::$debug = false |
Set true to enable debugging
Definition at line 34 of file libschema.php.
|
private |
Schema to be applied
Definition at line 46 of file libschema.php.