class Structure implements IStructure

Provides database structure metadata with caching.

Properties

protected $cache
protected $structure
protected $isRebuilt

Methods

__construct(Connection $connection, Storage $cacheStorage)

No description

array
getTables()

No description

array
getColumns(string $table)

Returns all columns in a table.

string|array|null
getPrimaryKey(string $table)

No description

string|null
getPrimaryAutoincrementKey(string $table)

Returns the name of the autoincrement primary key column, or null if none exists.

string|null
getPrimaryKeySequence(string $table)

Returns the sequence name for the primary key column, or null if not applicable.

array|null
getHasManyReference(string $table)

No description

array|null
getBelongsToReference(string $table)

No description

void
rebuild()

Rebuilds structure cache.

bool
isRebuilt()

Checks whether the structure has been rebuilt from the database during this request.

void
needStructure()

Ensures the structure is loaded, from cache or from the database.

array
loadStructure()

Loads complete structure from database.

string|array|null
analyzePrimaryKey(array $columns)

No description

void
analyzeForeignKeys(array $structure, string $table)

No description

string
resolveFQTableName(string $table)

Returns normalized table name.

Details

at line 26
__construct(Connection $connection, Storage $cacheStorage)

No description

Parameters

Connection $connection
Storage $cacheStorage

at line 35
array getTables()

No description

Return Value

array

at line 42
array getColumns(string $table)

Returns all columns in a table.

Parameters

string $table

Return Value

array

at line 54
string|array|null getPrimaryKey(string $table)

No description

Parameters

string $table

Return Value

string|array|null

at line 65
string|null getPrimaryAutoincrementKey(string $table)

Returns the name of the autoincrement primary key column, or null if none exists.

Parameters

string $table

Return Value

string|null

at line 98
string|null getPrimaryKeySequence(string $table)

Returns the sequence name for the primary key column, or null if not applicable.

Parameters

string $table

Return Value

string|null

at line 124
array|null getHasManyReference(string $table)

No description

Parameters

string $table

Return Value

array|null

referencing table name => list of referencing columns

at line 133
array|null getBelongsToReference(string $table)

No description

Parameters

string $table

Return Value

array|null

local column name => referenced table name

at line 144
void rebuild()

Rebuilds structure cache.

Return Value

void

at line 154
bool isRebuilt()

Checks whether the structure has been rebuilt from the database during this request.

Return Value

bool

at line 163
protected void needStructure()

Ensures the structure is loaded, from cache or from the database.

Return Value

void

at line 177
protected array loadStructure()

Loads complete structure from database.

Return Value

array

at line 216
protected string|array|null analyzePrimaryKey(array $columns)

No description

Parameters

array $columns

Return Value

string|array|null

at line 236
protected void analyzeForeignKeys(array $structure, string $table)

No description

Parameters

array $structure
string $table

Return Value

void

at line 265
protected string resolveFQTableName(string $table)

Returns normalized table name.

Parameters

string $table

Return Value

string