class StaticConventions implements Conventions

Defines naming conventions for database structure using static patterns.

Methods

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

No description

string|array|null
getPrimary(string $table)

Returns primary key for table.

array|null
getHasManyReference(string $table, string $key)

Returns the referencing table name and referencing column for a has-many relationship.

array|null
getBelongsToReference(string $table, string $key)

Returns the referenced table name and local foreign key column for a belongs-to relationship.

string
getColumnFromTable(string $name)

No description

Details

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

No description

Parameters

string $primary

%s stands for table name

string $foreign

%1$s stands for key used after ->, %2$s for table name

string $table

%1$s stands for key used after ->, %2$s for table name

at line 32
string|array|null getPrimary(string $table)

Returns primary key for table.

Parameters

string $table

Return Value

string|array|null

at line 38
array|null getHasManyReference(string $table, string $key)

Returns the referencing table name and referencing column for a has-many relationship.

Example: (author, book) returns [book, author_id]

Parameters

string $table
string $key

Return Value

array|null

Exceptions

AmbiguousReferenceKeyException

at line 48
array|null getBelongsToReference(string $table, string $key)

Returns the referenced table name and local foreign key column for a belongs-to relationship.

Example: (book, author) returns [author, author_id] (book, translator) returns [author, translator_id]

Parameters

string $table
string $key

Return Value

array|null

at line 58
protected string getColumnFromTable(string $name)

No description

Parameters

string $name

Return Value

string