PHP Класс CakeSchema

Наследование: extends Object
Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$connection string Connection used for read.
$file string File to write.
$name string Name of the schema.
$path string Path to write location.
$plugin string Plugin name.
$tables array Set of tables.

Открытые методы

Метод Описание
__construct ( array $options = [] ) Constructor
after ( array $event = [] ) : void After callback to be implemented in subclasses.
before ( array $event = [] ) : boolean Before callback to be implemented in subclasses.
build ( array $data ) : void Builds schema object properties.
compare ( array | object $old, array | object $new = null ) : array Compares two sets of schemas.
generateTable ( string $table, array $fields ) : string Generate the schema code for a table.
load ( array $options = [] ) : array Reads database and creates schema tables.
read ( array $options = [] ) : array Reads database and creates schema tables.
write ( array | object $object, array $options = [] ) : mixed Writes schema file from object or options.

Защищенные методы

Метод Описание
_arrayDiffAssoc ( array $array1, array $array2 ) : array Extended array_diff_assoc noticing change from/to NULL values.
_columns ( &$Obj ) : array Formats Schema columns from Model Object.
_compareIndexes ( array $new, array $old ) : mixed Compare two schema indexes.
_compareTableParameters ( array $new, array $old ) : mixed Compare two schema files table Parameters.
_noPrefixTable ( string $prefix, string $table ) : string Trim the table prefix from the full table name, and return the prefix-less table.
_requireFile ( string $path, string $file ) : boolean Attempts to require the schema file specified.
_values ( array $values ) : array Formats Schema columns from Model Object.

Описание методов

__construct() публичный Метод

Constructor
public __construct ( array $options = [] )
$options array Optional load object properties.

_arrayDiffAssoc() защищенный Метод

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.
protected _arrayDiffAssoc ( array $array1, array $array2 ) : array
$array1 array Base array.
$array2 array Corresponding array checked for equality.
Результат array Difference as array with array(keys => values) from input array where match was not found.

_columns() защищенный Метод

Formats Schema columns from Model Object.
protected _columns ( &$Obj ) : array
Результат array Formatted columns.

_compareIndexes() защищенный Метод

Compare two schema indexes.
protected _compareIndexes ( array $new, array $old ) : mixed
$new array New indexes.
$old array Old indexes.
Результат mixed False on failure or array of indexes to add and drop.

_compareTableParameters() защищенный Метод

Compare two schema files table Parameters.
protected _compareTableParameters ( array $new, array $old ) : mixed
$new array New indexes.
$old array Old indexes.
Результат mixed False on failure, or an array of parameters to add & drop.

_noPrefixTable() защищенный Метод

Trim the table prefix from the full table name, and return the prefix-less table.
protected _noPrefixTable ( string $prefix, string $table ) : string
$prefix string Table prefix.
$table string Full table name.
Результат string Prefix-less table name.

_requireFile() защищенный Метод

Attempts to require the schema file specified.
protected _requireFile ( string $path, string $file ) : boolean
$path string Filesystem path to the file.
$file string Filesystem basename of the file.
Результат boolean True when a file was successfully included, false on failure.

_values() защищенный Метод

Formats Schema columns from Model Object.
protected _values ( array $values ) : array
$values array Options keys(type, null, default, key, length, extra).
Результат array Formatted values.

after() публичный Метод

After callback to be implemented in subclasses.
public after ( array $event = [] ) : void
$event array Schema object properties.
Результат void

before() публичный Метод

Before callback to be implemented in subclasses.
public before ( array $event = [] ) : boolean
$event array Schema object properties.
Результат boolean Should process continue.

build() публичный Метод

Builds schema object properties.
public build ( array $data ) : void
$data array Loaded object properties.
Результат void

compare() публичный Метод

Compares two sets of schemas.
public compare ( array | object $old, array | object $new = null ) : array
$old array | object Schema object or array.
$new array | object Schema object or array.
Результат array Tables (that are added, dropped, or changed.)

generateTable() публичный Метод

Takes a table name and $fields array and returns a completed, escaped variable declaration to be used in schema classes.
public generateTable ( string $table, array $fields ) : string
$table string Table name you want returned.
$fields array Array of field information to generate the table with.
Результат string Variable declaration for a schema class.

load() публичный Метод

Reads database and creates schema tables.
public load ( array $options = [] ) : array
$options array Schema object properties.
Результат array Set of name and tables.

read() публичный Метод

Options - 'connection' - the db connection to use - 'name' - name of the schema - 'models' - a list of models to use, or false to ignore models
public read ( array $options = [] ) : array
$options array Schema object properties.
Результат array Array indexed by name and tables.

write() публичный Метод

Writes schema file from object or options.
public write ( array | object $object, array $options = [] ) : mixed
$object array | object Schema object or options array.
$options array Schema object properties to override object.
Результат mixed False or string written to file.

Описание свойств

$connection публичное свойство

Connection used for read.
public string $connection
Результат string

$file публичное свойство

File to write.
public string $file
Результат string

$name публичное свойство

Name of the schema.
public string $name
Результат string

$path публичное свойство

Path to write location.
public string $path
Результат string

$plugin публичное свойство

Plugin name.
public string $plugin
Результат string

$tables публичное свойство

Set of tables.
public array $tables
Результат array