PHP Class PMA\libraries\Table

Afficher le fichier Open project: phpmyadmin/phpmyadmin Class Usage Examples

Méthodes publiques

Свойство Type Description
$engine engine (innodb, myisam, bdb, ...)
$errors errors occurred
$messages messages
$type type (view, base table, system view)
$uiprefs UI preferences

Protected Properties

Свойство Type Description
$_db_name database name
$_dbi DatabaseInterface
$_name table name

Méthodes publiques

Méthode Description
__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

Méthodes protégées

Méthode Description
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.

Private Methods

Méthode Description
_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

Method Details

__construct() public méthode

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() public méthode

returns table name
See also: Table::getName()
public __toString ( ) : string
Résultat string table name

checkIfMinRecordsExist() public méthode

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
Résultat boolean True, if at least $min_records exist, False otherwise.

countRecords() public méthode

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
Résultat mixed the number of records if "retain" param is true, otherwise true

duplicateInfo() public static méthode

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'))
Résultat integer | boolean

generateAlter() public static méthode

Generates column specification for ALTER syntax
See also: 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
Résultat string field specification

generateFieldSpec() static public méthode

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
Résultat string field specification

getColumnGenerationExpression() public méthode

Returns the generation expression for virtual columns
public getColumnGenerationExpression ( string $column = null ) : array | boolean
$column string name of the column
Résultat array | boolean associative array of column name and their expressions or false on failure

getColumns() public méthode

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
Résultat array

getColumnsMeta() public méthode

Get meta info for fields in table
public getColumnsMeta ( ) : mixed
Résultat mixed

getColumnsWithIndex() public méthode

Get columns with indexes
public getColumnsWithIndex ( integer $types ) : array
$types integer types bitmask
Résultat array an array of columns

getDbName() public méthode

returns database name for this table
public getDbName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Résultat string database name for this table

getFullName() public méthode

returns full name for table, including database name
public getFullName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Résultat string

getIndex() public méthode

Get index with index name
public getIndex ( string $index ) : Index
$index string Index name
Résultat Index

getIndexedColumns() public méthode

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
Résultat array

getLastError() public méthode

return the last error
public getLastError ( ) : string
Résultat string the last error

getLastMessage() public méthode

return the last message
public getLastMessage ( ) : string
Résultat string the last message

getName() public méthode

returns table name
public getName ( boolean $backquoted = false ) : string
$backquoted boolean whether to quote name with backticks ``
Résultat string table name

getNameAndTypeOfTheColumns() public méthode

Function to get the name and type of the columns of a table
public getNameAndTypeOfTheColumns ( ) : array
Résultat array

getNonGeneratedColumns() public méthode

Get non-generated columns in table
public getNonGeneratedColumns ( boolean $backquoted = true ) : array
$backquoted boolean whether to quote name with backticks ``
Résultat array

getRealRowCountTable() public méthode

Returns the real row count for a table
public getRealRowCountTable ( ) : number
Résultat number

getReservedColumnNames() public méthode

Get all column names which are MySQL reserved words
public getReservedColumnNames ( ) : array
Résultat array

getSqlQueryForIndexCreateOrEdit() public méthode

Function to get the sql query for index creation or edit
public getSqlQueryForIndexCreateOrEdit ( Index $index, &$error ) : string
$index Index current index
Résultat string

getStatusInfo() public méthode

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
Résultat mixed

getUiPrefsFromDb() protected méthode

Return UI preferences for this table from phpMyAdmin database.
protected getUiPrefsFromDb ( ) : array
Résultat array

getUiProp() public méthode

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
Résultat mixed

getUniqueColumns() public méthode

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
Résultat array

isEngine() public méthode

Checks the storage engine used to create table
public isEngine ( $engine ) : boolean
Résultat boolean True, if $engine matches the storage engine for the table, False otherwise.

isMerge() public méthode

If the ENGINE of the table is MERGE or MRG_MYISAM (alias), this is a merge table.
public isMerge ( ) : boolean
Résultat boolean true if it is a merge table

isUpdatableView() public méthode

Returns whether the table is actually an updatable view
public isUpdatableView ( ) : boolean
Résultat boolean whether the given is an updatable view

isValidName() static public méthode

checks if given name is a valid table name, currently if not empty, trailing spaces, '.', '/' and '\'
See also: 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
Résultat boolean whether the string is valid or not

isView() public méthode

returns whether the table is actually a view
public isView ( ) : boolean
Résultat boolean whether the given is a view

loadUiPrefs() protected méthode

If pmadb and table_uiprefs is set, it will load the UI preferences from phpMyAdmin database.
protected loadUiPrefs ( ) : void
Résultat void

moveCopy() public static méthode

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
Résultat boolean true if success, false otherwise

removeUiProp() public méthode

Remove a property from UI preferences.
public removeUiProp ( string $property ) : true | Message
$property string the property
Résultat true | Message

rename() public méthode

renames table
public rename ( string $new_name, string $new_db = null ) : boolean
$new_name string new table name
$new_db string new database name
Résultat boolean success

saveUiPrefsToDb() protected méthode

Save this table's UI preferences into phpMyAdmin database.
protected saveUiPrefsToDb ( ) : true | Message
Résultat true | Message

setUiProp() public méthode

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
Résultat boolean | Message

showCreate() public méthode

Returns the CREATE statement for this table
public showCreate ( ) : mixed
Résultat mixed

updateDisplayField() public méthode

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
Résultat boolean True on update succeed or False on failure

updateForeignKeys() public méthode

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
Résultat array

updateInternalRelations() public méthode

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
Résultat boolean

Property Details

$_db_name protected_oe property

database name
protected $_db_name

$_dbi protected_oe property

protected DatabaseInterface,PMA\libraries $_dbi
Résultat DatabaseInterface

$_name protected_oe property

table name
protected $_name

$engine public_oe property

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

$errors public_oe property

errors occurred
public $errors

$messages public_oe property

messages
public $messages

$type public_oe property

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

$uiprefs public_oe property

UI preferences
public $uiprefs