class ConventionalReflection extends Object implements IReflection

Reflection metadata class for a database.

Properties

protected string $primary
protected string $foreign
protected string $table

Methods

__construct($primary = 'id', $foreign = '%s_id', $table = '%s')

Create conventional structure.

string|array
getPrimary($table)

Gets primary key of $table.

array
getHasManyReference($table, $key)

Gets referenced table & referenced column.

array
getBelongsToReference($table, $key)

Gets referenced table & referencing column.

getColumnFromTable($name)

No description

Details

at line 37
__construct($primary = 'id', $foreign = '%s_id', $table = '%s')

Create conventional structure.

Parameters

$primary
$foreign
$table

at line 45
string|array getPrimary($table)

Gets primary key of $table.

Parameters

$table

Return Value

string|array

at line 51
array getHasManyReference($table, $key)

Gets referenced table & referenced column.

Example: author, book returns array(book, author_id)

Parameters

$table
$key

Return Value

array

array(referenced table, referenced column)

Exceptions

MissingReferenceException
AmbiguousReferenceKeyException

at line 61
array getBelongsToReference($table, $key)

Gets referenced table & referencing column.

Example book, author returns array(author, author_id) book, translator returns array(author, translator_id)

Parameters

$table
$key

Return Value

array

array(referenced table, referencing column)

Exceptions

MissingReferenceException

at line 71
protected getColumnFromTable($name)

No description

Parameters

$name