PHP Класс PMA\libraries\Table

Показать файл Открыть проект Примеры использования класса

Открытые свойства

Свойство Тип Описание
$engine engine (innodb, myisam, bdb, ...)
$errors errors occurred
$messages messages
$type type (view, base table, system view)
$uiprefs UI preferences

Защищенные свойства (Protected)

Свойство Тип Описание
$_db_name database name
$_dbi DatabaseInterface
$_name table name

Открытые методы

Метод Описание
__construct ( string $table_name, string $db_name, DatabaseInterface $dbi = null ) Constructor
__toString ( ) : string returns table name
checkIfMinRecordsExist ( integer $min_records ) : boolean Checks if the number of records in a table is at least equal to $min_records
countRecords ( boolean $force_exact = false ) : mixed Counts and returns (or displays) the number of records in a table
duplicateInfo ( string $work, string $pma_table, array $get_fields, array $where_fields, array $new_fields ) : integer | boolean Inserts existing entries in a PMA_* table by reading a value from an old entry
generateAlter ( string $oldcol, string $newcol, string $type, string $length, string $attribute, string $collation, boolean | string $null, string $default_type, string $default_value, string $extra, string $comment, string $virtuality, string $expression, string $move_to ) : string Generates column specification for ALTER syntax
generateFieldSpec ( string $name, string $type, string $length = '', string $attribute = '', string $collation = '', boolean | string $null = false, string $default_type = 'USER_DEFINED', string $default_value = '', string $extra = '', string $comment = '', string $virtuality = '', string $expression = '', string $move_to = '' ) : string generates column specification for ALTER or CREATE TABLE syntax
getColumnGenerationExpression ( string $column = null ) : array | boolean Returns the generation expression for virtual columns
getColumns ( boolean $backquoted = true, boolean $fullName = true ) : array Get all columns
getColumnsMeta ( ) : mixed Get meta info for fields in table
getColumnsWithIndex ( integer $types ) : array Get columns with indexes
getDbName ( boolean $backquoted = false ) : string returns database name for this table
getFullName ( boolean $backquoted = false ) : string returns full name for table, including database name
getIndex ( string $index ) : Index Get index with index name
getIndexedColumns ( boolean $backquoted = true, boolean $fullName = true ) : array Get all indexed columns
getLastError ( ) : string return the last error
getLastMessage ( ) : string return the last message
getName ( boolean $backquoted = false ) : string returns table name
getNameAndTypeOfTheColumns ( ) : array Function to get the name and type of the columns of a table
getNonGeneratedColumns ( boolean $backquoted = true ) : array Get non-generated columns in table
getRealRowCountTable ( ) : number Returns the real row count for a table
getReservedColumnNames ( ) : array Get all column names which are MySQL reserved words
getSqlQueryForIndexCreateOrEdit ( Index $index, &$error ) : string Function to get the sql query for index creation or edit
getStatusInfo ( string $info = null, boolean $force_read = false, boolean $disable_error = false ) : mixed Returns full table status info, or specific if $info provided this info is collected from information_schema
getUiProp ( string $property ) : mixed Get a property from UI preferences.
getUniqueColumns ( boolean $backquoted = true, boolean $fullName = true ) : array Get all unique columns
isEngine ( $engine ) : boolean Checks the storage engine used to create table
isMerge ( ) : boolean Checks if this is a merge table
isUpdatableView ( ) : boolean Returns whether the table is actually an updatable view
isValidName ( string $table_name, boolean $is_backquoted = false ) : boolean checks if given name is a valid table name, currently if not empty, trailing spaces, '.', '/' and '\'
isView ( ) : boolean returns whether the table is actually a view
moveCopy ( string $source_db, string $source_table, string $target_db, string $target_table, string $what, boolean $move, string $mode ) : boolean Copies or renames table
removeUiProp ( string $property ) : true | Message Remove a property from UI preferences.
rename ( string $new_name, string $new_db = null ) : boolean renames table
setUiProp ( string $property, mixed $value, string $table_create_time = null ) : boolean | Message Set a property from UI preferences.
showCreate ( ) : mixed Returns the CREATE statement for this table
updateDisplayField ( string $disp, string $display_field, array $cfgRelation ) : boolean Function to handle update for display field
updateForeignKeys ( array $destination_foreign_db, array $multi_edit_columns_name, array $destination_foreign_table, array $destination_foreign_column, array $options_array, string $table, array $existrel_foreign ) : array Function to handle foreign key updates
updateInternalRelations ( array $multi_edit_columns_name, array $destination_db, array $destination_table, array $destination_column, array $cfgRelation, array | null $existrel ) : boolean Function to get update query for updating internal relations

Защищенные методы

Метод Описание
getUiPrefsFromDb ( ) : array Return UI preferences for this table from phpMyAdmin database.
loadUiPrefs ( ) : void Loads the UI preferences for this table.
saveUiPrefsToDb ( ) : true | Message Save this table's UI preferences into phpMyAdmin database.

Приватные методы

Метод Описание
_formatColumns ( array $indexed, boolean $backquoted, boolean $fullName ) : array Formats lists of columns
_getSQLToCreateForeignKey ( string $table, array $field, string $foreignDb, string $foreignTable, array $foreignField, string $name = null, string $onDelete = null, string $onUpdate = null ) : string Returns the SQL query for foreign key constraint creation

Описание методов

__construct() публичный Метод

Constructor
public __construct ( string $table_name, string $db_name, DatabaseInterface $dbi = null )
$table_name string table name
$db_name string database name
$dbi DatabaseInterface database interface for the table

__toString() публичный Метод

returns table name
См. также: Table::getName()
public __toString ( ) : string
Результат string table name

checkIfMinRecordsExist() публичный Метод

Checks if the number of records in a table is at least equal to $min_records
public checkIfMinRecordsExist ( integer $min_records ) : boolean
$min_records integer Number of records to check for in a table
Результат boolean True, if at least $min_records exist, False otherwise.

countRecords() публичный Метод

Counts and returns (or displays) the number of records in a table
public countRecords ( boolean $force_exact = false ) : mixed
$force_exact boolean whether to force an exact count
Результат mixed the number of records if "retain" param is true, otherwise true

duplicateInfo() публичный статический Метод

Inserts existing entries in a PMA_* table by reading a value from an old entry
public static duplicateInfo ( string $work, string $pma_table, array $get_fields, array $where_fields, array $new_fields ) : integer | boolean
$work string The array index, which Relation feature to check ('relwork', 'commwork', ...)
$pma_table string The array index, which PMA-table to update ('bookmark', 'relation', ...)
$get_fields array Which fields will be SELECT'ed from the old entry
$where_fields array Which fields will be used for the WHERE query (array('FIELDNAME' => 'FIELDVALUE'))
$new_fields array Which fields will be used as new VALUES. These are the important keys which differ from the old entry (array('FIELDNAME' => 'NEW FIELDVALUE'))
Результат integer | boolean

generateAlter() публичный статический Метод

Generates column specification for ALTER syntax
См. также: Table::generateFieldSpec()
public static generateAlter ( string $oldcol, string $newcol, string $type, string $length, string $attribute, string $collation, boolean | string $null, string $default_type, string $default_value, string $extra, string $comment, string $virtuality, string $expression, string $move_to ) : string
$oldcol string old column name
$newcol string new column name
$type string type ('INT', 'VARCHAR', 'BIT', ...)
$length string length ('2', '5,2', '', ...)
$attribute string attribute
$collation string collation
$null boolean | string with 'NULL' or 'NOT NULL'
$default_type string whether default is CURRENT_TIMESTAMP, NULL, NONE, USER_DEFINED
$default_value string default value for USER_DEFINED default type
$extra string 'AUTO_INCREMENT'
$comment string field comment
$virtuality string virtuality of the column
$expression string expression for the virtual column
$move_to string new position for column
Результат string field specification

generateFieldSpec() статический публичный Метод

generates column specification for ALTER or CREATE TABLE syntax
static public generateFieldSpec ( string $name, string $type, string $length = '', string $attribute = '', string $collation = '', boolean | string $null = false, string $default_type = 'USER_DEFINED', string $default_value = '', string $extra = '', string $comment = '', string $virtuality = '', string $expression = '', string $move_to = '' ) : string
$name string name
$type string type ('INT', 'VARCHAR', 'BIT', ...)
$length string length ('2', '5,2', '', ...)
$attribute string attribute
$collation string collation
$null boolean | string with 'NULL' or 'NOT NULL'
$default_type string whether default is CURRENT_TIMESTAMP, NULL, NONE, USER_DEFINED
$default_value string default value for USER_DEFINED default type
$extra string 'AUTO_INCREMENT'
$comment string field comment
$virtuality string virtuality of the column
$expression string expression for the virtual column
$move_to string new position for column
Результат string field specification

getColumnGenerationExpression() публичный Метод

Returns the generation expression for virtual columns
public getColumnGenerationExpression ( string $column = null ) : array | boolean
$column string name of the column
Результат array | boolean associative array of column name and their expressions or false on failure

getColumns() публичный Метод

returns an array with all columns
public getColumns ( boolean $backquoted = true, boolean $fullName = true ) : array
$backquoted boolean whether to quote name with backticks ``
$fullName boolean whether to include full name of the table as a prefix
Результат array

getColumnsMeta() публичный Метод

Get meta info for fields in table
public getColumnsMeta ( ) : mixed
Результат mixed

getColumnsWithIndex() публичный Метод

Get columns with indexes
public getColumnsWithIndex ( integer $types ) : array
$types integer types bitmask
Результат array an array of columns

getDbName() публичный Метод

returns database name for this table
public getDbName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Результат string database name for this table

getFullName() публичный Метод

returns full name for table, including database name
public getFullName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Результат string

getIndex() публичный Метод

Get index with index name
public getIndex ( string $index ) : Index
$index string Index name
Результат Index

getIndexedColumns() публичный Метод

returns an array with all columns that make use of an index e.g. index(col1, col2) would return col1, col2
public getIndexedColumns ( boolean $backquoted = true, boolean $fullName = true ) : array
$backquoted boolean whether to quote name with backticks ``
$fullName boolean whether to include full name of the table as a prefix
Результат array

getLastError() публичный Метод

return the last error
public getLastError ( ) : string
Результат string the last error

getLastMessage() публичный Метод

return the last message
public getLastMessage ( ) : string
Результат string the last message

getName() публичный Метод

returns table name
public getName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Результат string table name

getNameAndTypeOfTheColumns() публичный Метод

Function to get the name and type of the columns of a table
public getNameAndTypeOfTheColumns ( ) : array
Результат array

getNonGeneratedColumns() публичный Метод

Get non-generated columns in table
public getNonGeneratedColumns ( boolean $backquoted = true ) : array
$backquoted boolean whether to quote name with backticks ``
Результат array

getRealRowCountTable() публичный Метод

Returns the real row count for a table
public getRealRowCountTable ( ) : number
Результат number

getReservedColumnNames() публичный Метод

Get all column names which are MySQL reserved words
public getReservedColumnNames ( ) : array
Результат array

getSqlQueryForIndexCreateOrEdit() публичный Метод

Function to get the sql query for index creation or edit
public getSqlQueryForIndexCreateOrEdit ( Index $index, &$error ) : string
$index Index current index
Результат string

getStatusInfo() публичный Метод

Returns full table status info, or specific if $info provided this info is collected from information_schema
public getStatusInfo ( string $info = null, boolean $force_read = false, boolean $disable_error = false ) : mixed
$info string specific information to be fetched
$force_read boolean read new rather than serving from cache
$disable_error boolean if true, disables error message
Результат mixed

getUiPrefsFromDb() защищенный Метод

Return UI preferences for this table from phpMyAdmin database.
protected getUiPrefsFromDb ( ) : array
Результат array

getUiProp() публичный Метод

Return false if the property is not found. Available property: - PROP_SORTED_COLUMN - PROP_COLUMN_ORDER - PROP_COLUMN_VISIB
public getUiProp ( string $property ) : mixed
$property string property
Результат mixed

getUniqueColumns() публичный Метод

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
public getUniqueColumns ( boolean $backquoted = true, boolean $fullName = true ) : array
$backquoted boolean whether to quote name with backticks ``
$fullName boolean whether to include full name of the table as a prefix
Результат array

isEngine() публичный Метод

Checks the storage engine used to create table
public isEngine ( $engine ) : boolean
Результат boolean True, if $engine matches the storage engine for the table, False otherwise.

isMerge() публичный Метод

If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
public isMerge ( ) : boolean
Результат boolean true if it is a merge table

isUpdatableView() публичный Метод

Returns whether the table is actually an updatable view
public isUpdatableView ( ) : boolean
Результат boolean whether the given is an updatable view

isValidName() статический публичный Метод

checks if given name is a valid table name, currently if not empty, trailing spaces, '.', '/' and '\'
См. также: https://dev.mysql.com/doc/refman/5.0/en/legal-names.html
static public isValidName ( string $table_name, boolean $is_backquoted = false ) : boolean
$table_name string name to check
$is_backquoted boolean whether this name is used inside backquotes or not
Результат boolean whether the string is valid or not

isView() публичный Метод

returns whether the table is actually a view
public isView ( ) : boolean
Результат boolean whether the given is a view

loadUiPrefs() защищенный Метод

If pmadb and table_uiprefs is set, it will load the UI preferences from phpMyAdmin database.
protected loadUiPrefs ( ) : void
Результат void

moveCopy() публичный статический Метод

Copies or renames table
public static moveCopy ( string $source_db, string $source_table, string $target_db, string $target_table, string $what, boolean $move, string $mode ) : boolean
$source_db string source database
$source_table string source table
$target_db string target database
$target_table string target table
$what string what to be moved or copied (data, dataonly)
$move boolean whether to move
$mode string mode
Результат boolean true if success, false otherwise

removeUiProp() публичный Метод

Remove a property from UI preferences.
public removeUiProp ( string $property ) : true | Message
$property string the property
Результат true | Message

rename() публичный Метод

renames table
public rename ( string $new_name, string $new_db = null ) : boolean
$new_name string new table name
$new_db string new database name
Результат boolean success

saveUiPrefsToDb() защищенный Метод

Save this table's UI preferences into phpMyAdmin database.
protected saveUiPrefsToDb ( ) : true | Message
Результат true | Message

setUiProp() публичный Метод

If pmadb and table_uiprefs is set, it will save the UI preferences to phpMyAdmin database. Available property: - PROP_SORTED_COLUMN - PROP_COLUMN_ORDER - PROP_COLUMN_VISIB
public setUiProp ( string $property, mixed $value, string $table_create_time = null ) : boolean | Message
$property string Property
$value mixed Value for the property
$table_create_time string Needed for PROP_COLUMN_ORDER and PROP_COLUMN_VISIB
Результат boolean | Message

showCreate() публичный Метод

Returns the CREATE statement for this table
public showCreate ( ) : mixed
Результат mixed

updateDisplayField() публичный Метод

Function to handle update for display field
public updateDisplayField ( string $disp, string $display_field, array $cfgRelation ) : boolean
$disp string current display field
$display_field string display field
$cfgRelation array configuration relation
Результат boolean True on update succeed or False on failure

updateForeignKeys() публичный Метод

Function to handle foreign key updates
public updateForeignKeys ( array $destination_foreign_db, array $multi_edit_columns_name, array $destination_foreign_table, array $destination_foreign_column, array $options_array, string $table, array $existrel_foreign ) : array
$destination_foreign_db array destination foreign database
$multi_edit_columns_name array multi edit column names
$destination_foreign_table array destination foreign table
$destination_foreign_column array destination foreign column
$options_array array options array
$table string current table
$existrel_foreign array db, table, column
Результат array

updateInternalRelations() публичный Метод

Function to get update query for updating internal relations
public updateInternalRelations ( array $multi_edit_columns_name, array $destination_db, array $destination_table, array $destination_column, array $cfgRelation, array | null $existrel ) : boolean
$multi_edit_columns_name array multi edit column names
$destination_db array destination tables
$destination_table array destination tables
$destination_column array destination columns
$cfgRelation array configuration relation
$existrel array | null db, table, column
Результат boolean

Описание свойств

$_db_name защищенное свойство

database name
protected $_db_name

$_dbi защищенное свойство

protected DatabaseInterface,PMA\libraries $_dbi
Результат DatabaseInterface

$_name защищенное свойство

table name
protected $_name

$engine публичное свойство

engine (innodb, myisam, bdb, ...)
public $engine

$errors публичное свойство

errors occurred
public $errors

$messages публичное свойство

messages
public $messages

$type публичное свойство

type (view, base table, system view)
public $type

$uiprefs публичное свойство

UI preferences
public $uiprefs