作者:nicokaise
项目:phpmyadmi
$user_form .= ' rowspan="' . count($current_privileges) . '"';
}
$user_form .= '>' . (empty($current_user) ? '<span style="color: #FF0000">' . __('Any') . '</span>' : htmlspecialchars($current_user)) . "\n"
. ' </td>' . "\n"
. ' <td';
if (count($current_privileges) > 1) {
$user_form .= ' rowspan="' . count($current_privileges) . '"';
}
$user_form .= '>' . htmlspecialchars($current_host) . '</td>' . "\n";
for ($i = 0; $i < count($current_privileges); $i++) {
$current = $current_privileges[$i];
$user_form .= ' <td>' . "\n"
. ' ';
if (! isset($current['Db']) || $current['Db'] == '*') {
$user_form .= __('global');
} elseif ($current['Db'] == PMA_escape_mysql_wildcards($checkprivs)) {
$user_form .= __('database-specific');
} else {
$user_form .= __('wildcard'). ': <code>' . htmlspecialchars($current['Db']) . '</code>';
}
$user_form .= "\n"
. ' </td>' . "\n"
. ' <td>' . "\n"
. ' <code>' . "\n"
. ' ' . join(',' . "\n" . ' ', PMA_extractPrivInfo($current, true)) . "\n"
. ' </code>' . "\n"
. ' </td>' . "\n"
. ' <td>' . "\n"
. ' ' . ($current['Grant_priv'] == 'Y' ? __('Yes') : __('No')) . "\n"
. ' </td>' . "\n"
. ' <td>' . "\n";
作者:alexhav
项目:elixirjuic
/**
* returns array of all tables in given db or dbs
* this function expects unquoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full('my_database');
* PMA_DBI_get_tables_full('my_database', 'my_table'));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', true));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', 'comment'));
* </code>
*
* @todo move into PMA_Table
* @uses PMA_DBI_fetch_result()
* @uses PMA_escape_mysql_wildcards()
* @uses PMA_backquote()
* @uses is_array()
* @uses addslashes()
* @uses strpos()
* @uses strtoupper()
* @param string $databases database
* @param string $table table
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @param integer $limit_offset zero-based offset for the count
* @param boolean|integer $limit_count number of tables to return
* @param string $sort_by table attribute to sort by
* @param string $sort_order direction to sort (ASC or DESC)
* @return array list of tables in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = false, $link = null, $limit_offset = 0, $limit_count = false, $sort_by = 'Name', $sort_order = 'ASC')
{
require_once './libraries/Table.class.php';
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxTableList'];
}
// prepare and check parameters
if (!is_array($database)) {
$databases = array($database);
} else {
$databases = $database;
}
$tables = array();
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
// get table information from information_schema
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_NAME` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
//
// on non-Windows servers,
// added BINARY in the WHERE clause to force a case sensitive
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
$this_databases = array_map('PMA_sqlAddslashes', $databases);
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES`
WHERE ' . (PMA_IS_WINDOWS ? '' : 'BINARY') . ' `TABLE_SCHEMA` IN (\'' . implode("', '", $this_databases) . '\')
' . $sql_where_table;
// Sort the tables
if ($sort_by == 'Name' && $GLOBALS['cfg']['NaturalOrder']) {
// This crazy bit of SQL was inspired by a post here:
// http://forums.mysql.com/read.php?10,34908,35959#msg-35959
// Find the longest table name
$max_name_sql = "SELECT MAX(LENGTH(TABLE_NAME)) FROM `information_schema`.`TABLES`\n WHERE `TABLE_SCHEMA` IN ('" . implode("', '", $this_databases) . "')";
$max_name_array = PMA_DBI_fetch_result($max_name_sql);
//.........这里部分代码省略.........
作者:portokallidi
项目:Metamorphosis-Meducato
$is_show_stats = $cfg['ShowStats'];
/**
* @global bool whether selected db is information_schema
*/
$db_is_information_schema = false;
if ($db == 'information_schema') {
$is_show_stats = false;
$db_is_information_schema = true;
}
/**
* @global array information about tables in db
*/
$tables = array();
// When used in Nested table group mode, only show tables matching the given groupname
if (PMA_isValid($tbl_group) && !$cfg['ShowTooltipAliasTB']) {
$tbl_group_sql = ' LIKE "' . PMA_escape_mysql_wildcards($tbl_group) . '%"';
} else {
$tbl_group_sql = '';
}
if ($cfg['ShowTooltip']) {
$tooltip_truename = array();
$tooltip_aliasname = array();
}
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if (true === $cfg['SkipLockedTables']) {
$db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
// Blending out tables in use
if ($db_info_result && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
// if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
作者:nexusvist
项目:phpmyadmi
/**
* returns array of all tables in given db or dbs
* this function expects unquoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full('my_database');
* PMA_DBI_get_tables_full('my_database', 'my_table'));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', true));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', 'comment'));
* </code>
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_result()
* @uses PMA_escape_mysql_wildcards()
* @uses PMA_backquote()
* @uses is_array()
* @uses addslashes()
* @uses strpos()
* @uses strtoupper()
* @param string $databases database
* @param string $table table
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @param integer $limit_offset zero-based offset for the count
* @param boolean|integer $limit_count number of tables to return
* @return array list of tables in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = false, $link = null, $limit_offset = 0, $limit_count = false)
{
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxTableList'];
}
// prepare and check parameters
if (!is_array($database)) {
$databases = array($database);
} else {
$databases = $database;
}
$tables = array();
if (PMA_MYSQL_INT_VERSION >= 50002) {
// get table information from information_schema
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_NAME` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
//
// on non-Windows servers,
// added BINARY in the WHERE clause to force a case sensitive
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
$this_databases = array_map('PMA_sqlAddslashes', $databases);
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES`
WHERE ' . (PMA_IS_WINDOWS ? '' : 'BINARY') . ' `TABLE_SCHEMA` IN (\'' . implode("', '", $this_databases) . '\')
' . $sql_where_table;
if ($limit_count) {
$sql .= ' LIMIT ' . $limit_count . ' OFFSET ' . $limit_offset;
}
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'), null, $link);
unset($sql_where_table, $sql);
}
// If permissions are wrong on even one database directory,
// information_schema does not return any table info for any database
// this is why we fall back to SHOW TABLE STATUS even for MySQL >= 50002
if (PMA_MYSQL_INT_VERSION < 50002 || empty($tables)) {
//.........这里部分代码省略.........
作者:nicokaise
项目:phpmyadmi
/**
* returns array of all tables in given db or dbs
* this function expects unquoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full('my_database');
* PMA_DBI_get_tables_full('my_database', 'my_table'));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', true));
* PMA_DBI_get_tables_full('my_database', 'my_tables_', 'comment'));
* </code>
*
* @param string $database database
* @param string|bool $table table or false
* @param boolean|string $tbl_is_group $table is a table group
* @param mixed $link mysql link
* @param integer $limit_offset zero-based offset for the count
* @param boolean|integer $limit_count number of tables to return
* @param string $sort_by table attribute to sort by
* @param string $sort_order direction to sort (ASC or DESC)
*
* @todo move into PMA_Table
*
* @return array list of tables in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = false, $link = null, $limit_offset = 0, $limit_count = false, $sort_by = 'Name', $sort_order = 'ASC')
{
if (true === $limit_count) {
$limit_count = $GLOBALS['cfg']['MaxTableList'];
}
// prepare and check parameters
if (!is_array($database)) {
$databases = array($database);
} else {
$databases = $database;
}
$tables = array();
if (!$GLOBALS['cfg']['Server']['DisableIS']) {
// get table information from information_schema
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_NAME` LIKE \'' . PMA_escape_mysql_wildcards(PMA_sqlAddSlashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND t.`TABLE_COMMENT` LIKE \'' . PMA_escape_mysql_wildcards(PMA_sqlAddSlashes($table)) . '%\'';
} else {
$sql_where_table = 'AND t.`TABLE_NAME` = \'' . PMA_sqlAddSlashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
//
// on non-Windows servers,
// added BINARY in the WHERE clause to force a case sensitive
// comparison (if we are looking for the db Aa we don't want
// to find the db aa)
$this_databases = array_map('PMA_sqlAddSlashes', $databases);
if (PMA_DRIZZLE) {
$engine_info = PMA_cacheGet('drizzle_engines', true);
$stats_join = "LEFT JOIN (SELECT 0 NUM_ROWS) AS stat ON false";
if (isset($engine_info['InnoDB']) && $engine_info['InnoDB']['module_library'] == 'innobase') {
$stats_join = "LEFT JOIN data_dictionary.INNODB_SYS_TABLESTATS stat ON (t.ENGINE = 'InnoDB' AND stat.NAME = (t.TABLE_SCHEMA || '/') || t.TABLE_NAME)";
}
// data_dictionary.table_cache may not contain any data for some tables, it's just a table cache
// auto_increment == 0 is cast to NULL because currently (2011.03.13 GA) Drizzle doesn't provide correct value
$sql = "\n SELECT t.*,\n t.TABLE_SCHEMA AS `Db`,\n t.TABLE_NAME AS `Name`,\n t.TABLE_TYPE AS `TABLE_TYPE`,\n t.ENGINE AS `Engine`,\n t.ENGINE AS `Type`,\n t.TABLE_VERSION AS `Version`,-- VERSION\n t.ROW_FORMAT AS `Row_format`,\n coalesce(tc.ROWS, stat.NUM_ROWS)\n AS `Rows`,-- TABLE_ROWS,\n coalesce(tc.ROWS, stat.NUM_ROWS)\n AS `TABLE_ROWS`,\n tc.AVG_ROW_LENGTH AS `Avg_row_length`, -- AVG_ROW_LENGTH\n tc.TABLE_SIZE AS `Data_length`, -- DATA_LENGTH\n NULL AS `Max_data_length`, -- MAX_DATA_LENGTH\n NULL AS `Index_length`, -- INDEX_LENGTH\n NULL AS `Data_free`, -- DATA_FREE\n nullif(t.AUTO_INCREMENT, 0)\n AS `Auto_increment`,\n t.TABLE_CREATION_TIME AS `Create_time`, -- CREATE_TIME\n t.TABLE_UPDATE_TIME AS `Update_time`, -- UPDATE_TIME\n NULL AS `Check_time`, -- CHECK_TIME\n t.TABLE_COLLATION AS `Collation`,\n NULL AS `Checksum`, -- CHECKSUM\n NULL AS `Create_options`, -- CREATE_OPTIONS\n t.TABLE_COMMENT AS `Comment`\n FROM data_dictionary.TABLES t\n LEFT JOIN data_dictionary.TABLE_CACHE tc ON tc.TABLE_SCHEMA = t.TABLE_SCHEMA AND tc.TABLE_NAME = t.TABLE_NAME\n {$stats_join}\n WHERE t.TABLE_SCHEMA IN ('" . implode("', '", $this_databases) . "')\n " . $sql_where_table;
} else {
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`TABLE_TYPE` AS `TABLE_TYPE`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES` t
WHERE ' . (PMA_IS_WINDOWS ? '' : 'BINARY') . ' `TABLE_SCHEMA` IN (\'' . implode("', '", $this_databases) . '\')
' . $sql_where_table;
}
// Sort the tables
//.........这里部分代码省略.........
作者:nicokaise
项目:phpmyadmi
/**
* PMA_escape_mysql_wildcards tests
* @dataProvider escapeDataProvider
*/
public function testEscape($a, $b)
{
$this->assertEquals($a, PMA_escape_mysql_wildcards($b));
}
作者:BackupTheBerlio
项目:vhcs-sv
/**
* returns array of all tables in given db or dbs
* this function expects unqoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full( 'my_database' );
* PMA_DBI_get_tables_full( 'my_database', 'my_table' ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', true ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', 'comment' ) );
* </code>
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_result()
* @uses PMA_escape_mysql_wildcards()
* @uses PMA_backquote()
* @uses is_array()
* @uses addslashes()
* @uses strpos()
* @uses strtoupper()
* @param string $databases database
* @param string $table table
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @return array list of tbales in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = false, $link = NULL)
{
// prepare and check parameters
if (empty($database)) {
return false;
} elseif (false !== strpos('`', $database)) {
// found ` in name
return false;
} elseif (false !== strpos('\\', $database)) {
// found \ in name
return false;
}
if (PMA_MYSQL_INT_VERSION >= 50002) {
// get table information from information_schema
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_NAME` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` = \'' . addslashes($database) . '\'
' . $sql_where_table;
$tables = PMA_DBI_fetch_result($sql, 'TABLE_NAME', NULL, $link);
unset($sql_where_table, $sql);
} else {
if (true === $tbl_is_group) {
$sql = 'SHOW TABLE STATUS FROM ' . PMA_backquote(addslashes($database)) . ' LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql = 'SHOW TABLE STATUS FROM ' . PMA_backquote(addslashes($database)) . ';';
}
$tables = PMA_DBI_fetch_result($sql, 'Name', NULL, $link);
foreach ($tables as $table_name => $each_table) {
if ('comment' === $tbl_is_group && 0 === strpos($each_table['Comment'], $table)) {
// remove table from list
unset($tables[$table_name]);
continue;
}
if (!isset($tables[$table_name]['Type']) && isset($tables[$table_name]['Engine'])) {
// pma BC, same parts of PMA still uses 'Type'
$tables[$table_name]['Type'] =& $tables[$table_name]['Engine'];
//.........这里部分代码省略.........
作者:hoogl
项目:tt
/**
* returns array of all tables in given db or dbs
* this function expects unqoted names:
* RIGHT: my_database
* WRONG: `my_database`
* WRONG: my\_database
* if $tbl_is_group is true, $table is used as filter for table names
* if $tbl_is_group is 'comment, $table is used as filter for table comments
*
* <code>
* PMA_DBI_get_tables_full( 'my_database' );
* PMA_DBI_get_tables_full( 'my_database', 'my_table' ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', true ) );
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', 'comment' ) );
* </code>
*
* @uses PMA_MYSQL_INT_VERSION
* @uses PMA_DBI_fetch_result()
* @uses PMA_escape_mysql_wildcards()
* @uses PMA_backquote()
* @uses is_array()
* @uses addslashes()
* @uses strpos()
* @uses strtoupper()
* @param string $databases database
* @param string $table table
* @param boolean|string $tbl_is_group $table is a table group
* @param resource $link mysql link
* @return array list of tbales in given db(s)
*/
function PMA_DBI_get_tables_full($database, $table = false, $tbl_is_group = false, $link = null)
{
// prepare and check parameters
if (!is_array($database)) {
$databases = array(addslashes($database));
} else {
$databases = array_map('addslashes', $database);
}
$tables = array();
if (PMA_MYSQL_INT_VERSION >= 50002) {
// get table information from information_schema
if ($table) {
if (true === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_NAME` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} elseif ('comment' === $tbl_is_group) {
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes($table) . '\'';
}
} else {
$sql_where_table = '';
}
// for PMA bc:
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
$sql = '
SELECT *,
`TABLE_SCHEMA` AS `Db`,
`TABLE_NAME` AS `Name`,
`ENGINE` AS `Engine`,
`ENGINE` AS `Type`,
`VERSION` AS `Version`,
`ROW_FORMAT` AS `Row_format`,
`TABLE_ROWS` AS `Rows`,
`AVG_ROW_LENGTH` AS `Avg_row_length`,
`DATA_LENGTH` AS `Data_length`,
`MAX_DATA_LENGTH` AS `Max_data_length`,
`INDEX_LENGTH` AS `Index_length`,
`DATA_FREE` AS `Data_free`,
`AUTO_INCREMENT` AS `Auto_increment`,
`CREATE_TIME` AS `Create_time`,
`UPDATE_TIME` AS `Update_time`,
`CHECK_TIME` AS `Check_time`,
`TABLE_COLLATION` AS `Collation`,
`CHECKSUM` AS `Checksum`,
`CREATE_OPTIONS` AS `Create_options`,
`TABLE_COMMENT` AS `Comment`
FROM `information_schema`.`TABLES`
WHERE `TABLE_SCHEMA` IN (\'' . implode("', '", $databases) . '\')
' . $sql_where_table;
$tables = PMA_DBI_fetch_result($sql, array('TABLE_SCHEMA', 'TABLE_NAME'), null, $link);
unset($sql_where_table, $sql);
} else {
foreach ($databases as $each_database) {
if (true === $tbl_is_group) {
$sql = 'SHOW TABLE STATUS FROM ' . PMA_backquote($each_database) . ' LIKE \'' . PMA_escape_mysql_wildcards(addslashes($table)) . '%\'';
} else {
$sql = 'SHOW TABLE STATUS FROM ' . PMA_backquote($each_database) . ';';
}
$each_tables = PMA_DBI_fetch_result($sql, 'Name', null, $link);
foreach ($each_tables as $table_name => $each_table) {
if ('comment' === $tbl_is_group && 0 === strpos($each_table['Comment'], $table)) {
// remove table from list
unset($each_tables[$table_name]);
continue;
}
if (!isset($each_tables[$table_name]['Type']) && isset($each_tables[$table_name]['Engine'])) {
// pma BC, same parts of PMA still uses 'Type'
$each_tables[$table_name]['Type'] =& $each_tables[$table_name]['Engine'];
} elseif (!isset($each_tables[$table_name]['Engine']) && isset($each_tables[$table_name]['Type'])) {
// old MySQL reports Type, newer MySQL reports Engine
//.........这里部分代码省略.........