Table
class Table implements Stringable (View source)
Handles everything related to tables
Properties
array | $uiprefs | ||
array | $errors | ||
array | $messages |
Methods
returns table name
return the last error
return the last message
returns table name
returns database name for this table
returns full name for table, including database name
Checks the storage engine used to create table
returns whether the table is actually a view
Returns whether the table is actually an updatable view
Checks if this is a merge table
Returns full table status info, or specific if $info provided this info is collected from information_schema
Returns the Table storage Engine for current table.
Returns the comments for current table.
Returns the collation for current table.
Returns the info about no of rows for current table.
Returns the Row format for current table.
Returns the auto increment option for current table.
Returns the array for CREATE statement for current table.
generates column specification for ALTER or CREATE TABLE syntax
Checks if the number of records in a table is at least equal to $min_records
Counts the number of records in a table
Generates column specification for ALTER syntax
checks if given name is a valid table name, currently if not empty, trailing spaces, '.', '/' and '\'
renames table
Get all unique columns
Get all indexed columns
Get all columns
Get meta info for fields in table
Get non-generated columns in table
Return UI preferences for this table from phpMyAdmin database.
Save this table's UI preferences into phpMyAdmin database.
Loads the UI preferences for this table.
Get a property from UI preferences.
Set a property from UI preferences.
Remove a property from UI preferences.
Function to get the name and type of the columns of a table
Function to handle update for display field
Function to get update query for updating internal relations
Function to handle foreign key updates
Returns the generation expression for virtual columns
Returns the CREATE statement for this table
Returns the real row count for a table
Get columns with indexes
Details
__construct(string $name, string $dbName, DatabaseInterface $dbi)
No description
string
__toString()
returns table name
static Table
get(string $tableName, string $dbName, DatabaseInterface $dbi)
Table getter
string
getLastError()
return the last error
string
getLastMessage()
return the last message
string
getName(bool $backquoted = false)
returns table name
string
getDbName(bool $backquoted = false)
returns database name for this table
string
getFullName(bool $backquoted = false)
returns full name for table, including database name
bool
isEngine(array|string $engine)
Checks the storage engine used to create table
bool
isView()
returns whether the table is actually a view
bool
isUpdatableView()
Returns whether the table is actually an updatable view
bool
isMerge()
Checks if this is a merge table
If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
array|string|int|null
getStatusInfo(string|null $info = null)
Returns full table status info, or specific if $info provided this info is collected from information_schema
string
getStorageEngine()
Returns the Table storage Engine for current table.
string
getComment()
Returns the comments for current table.
string
getCollation()
Returns the collation for current table.
int
getNumRows()
Returns the info about no of rows for current table.
string
getRowFormat()
Returns the Row format for current table.
string
getAutoIncrement()
Returns the auto increment option for current table.
array
getCreateOptions()
Returns the array for CREATE statement for current table.
static string
generateFieldSpec(string $name, string $type, string $length = '', string $attribute = '', string $collation = '', bool|string $null = false, string $defaultType = 'USER_DEFINED', string $defaultValue = '', string $extra = '', string $comment = '', string $virtuality = '', string $expression = '', string $moveTo = '', array|null $columnsWithIndex = null, string|null $oldColumnName = null)
generates column specification for ALTER or CREATE TABLE syntax
bool
checkIfMinRecordsExist(int $minRecords = 0)
Checks if the number of records in a table is at least equal to $min_records
int
countRecords(bool $forceExact = false)
Counts the number of records in a table
static string
generateAlter(string $oldcol, string $newcol, string $type, string $length, string $attribute, string $collation, bool|string $null, string $defaultType, string $defaultValue, string $extra, string $comment, string $virtuality, string $expression, string $moveTo, array|null $columnsWithIndex = null)
Generates column specification for ALTER syntax
static bool
isValidName(string $tableName, bool $isBackquoted = false)
checks if given name is a valid table name, currently if not empty, trailing spaces, '.', '/' and '\'
bool
rename(string $newName, string|null $newDb = null)
renames table
array
getUniqueColumns(bool $backquoted = true, bool $fullName = true)
Get all unique columns
returns an array with all columns with unique content, in fact these are all columns being single indexed in PRIMARY or UNIQUE
e.g.
- PRIMARY(id) // id
- UNIQUE(name) // name
- PRIMARY(fk_id1, fk_id2) // NONE
- UNIQUE(x,y) // NONE
array
getIndexedColumns(bool $backquoted = true, bool $fullName = true)
Get all indexed columns
returns an array with all columns that make use of an index
e.g. index(col1, col2) would return col1, col2
array
getColumns(bool $backquoted = true, bool $fullName = true)
Get all columns
returns an array with all columns
array
getColumnsMeta()
Get meta info for fields in table
array
getNonGeneratedColumns(bool $backquoted = true)
Get non-generated columns in table
protected array
getUiPrefsFromDb(UiPreferencesFeature|null $uiPreferencesFeature)
Return UI preferences for this table from phpMyAdmin database.
protected Message
saveUiPrefsToDb(UiPreferencesFeature $uiPreferencesFeature)
Save this table's UI preferences into phpMyAdmin database.
protected void
loadUiPrefs()
Loads the UI preferences for this table.
If pmadb and table_uiprefs is set, it will load the UI preferences from phpMyAdmin database.
mixed
getUiProp(UiProperty $property)
Get a property from UI preferences.
Return false if the property is not found.
Message
setUiProp(UiProperty $property, array|string $value, string|null $tableCreateTime = null)
Set a property from UI preferences.
If pmadb and table_uiprefs is set, it will save the UI preferences to phpMyAdmin database.
Message
removeUiProp(UiProperty $property)
Remove a property from UI preferences.
array
getNameAndTypeOfTheColumns()
Function to get the name and type of the columns of a table
Index
getIndex(string $index)
Get index with index name
void
updateDisplayField(string $displayField, DisplayFeature $displayFeature)
Function to handle update for display field
bool
updateInternalRelations(array $multiEditColumnsName, array $destinationDb, array $destinationTable, array $destinationColumn, RelationFeature $relationFeature, array|null $existrel)
Function to get update query for updating internal relations
array
updateForeignKeys(array $destinationForeignDb, array $multiEditColumnsName, array $destinationForeignTable, array $destinationForeignColumn, array $optionsArray, string $table, array $existrelForeign)
Function to handle foreign key updates
array|bool
getColumnGenerationExpression(string|null $column = null)
Returns the generation expression for virtual columns
string
showCreate()
Returns the CREATE statement for this table
int|null
getRealRowCountTable()
Returns the real row count for a table
array
getColumnsWithIndex(int $types)
Get columns with indexes