class Structure implements IStructure

Cached reflection of database structure.

Traits

Strict class for better experience.

Properties

protected Connection $connection
protected Cache $cache
protected array $structure
protected bool $isRebuilt

Methods

__construct(Connection $connection, IStorage $cacheStorage)

No description

array
getTables()

Returns tables list.

array
getColumns(string $table)

Returns table columns list.

string|array|null
getPrimaryKey(string $table)

No description

string|null
getPrimaryAutoincrementKey(string $table)

Returns autoincrement primary key name.

string|null
getPrimaryKeySequence(string $table)

Returns table primary key sequence.

array|null
getHasManyReference(string $table, string $targetTable = null)

Returns hasMany reference.

array|null
getBelongsToReference(string $table, string $column = null)

Returns belongsTo reference.

void
rebuild()

Rebuilds database structure cache.

bool
isRebuilt()

Returns true if database cached structure has been rebuilt.

void
needStructure()

No description

array
loadStructure()

No description

analyzePrimaryKey(array $columns)

No description

void
analyzeForeignKeys(array $structure, string $table)

No description

string
resolveFQTableName(string $table)

No description

Details

at line 35
__construct(Connection $connection, IStorage $cacheStorage)

Parameters

Connection $connection
IStorage $cacheStorage

at line 42
array getTables()

Returns tables list.

Return Value

array

at line 49
array getColumns(string $table)

Returns table columns list.

Parameters

string $table

Return Value

array

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

Parameters

string $table

Return Value

string|array|null

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

Returns autoincrement primary key name.

Parameters

string $table

Return Value

string|null

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

Returns table primary key sequence.

Parameters

string $table

Return Value

string|null

at line 123
array|null getHasManyReference(string $table, string $targetTable = null)

Returns hasMany reference.

If a targetTable is not provided, returns references for all tables.

Parameters

string $table
string $targetTable

Return Value

array|null

at line 144
array|null getBelongsToReference(string $table, string $column = null)

Returns belongsTo reference.

If a column is not provided, returns references for all columns.

Parameters

string $table
string $column

Return Value

array|null

at line 159
void rebuild()

Rebuilds database structure cache.

Return Value

void

at line 166
bool isRebuilt()

Returns true if database cached structure has been rebuilt.

Return Value

bool

at line 172
protected void needStructure()

Return Value

void

at line 185
array loadStructure()

Return Value

array

at line 222
protected analyzePrimaryKey(array $columns)

Parameters

array $columns

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

Parameters

array $structure
string $table

Return Value

void

at line 257
protected string resolveFQTableName(string $table)

Parameters

string $table

Return Value

string