Base Class for Schema management.

 Methods

Constructor

__construct(array $options = array()

Parameters

$options

array

Optional load object properties.

After callback to be implemented in subclasses.

after($event = array()

Parameters

$event

After callback to be implemented in subclasses.

after(array $event = array()) : void

Parameters

$event

array

Schema object properties.

Before callback to be implemented in subclasses.

before($event = array()

Parameters

$event

Before callback to be implemented in subclasses.

before(array $event = array()) : bool

Parameters

$event

array

Schema object properties.

Returns

boolShould process continue.

Builds schema object properties.

build(array $data) : void

Parameters

$data

array

Loaded object properties.

Compares two sets of schemas.

compare(array|object $old, array|object $new = null) : array

Parameters

$old

arrayobject

Schema object or array.

$new

arrayobject

Schema object or array.

Returns

arrayTables (that are added, dropped, or changed.)

Generate the schema code for a table.

generateTable(string $table, array $fields) : string
Takes a table name and $fields array and returns a completed, escaped variable declaration to be used in schema classes.

Parameters

$table

string

Table name you want returned.

$fields

array

Array of field information to generate the table with.

Returns

stringVariable declaration for a schema class.

Reads database and creates schema tables.

load(array $options = array()) : array

Parameters

$options

array

Schema object properties.

Returns

arraySet of name and tables.

Reads database and creates schema tables.

read(array $options = array()) : array
Options - 'connection' - the db connection to use - 'name' - name of the schema - 'models' - a list of models to use, or false to ignore models

Parameters

$options

array

Schema object properties.

Returns

arrayArray indexed by name and tables.

Writes schema file from object or options.

write(array|object $object, array $options = array()) : mixed

Parameters

$object

arrayobject

Schema object or options array.

$options

array

Schema object properties to override object.

Returns

mixedFalse or string written to file.

Extended array_diff_assoc noticing change from/to NULL values.

_arrayDiffAssoc(array $array1, array $array2) : array
It behaves almost the same way as array_diff_assoc except for NULL values: if one of the values is not NULL - change is detected. It is useful in situation where one value is strval('') ant other is strval(null) - in string comparing methods this results as EQUAL, while it is not.

Parameters

$array1

array

Base array.

$array2

array

Corresponding array checked for equality.

Returns

arrayDifference as array with array(keys => values) from input array where match was not found.

Formats Schema columns from Model Object.

_columns($Obj) : array

Parameters

$Obj

Returns

arrayFormatted columns.

Compare two schema indexes.

_compareIndexes(array $new, array $old) : mixed

Parameters

$new

array

New indexes.

$old

array

Old indexes.

Returns

mixedFalse on failure or array of indexes to add and drop.

Compare two schema files table Parameters.

_compareTableParameters(array $new, array $old) : mixed

Parameters

$new

array

New indexes.

$old

array

Old indexes.

Returns

mixedFalse on failure, or an array of parameters to add & drop.

Trim the table prefix from the full table name, and return the prefix-less table.

_noPrefixTable(string $prefix, string $table) : string

Parameters

$prefix

string

Table prefix.

$table

string

Full table name.

Returns

stringPrefix-less table name.

Attempts to require the schema file specified.

_requireFile(string $path, string $file) : bool

Parameters

$path

string

Filesystem path to the file.

$file

string

Filesystem basename of the file.

Returns

boolTrue when a file was successfully included, false on failure.

Formats Schema columns from Model Object.

_values(array $values) : array

Parameters

$values

array

Options keys(type, null, default, key, length, extra).

Returns

arrayFormatted values.

 Properties

 

Connection used for read.

$connection 

Default

'default'
 

Connection used for read.

$connection : string

Default

'default'
 

File to write.

$file 

Default

'uploader_configs.php'
 

File to write.

$file : string

Default

'schema.php'
 

Name of the schema.

$name 

Default

'UploaderConfigs'
 

Name of the schema.

$name : string

Default

null
 

Path to write location.

$path : string

Default

null
 

Plugin name.

$plugin : string

Default

null
 

Set of tables.

$tables : array

Default

array()
 

$uploader_configs

$uploader_configs 

Default

array('id' => array('type' => 'integer', 'null' => false, 'default' => NULL, 'length' => 8, 'key' => 'primary'), 'name' => array('type' => 'string', 'null' => false), 'value' => array('type' => 'text', 'null' => false), 'created' => array('type' => 'datetime', 'null' => true), 'modified' => array('type' => 'datetime', 'null' => true), 'indexes' => array('PRIMARY' => array('column' => 'id', 'unique' => 1)))