rex_sql_table
in package
Uses
rex_instance_pool_trait
Class to represent sql tables.
Tags
Table of Contents
Constants
- FIRST = 'FIRST '
Methods
- addColumn() : $this
- addForeignKey() : $this
- addIndex() : $this
- alter() : void
- Alters the table.
- clearInstance() : void
- clearInstancePool() : void
- Clears the instance pool.
- create() : void
- Creates the table.
- drop() : void
- Drops the table if it exists.
- ensure() : void
- Ensures that the table exists with the given definition.
- ensureColumn() : $this
- ensureForeignKey() : $this
- ensureGlobalColumns() : $this
- ensureIndex() : $this
- ensurePrimaryIdColumn() : $this
- exists() : bool
- get() : self
- getColumn() : rex_sql_column|null
- getColumns() : array<string, rex_sql_column>
- getForeignKey() : rex_sql_foreign_key|null
- getForeignKeys() : array<string, rex_sql_foreign_key>
- getIndex() : rex_sql_index|null
- getIndexes() : array<string, rex_sql_index>
- getName() : string
- getPrimaryKey() : array<int, string>|null
- hasColumn() : bool
- hasForeignKey() : bool
- hasIndex() : bool
- removeColumn() : $this
- removeForeignKey() : $this
- removeIndex() : $this
- renameColumn() : $this
- renameForeignKey() : $this
- renameIndex() : $this
- setName() : $this
- setPrimaryKey() : $this
- addInstance() : void
- Adds an instance.
- getInstance() : static|null
- Returns the instance for the given key.
- hasInstance() : bool
- Checks whether an instance exists for the given key.
Constants
FIRST
public
mixed
FIRST
= 'FIRST '
Methods
addColumn()
public
addColumn(rex_sql_column $column[, string|null $afterColumn = null ]) : $this
Parameters
- $column : rex_sql_column
- $afterColumn : string|null = null
-
Column name or
rex_sql_table::FIRST
Return values
$thisaddForeignKey()
public
addForeignKey(rex_sql_foreign_key $foreignKey) : $this
Parameters
- $foreignKey : rex_sql_foreign_key
Return values
$thisaddIndex()
public
addIndex(rex_sql_index $index) : $this
Parameters
- $index : rex_sql_index
Return values
$thisalter()
Alters the table.
public
alter() : void
Tags
clearInstance()
public
static clearInstance(string|array{: int, : string} $key) : void
Parameters
- $key : string|array{: int, : string}
-
A table-name or a array[db-id, table-name]
clearInstancePool()
Clears the instance pool.
public
static clearInstancePool() : void
create()
Creates the table.
public
create() : void
Tags
drop()
Drops the table if it exists.
public
drop() : void
ensure()
Ensures that the table exists with the given definition.
public
ensure() : void
ensureColumn()
public
ensureColumn(rex_sql_column $column[, string|null $afterColumn = null ]) : $this
Parameters
- $column : rex_sql_column
- $afterColumn : string|null = null
-
Column name or
rex_sql_table::FIRST
Return values
$thisensureForeignKey()
public
ensureForeignKey(rex_sql_foreign_key $foreignKey) : $this
Parameters
- $foreignKey : rex_sql_foreign_key
Return values
$thisensureGlobalColumns()
public
ensureGlobalColumns([string|null $afterColumn = null ]) : $this
Parameters
- $afterColumn : string|null = null
-
Column name or
rex_sql_table::FIRST
Return values
$thisensureIndex()
public
ensureIndex(rex_sql_index $index) : $this
Parameters
- $index : rex_sql_index
Return values
$thisensurePrimaryIdColumn()
public
ensurePrimaryIdColumn() : $this
Return values
$thisexists()
public
exists() : bool
Return values
boolget()
public
static get(non-empty-string $name[, positive-int $db = 1 ]) : self
Parameters
- $name : non-empty-string
- $db : positive-int = 1
Return values
selfgetColumn()
public
getColumn(string $name) : rex_sql_column|null
Parameters
- $name : string
Return values
rex_sql_column|nullgetColumns()
public
getColumns() : array<string, rex_sql_column>
Return values
array<string, rex_sql_column>getForeignKey()
public
getForeignKey(string $name) : rex_sql_foreign_key|null
Parameters
- $name : string
Return values
rex_sql_foreign_key|nullgetForeignKeys()
public
getForeignKeys() : array<string, rex_sql_foreign_key>
Return values
array<string, rex_sql_foreign_key>getIndex()
public
getIndex(string $name) : rex_sql_index|null
Parameters
- $name : string
Return values
rex_sql_index|nullgetIndexes()
public
getIndexes() : array<string, rex_sql_index>
Return values
array<string, rex_sql_index>getName()
public
getName() : string
Return values
stringgetPrimaryKey()
public
getPrimaryKey() : array<int, string>|null
Return values
array<int, string>|null —Column names
hasColumn()
public
hasColumn(string $name) : bool
Parameters
- $name : string
Return values
boolhasForeignKey()
public
hasForeignKey(string $name) : bool
Parameters
- $name : string
Return values
boolhasIndex()
public
hasIndex(string $name) : bool
Parameters
- $name : string
Return values
boolremoveColumn()
public
removeColumn(string $name) : $this
Parameters
- $name : string
Return values
$thisremoveForeignKey()
public
removeForeignKey(string $name) : $this
Parameters
- $name : string
Return values
$thisremoveIndex()
public
removeIndex(string $name) : $this
Parameters
- $name : string
Return values
$thisrenameColumn()
public
renameColumn(string $oldName, string $newName) : $this
Parameters
- $oldName : string
- $newName : string
Tags
Return values
$thisrenameForeignKey()
public
renameForeignKey(string $oldName, string $newName) : $this
Parameters
- $oldName : string
- $newName : string
Tags
Return values
$thisrenameIndex()
public
renameIndex(string $oldName, string $newName) : $this
Parameters
- $oldName : string
- $newName : string
Tags
Return values
$thissetName()
public
setName(string $name) : $this
Parameters
- $name : string
Return values
$thissetPrimaryKey()
public
setPrimaryKey(string|array<int, string>|null $columns) : $this
Parameters
- $columns : string|array<int, string>|null
-
Column name(s)
Tags
Return values
$thisaddInstance()
Adds an instance.
protected
static addInstance(mixed $key, self $instance) : void
Parameters
- $key : mixed
-
Key
- $instance : self
-
Instance
getInstance()
Returns the instance for the given key.
protected
static getInstance(mixed $key[, callable $createCallback = null ]) : static|null
If the instance does not exist it will be created by calling the $createCallback
Parameters
- $key : mixed
-
Key
- $createCallback : callable = null
-
Callback, will be called to create a new instance
Tags
Return values
static|nullhasInstance()
Checks whether an instance exists for the given key.
protected
static hasInstance(mixed $key) : bool
Parameters
- $key : mixed
-
Key