- added PMA_DBI_get_default_engine()
- display default engine in table list footer
This commit is contained in:
@@ -8,7 +8,10 @@ $Source$
|
|||||||
2005-11-09 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2005-11-09 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* server_databases.php, mysql_charsets-lib.php:
|
* server_databases.php, mysql_charsets-lib.php:
|
||||||
bug #1351743 undefined function: pma_getservercollation()
|
bug #1351743 undefined function: pma_getservercollation()
|
||||||
* db_details_structure.php: fixed display issues
|
* database_interface.lib.php: added PMA_DBI_get_default_engine()
|
||||||
|
* db_details_structure.php:
|
||||||
|
- fixed display issues
|
||||||
|
- display default engine in footer
|
||||||
|
|
||||||
2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
2005-11-08 Sebastian Mendel <cybot_tm@users.sourceforge.net>
|
||||||
* Documentation.html, browse_foreigners.php, error.php,
|
* Documentation.html, browse_foreigners.php, error.php,
|
||||||
|
@@ -366,18 +366,17 @@ if ($cfg['ShowStats']) {
|
|||||||
<?php echo sprintf( $strTables, PMA_formatNumber( $num_tables, 0 ) ); ?>
|
<?php echo sprintf( $strTables, PMA_formatNumber( $num_tables, 0 ) ); ?>
|
||||||
</th>
|
</th>
|
||||||
<th colspan="<?php echo ( $db_is_information_schema ? 3 : 6 ) ?>" align="center">
|
<th colspan="<?php echo ( $db_is_information_schema ? 3 : 6 ) ?>" align="center">
|
||||||
<?php echo $strSum; ?>
|
<?php echo $strSum; ?></th>
|
||||||
</th>
|
|
||||||
<th class="value"><?php echo PMA_formatNumber( $sum_entries, 0 ); ?></th>
|
<th class="value"><?php echo PMA_formatNumber( $sum_entries, 0 ); ?></th>
|
||||||
<?php
|
<?php
|
||||||
if (!($cfg['PropertiesNumColumns'] > 1)) {
|
if (!($cfg['PropertiesNumColumns'] > 1)) {
|
||||||
echo ' <th align="center">--</th>' . "\n";
|
echo ' <th align="center">'
|
||||||
|
.PMA_DBI_get_default_engine() . '</th>' . "\n";
|
||||||
if ( ! empty( $db_collation ) ) {
|
if ( ! empty( $db_collation ) ) {
|
||||||
echo ' <th align="center">' . "\n"
|
echo ' <th align="center">' . "\n"
|
||||||
. ' <dfn title="'
|
. ' <dfn title="'
|
||||||
. PMA_getCollationDescr($db_collation) . '">' . $db_collation
|
. PMA_getCollationDescr($db_collation) . '">' . $db_collation
|
||||||
. '</dfn>' . "\n"
|
. '</dfn></th>';
|
||||||
. ' </th>' . "\n";
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,23 +414,23 @@ $checkall_url = 'db_details_structure.php?' . PMA_generate_common_url($db);
|
|||||||
|
|
||||||
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
|
<img src="<?php echo $GLOBALS['pmaThemeImage'] . 'spacer.png'; ?>"
|
||||||
width="38" height="1" alt="" />
|
width="38" height="1" alt="" />
|
||||||
<select name="submit_mult" dir="ltr" onchange="this.form.submit();">
|
<select name="submit_mult" onchange="this.form.submit();">
|
||||||
<?php
|
<?php
|
||||||
echo ' <option value="' . $strWithChecked . '" selected="selected">'
|
echo ' <option value="' . $strWithChecked . '" selected="selected">'
|
||||||
. $strWithChecked . '</option>' . "\n";
|
. $strWithChecked . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strDrop . '" >'
|
echo ' <option value="' . $strDrop . '" >'
|
||||||
. $strDrop . '</option>' . "\n";
|
. $strDrop . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strEmpty . '" >'
|
echo ' <option value="' . $strEmpty . '" >'
|
||||||
. $strEmpty . '</option>' . "\n";
|
. $strEmpty . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strPrintView . '" >'
|
echo ' <option value="' . $strPrintView . '" >'
|
||||||
. $strPrintView . '</option>' . "\n";
|
. $strPrintView . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strCheckTable . '" >'
|
echo ' <option value="' . $strCheckTable . '" >'
|
||||||
. $strCheckTable . '</option>' . "\n";
|
. $strCheckTable . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strOptimizeTable . '" >'
|
echo ' <option value="' . $strOptimizeTable . '" >'
|
||||||
. $strOptimizeTable . '</option>' . "\n";
|
. $strOptimizeTable . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strRepairTable . '" >'
|
echo ' <option value="' . $strRepairTable . '" >'
|
||||||
. $strRepairTable . '</option>' . "\n";
|
. $strRepairTable . '</option>' . "\n";
|
||||||
echo ' <option value="' . $strAnalyzeTable . '" >'
|
echo ' <option value="' . $strAnalyzeTable . '" >'
|
||||||
. $strAnalyzeTable . '</option>' . "\n";
|
. $strAnalyzeTable . '</option>' . "\n";
|
||||||
?>
|
?>
|
||||||
</select>
|
</select>
|
||||||
|
@@ -31,7 +31,7 @@ function PMA_DBI_query($query, $link = NULL, $options = 0) {
|
|||||||
* into PMA charset, usally UTF-8
|
* into PMA charset, usally UTF-8
|
||||||
* uses language to charset mapping from mysql/share/errmsg.txt
|
* uses language to charset mapping from mysql/share/errmsg.txt
|
||||||
* and charset names to ISO charset from information_schema.CHARACTER_SETS
|
* and charset names to ISO charset from information_schema.CHARACTER_SETS
|
||||||
*
|
*
|
||||||
* @uses $GLOBALS['cfg']['IconvExtraParams']
|
* @uses $GLOBALS['cfg']['IconvExtraParams']
|
||||||
* @uses $GLOBALS['charset'] as target charset
|
* @uses $GLOBALS['charset'] as target charset
|
||||||
* @uses PMA_DBI_fetch_value() to get server_language
|
* @uses PMA_DBI_fetch_value() to get server_language
|
||||||
@@ -73,13 +73,13 @@ function PMA_DBI_convert_message( $message ) {
|
|||||||
'french' => 'CP1252', //'latin1',
|
'french' => 'CP1252', //'latin1',
|
||||||
'german' => 'CP1252', //'latin1',
|
'german' => 'CP1252', //'latin1',
|
||||||
);
|
);
|
||||||
|
|
||||||
if ( $server_language = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'language\';', 0, 1 ) ) {
|
if ( $server_language = PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'language\';', 0, 1 ) ) {
|
||||||
if ( preg_match( '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', $server_language, $found = array() ) ) {
|
if ( preg_match( '&(?:\\\|\\/)([^\\\\\/]*)(?:\\\|\\/)$&i', $server_language, $found = array() ) ) {
|
||||||
$server_language = $found[1];
|
$server_language = $found[1];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! empty( $server_language ) && isset( $encodings[$server_language] ) ) {
|
if ( ! empty( $server_language ) && isset( $encodings[$server_language] ) ) {
|
||||||
if ( function_exists( 'iconv' ) ) {
|
if ( function_exists( 'iconv' ) ) {
|
||||||
$message = iconv( $encodings[$server_language],
|
$message = iconv( $encodings[$server_language],
|
||||||
@@ -100,19 +100,19 @@ function PMA_DBI_convert_message( $message ) {
|
|||||||
// lang not found, try all
|
// lang not found, try all
|
||||||
// what TODO ?
|
// what TODO ?
|
||||||
}
|
}
|
||||||
|
|
||||||
return $message;
|
return $message;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns array with database names
|
* returns array with database names
|
||||||
*
|
*
|
||||||
* @return array $databases
|
* @return array $databases
|
||||||
*/
|
*/
|
||||||
function PMA_DBI_get_dblist( $link = NULL ) {
|
function PMA_DBI_get_dblist( $link = NULL ) {
|
||||||
|
|
||||||
$dbs_array = PMA_DBI_fetch_result( 'SHOW DATABASES;', $link );
|
$dbs_array = PMA_DBI_fetch_result( 'SHOW DATABASES;', $link );
|
||||||
|
|
||||||
// Before MySQL 4.0.2, SHOW DATABASES could send the
|
// Before MySQL 4.0.2, SHOW DATABASES could send the
|
||||||
// whole list, so check if we really have access:
|
// whole list, so check if we really have access:
|
||||||
if ( PMA_MYSQL_INT_VERSION < 40002 ) {
|
if ( PMA_MYSQL_INT_VERSION < 40002 ) {
|
||||||
@@ -147,14 +147,14 @@ function PMA_DBI_get_tables($database, $link = NULL) {
|
|||||||
* 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 true, $table is used as filter for table names
|
||||||
* if $tbl_is_group is 'comment, $table is used as filter for table comments
|
* if $tbl_is_group is 'comment, $table is used as filter for table comments
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* PMA_DBI_get_tables_full( 'my_database' );
|
* PMA_DBI_get_tables_full( 'my_database' );
|
||||||
* PMA_DBI_get_tables_full( 'my_database', 'my_table' ) );
|
* 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_', true ) );
|
||||||
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', 'comment' ) );
|
* PMA_DBI_get_tables_full( 'my_database', 'my_tables_', 'comment' ) );
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @uses PMA_MYSQL_INT_VERSION
|
* @uses PMA_MYSQL_INT_VERSION
|
||||||
* @uses PMA_DBI_fetch_result()
|
* @uses PMA_DBI_fetch_result()
|
||||||
* @uses PMA_escape_mysql_wildcards()
|
* @uses PMA_escape_mysql_wildcards()
|
||||||
@@ -182,15 +182,15 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
// found \ in name
|
// found \ in name
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
|
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
|
||||||
// get table information from information_schema
|
// get table information from information_schema
|
||||||
if ( $table ) {
|
if ( $table ) {
|
||||||
if ( true === $tbl_is_group ) {
|
if ( true === $tbl_is_group ) {
|
||||||
$sql_where_table = 'AND `TABLE_NAME` LIKE \''
|
$sql_where_table = 'AND `TABLE_NAME` LIKE \''
|
||||||
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
||||||
} elseif ( 'comment' === $tbl_is_group ) {
|
} elseif ( 'comment' === $tbl_is_group ) {
|
||||||
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
|
$sql_where_table = 'AND `TABLE_COMMENT` LIKE \''
|
||||||
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
. PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
||||||
} else {
|
} else {
|
||||||
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes( $table ) . '\'';
|
$sql_where_table = 'AND `TABLE_NAME` = \'' . addslashes( $table ) . '\'';
|
||||||
@@ -198,7 +198,7 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
} else {
|
} else {
|
||||||
$sql_where_table = '';
|
$sql_where_table = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// for PMA bc:
|
// for PMA bc:
|
||||||
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
||||||
$sql = '
|
$sql = '
|
||||||
@@ -226,30 +226,30 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
FROM `information_schema`.`TABLES`
|
FROM `information_schema`.`TABLES`
|
||||||
WHERE `TABLE_SCHEMA` = \'' . addslashes( $database ) . '\'
|
WHERE `TABLE_SCHEMA` = \'' . addslashes( $database ) . '\'
|
||||||
' . $sql_where_table;
|
' . $sql_where_table;
|
||||||
|
|
||||||
$tables = PMA_DBI_fetch_result( $sql, 'TABLE_NAME', NULL, $link );
|
$tables = PMA_DBI_fetch_result( $sql, 'TABLE_NAME', NULL, $link );
|
||||||
unset( $sql_where_table, $sql );
|
unset( $sql_where_table, $sql );
|
||||||
} else {
|
} else {
|
||||||
if ( true === $tbl_is_group ) {
|
if ( true === $tbl_is_group ) {
|
||||||
$sql = 'SHOW TABLE STATUS FROM '
|
$sql = 'SHOW TABLE STATUS FROM '
|
||||||
. PMA_backquote( addslashes( $database ) )
|
. PMA_backquote( addslashes( $database ) )
|
||||||
.' LIKE \'' . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
.' LIKE \'' . PMA_escape_mysql_wildcards( addslashes( $table ) ) . '%\'';
|
||||||
} else {
|
} else {
|
||||||
$sql = 'SHOW TABLE STATUS FROM '
|
$sql = 'SHOW TABLE STATUS FROM '
|
||||||
. PMA_backquote( addslashes( $database ) ) . ';';
|
. PMA_backquote( addslashes( $database ) ) . ';';
|
||||||
}
|
}
|
||||||
$tables = PMA_DBI_fetch_result( $sql, 'Name', NULL, $link );
|
$tables = PMA_DBI_fetch_result( $sql, 'Name', NULL, $link );
|
||||||
foreach ( $tables as $table_name => $each_table ) {
|
foreach ( $tables as $table_name => $each_table ) {
|
||||||
|
|
||||||
|
|
||||||
if ( 'comment' === $tbl_is_group
|
if ( 'comment' === $tbl_is_group
|
||||||
&& 0 === strpos( $each_table['Comment'], $table ) )
|
&& 0 === strpos( $each_table['Comment'], $table ) )
|
||||||
{
|
{
|
||||||
// remove table from list
|
// remove table from list
|
||||||
unset( $tables[$table_name] );
|
unset( $tables[$table_name] );
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( ! isset( $tables[$table_name]['Type'] )
|
if ( ! isset( $tables[$table_name]['Type'] )
|
||||||
&& isset( $tables[$table_name]['Engine'] ) ) {
|
&& isset( $tables[$table_name]['Engine'] ) ) {
|
||||||
// pma BC, same parts of PMA still uses 'Type'
|
// pma BC, same parts of PMA still uses 'Type'
|
||||||
@@ -259,7 +259,7 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
// old MySQL reports Type, newer MySQL reports Engine
|
// old MySQL reports Type, newer MySQL reports Engine
|
||||||
$tables[$table_name]['Engine'] =& $tables[$table_name]['Type'];
|
$tables[$table_name]['Engine'] =& $tables[$table_name]['Type'];
|
||||||
}
|
}
|
||||||
|
|
||||||
// MySQL forward compatibility
|
// MySQL forward compatibility
|
||||||
// so pma could use this array as if every server is of version >5.0
|
// so pma could use this array as if every server is of version >5.0
|
||||||
$tables[$table_name]['TABLE_SCHEMA'] = $database;
|
$tables[$table_name]['TABLE_SCHEMA'] = $database;
|
||||||
@@ -281,7 +281,7 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
$tables[$table_name]['CHECKSUM'] =& $tables[$table_name]['Checksum'];
|
$tables[$table_name]['CHECKSUM'] =& $tables[$table_name]['Checksum'];
|
||||||
$tables[$table_name]['CREATE_OPTIONS'] =& $tables[$table_name]['Create_options'];
|
$tables[$table_name]['CREATE_OPTIONS'] =& $tables[$table_name]['Create_options'];
|
||||||
$tables[$table_name]['TABLE_COMMENT'] =& $tables[$table_name]['Comment'];
|
$tables[$table_name]['TABLE_COMMENT'] =& $tables[$table_name]['Comment'];
|
||||||
|
|
||||||
if ( strtoupper( $tables[$table_name]['Comment'] ) === 'VIEW' ) {
|
if ( strtoupper( $tables[$table_name]['Comment'] ) === 'VIEW' ) {
|
||||||
$tables[$table_name]['TABLE_TYPE'] = 'VIEW';
|
$tables[$table_name]['TABLE_TYPE'] = 'VIEW';
|
||||||
} else {
|
} else {
|
||||||
@@ -291,17 +291,17 @@ function PMA_DBI_get_tables_full( $database, $table = false,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
|
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
|
||||||
uksort( $tables, 'strnatcasecmp' );
|
uksort( $tables, 'strnatcasecmp' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $tables;
|
return $tables;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns array with databases containing extended infos about them
|
* returns array with databases containing extended infos about them
|
||||||
*
|
*
|
||||||
* @param string $databases database
|
* @param string $databases database
|
||||||
* @param boolean $force_stats retrieve stats also for MySQL < 5
|
* @param boolean $force_stats retrieve stats also for MySQL < 5
|
||||||
* @param resource $link mysql link
|
* @param resource $link mysql link
|
||||||
@@ -311,12 +311,12 @@ function PMA_DBI_get_databases_full( $database = NULL, $force_stats = false, $li
|
|||||||
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
|
if ( PMA_MYSQL_INT_VERSION >= 50002 ) {
|
||||||
// get table information from information_schema
|
// get table information from information_schema
|
||||||
if ( $database ) {
|
if ( $database ) {
|
||||||
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
|
$sql_where_schema = 'WHERE `SCHEMA_NAME` LIKE \''
|
||||||
. addslashes( $database ) . '\'';
|
. addslashes( $database ) . '\'';
|
||||||
} else {
|
} else {
|
||||||
$sql_where_schema = '';
|
$sql_where_schema = '';
|
||||||
}
|
}
|
||||||
|
|
||||||
// for PMA bc:
|
// for PMA bc:
|
||||||
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
// `SCHEMA_FIELD_NAME` AS `SHOW_TABLE_STATUS_FIELD_NAME`
|
||||||
$sql = '
|
$sql = '
|
||||||
@@ -349,13 +349,13 @@ function PMA_DBI_get_databases_full( $database = NULL, $force_stats = false, $li
|
|||||||
// MySQL forward compatibility
|
// MySQL forward compatibility
|
||||||
// so pma could use this array as if every server is of version >5.0
|
// so pma could use this array as if every server is of version >5.0
|
||||||
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
|
$databases[$database_name]['SCHEMA_NAME'] = $database_name;
|
||||||
|
|
||||||
if ( $force_stats ) {
|
if ( $force_stats ) {
|
||||||
require_once 'mysql_charsets.lib.php';
|
require_once 'mysql_charsets.lib.php';
|
||||||
|
|
||||||
$databases[$database_name]['DEFAULT_COLLATION_NAME']
|
$databases[$database_name]['DEFAULT_COLLATION_NAME']
|
||||||
= PMA_getDbCollation( $database_name );
|
= PMA_getDbCollation( $database_name );
|
||||||
|
|
||||||
// get additonal info about tables
|
// get additonal info about tables
|
||||||
$databases[$database_name]['SCHEMA_TABLES'] = 0;
|
$databases[$database_name]['SCHEMA_TABLES'] = 0;
|
||||||
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
|
$databases[$database_name]['SCHEMA_TABLE_ROWS'] = 0;
|
||||||
@@ -364,7 +364,7 @@ function PMA_DBI_get_databases_full( $database = NULL, $force_stats = false, $li
|
|||||||
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
|
$databases[$database_name]['SCHEMA_INDEX_LENGTH'] = 0;
|
||||||
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
|
$databases[$database_name]['SCHEMA_LENGTH'] = 0;
|
||||||
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
|
$databases[$database_name]['SCHEMA_DATA_FREE'] = 0;
|
||||||
|
|
||||||
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote( $database_name ) . ';');
|
$res = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote( $database_name ) . ';');
|
||||||
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
|
while ( $row = PMA_DBI_fetch_assoc( $res ) ) {
|
||||||
$databases[$database_name]['SCHEMA_TABLES']++;
|
$databases[$database_name]['SCHEMA_TABLES']++;
|
||||||
@@ -386,11 +386,11 @@ function PMA_DBI_get_databases_full( $database = NULL, $force_stats = false, $li
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
|
if ( $GLOBALS['cfg']['NaturalOrder'] ) {
|
||||||
uksort( $databases, 'strnatcasecmp' );
|
uksort( $databases, 'strnatcasecmp' );
|
||||||
}
|
}
|
||||||
|
|
||||||
return $databases;
|
return $databases;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -402,7 +402,7 @@ function PMA_DBI_get_fields($database, $table, $link = NULL) {
|
|||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// here we use a try_query because when coming from
|
// here we use a try_query because when coming from
|
||||||
// tbl_create + tbl_properties.inc.php, the table does not exist
|
// tbl_create + tbl_properties.inc.php, the table does not exist
|
||||||
$result = PMA_DBI_try_query('SHOW FULL FIELDS FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table), $link);
|
$result = PMA_DBI_try_query('SHOW FULL FIELDS FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table), $link);
|
||||||
|
|
||||||
@@ -482,7 +482,7 @@ function PMA_DBI_postConnect($link, $is_controluser = FALSE) {
|
|||||||
|
|
||||||
// and we remove the non-UTF-8 choices to avoid confusion
|
// and we remove the non-UTF-8 choices to avoid confusion
|
||||||
if (!defined('PMA_REMOVED_NON_UTF_8')) {
|
if (!defined('PMA_REMOVED_NON_UTF_8')) {
|
||||||
$tmp_available_languages = $GLOBALS['available_languages'];
|
$tmp_available_languages = $GLOBALS['available_languages'];
|
||||||
$GLOBALS['available_languages'] = array();
|
$GLOBALS['available_languages'] = array();
|
||||||
foreach ($tmp_available_languages AS $tmp_lang => $tmp_lang_data) {
|
foreach ($tmp_available_languages AS $tmp_lang => $tmp_lang_data) {
|
||||||
if (substr($tmp_lang, -5) == 'utf-8') {
|
if (substr($tmp_lang, -5) == 'utf-8') {
|
||||||
@@ -524,14 +524,14 @@ function PMA_DBI_postConnect($link, $is_controluser = FALSE) {
|
|||||||
* returns a single value from the given result or query,
|
* returns a single value from the given result or query,
|
||||||
* if the query or the result has more than one row or field
|
* if the query or the result has more than one row or field
|
||||||
* the first field of the first row is returned
|
* the first field of the first row is returned
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* $sql = 'SELECT `name` FROM `user` WHERE `id` = 123';
|
* $sql = 'SELECT `name` FROM `user` WHERE `id` = 123';
|
||||||
* $user_name = PMA_DBI_fetch_value( $sql );
|
* $user_name = PMA_DBI_fetch_value( $sql );
|
||||||
* // produces
|
* // produces
|
||||||
* // $user_name = 'John Doe'
|
* // $user_name = 'John Doe'
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @uses is_string()
|
* @uses is_string()
|
||||||
* @uses is_int()
|
* @uses is_int()
|
||||||
* @uses PMA_DBI_try_query()
|
* @uses PMA_DBI_try_query()
|
||||||
@@ -545,55 +545,55 @@ function PMA_DBI_postConnect($link, $is_controluser = FALSE) {
|
|||||||
* @param integer|string $field field to fetch the value from,
|
* @param integer|string $field field to fetch the value from,
|
||||||
* starting at 0, with 0 beeing default
|
* starting at 0, with 0 beeing default
|
||||||
* @param resource $link mysql link
|
* @param resource $link mysql link
|
||||||
* @param mixed $options
|
* @param mixed $options
|
||||||
* @return mixed value of first field in first row from result
|
* @return mixed value of first field in first row from result
|
||||||
* or false if not found
|
* or false if not found
|
||||||
*/
|
*/
|
||||||
function PMA_DBI_fetch_value( $result, $row_number = 0, $field = 0, $link = NULL, $options = 0 ) {
|
function PMA_DBI_fetch_value( $result, $row_number = 0, $field = 0, $link = NULL, $options = 0 ) {
|
||||||
$value = false;
|
$value = false;
|
||||||
|
|
||||||
if ( is_string( $result ) ) {
|
if ( is_string( $result ) ) {
|
||||||
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
|
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// return false if result is empty or false
|
// return false if result is empty or false
|
||||||
// or requested row is larger than rows in result
|
// or requested row is larger than rows in result
|
||||||
if ( PMA_DBI_num_rows( $result ) < ( $row_number + 1 ) ) {
|
if ( PMA_DBI_num_rows( $result ) < ( $row_number + 1 ) ) {
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if $field is an integer use non associative mysql fetch function
|
// if $field is an integer use non associative mysql fetch function
|
||||||
if ( is_int( $field ) ) {
|
if ( is_int( $field ) ) {
|
||||||
$fetch_function = 'PMA_DBI_fetch_row';
|
$fetch_function = 'PMA_DBI_fetch_row';
|
||||||
} else {
|
} else {
|
||||||
$fetch_function = 'PMA_DBI_fetch_assoc';
|
$fetch_function = 'PMA_DBI_fetch_assoc';
|
||||||
}
|
}
|
||||||
|
|
||||||
// get requested row
|
// get requested row
|
||||||
for ( $i = 0; $i <= $row_number; $i++ ) {
|
for ( $i = 0; $i <= $row_number; $i++ ) {
|
||||||
$row = $fetch_function( $result );
|
$row = $fetch_function( $result );
|
||||||
}
|
}
|
||||||
PMA_DBI_free_result( $result );
|
PMA_DBI_free_result( $result );
|
||||||
|
|
||||||
// return requested field
|
// return requested field
|
||||||
if ( isset( $row[$field] ) ) {
|
if ( isset( $row[$field] ) ) {
|
||||||
$value = $row[$field];
|
$value = $row[$field];
|
||||||
}
|
}
|
||||||
unset( $row );
|
unset( $row );
|
||||||
|
|
||||||
return $value;
|
return $value;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* returns only the first row from the result
|
* returns only the first row from the result
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* $sql = 'SELECT * FROM `user` WHERE `id` = 123';
|
* $sql = 'SELECT * FROM `user` WHERE `id` = 123';
|
||||||
* $user = PMA_DBI_fetch_single_row( $sql );
|
* $user = PMA_DBI_fetch_single_row( $sql );
|
||||||
* // produces
|
* // produces
|
||||||
* // $user = array( 'id' => 123, 'name' => 'John Doe' )
|
* // $user = array( 'id' => 123, 'name' => 'John Doe' )
|
||||||
* </code>
|
* </code>
|
||||||
*
|
*
|
||||||
* @uses is_string()
|
* @uses is_string()
|
||||||
* @uses PMA_DBI_try_query()
|
* @uses PMA_DBI_try_query()
|
||||||
* @uses PMA_DBI_num_rows()
|
* @uses PMA_DBI_num_rows()
|
||||||
@@ -606,7 +606,7 @@ function PMA_DBI_fetch_value( $result, $row_number = 0, $field = 0, $link = NULL
|
|||||||
* returned array should either numeric
|
* returned array should either numeric
|
||||||
* associativ or booth
|
* associativ or booth
|
||||||
* @param resource $link mysql link
|
* @param resource $link mysql link
|
||||||
* @param mixed $options
|
* @param mixed $options
|
||||||
* @return array|boolean first row from result
|
* @return array|boolean first row from result
|
||||||
* or false if result is empty
|
* or false if result is empty
|
||||||
*/
|
*/
|
||||||
@@ -614,12 +614,12 @@ function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = NULL, $opti
|
|||||||
if ( is_string( $result ) ) {
|
if ( is_string( $result ) ) {
|
||||||
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
|
$result = PMA_DBI_try_query( $result, $link, $options | PMA_DBI_QUERY_STORE );
|
||||||
}
|
}
|
||||||
|
|
||||||
// return NULL if result is empty or false
|
// return NULL if result is empty or false
|
||||||
if ( ! PMA_DBI_num_rows( $result ) ) {
|
if ( ! PMA_DBI_num_rows( $result ) ) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
switch ( $type ) {
|
switch ( $type ) {
|
||||||
case 'NUM' :
|
case 'NUM' :
|
||||||
$fetch_function = 'PMA_DBI_fetch_row';
|
$fetch_function = 'PMA_DBI_fetch_row';
|
||||||
@@ -632,7 +632,7 @@ function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = NULL, $opti
|
|||||||
$fetch_function = 'PMA_DBI_fetch_array';
|
$fetch_function = 'PMA_DBI_fetch_array';
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
$row = $fetch_function( $result );
|
$row = $fetch_function( $result );
|
||||||
PMA_DBI_free_result( $result );
|
PMA_DBI_free_result( $result );
|
||||||
return $row;
|
return $row;
|
||||||
@@ -640,13 +640,13 @@ function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = NULL, $opti
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* returns all rows in the resultset in one array
|
* returns all rows in the resultset in one array
|
||||||
*
|
*
|
||||||
* <code>
|
* <code>
|
||||||
* $sql = 'SELECT * FROM `user`';
|
* $sql = 'SELECT * FROM `user`';
|
||||||
* $users = PMA_DBI_fetch_result( $sql );
|
* $users = PMA_DBI_fetch_result( $sql );
|
||||||
* // produces
|
* // produces
|
||||||
* // $users[] = array( 'id' => 123, 'name' => 'John Doe' )
|
* // $users[] = array( 'id' => 123, 'name' => 'John Doe' )
|
||||||
*
|
*
|
||||||
* $sql = 'SELECT `id`, `name` FROM `user`';
|
* $sql = 'SELECT `id`, `name` FROM `user`';
|
||||||
* $users = PMA_DBI_fetch_result( $sql, 'id' );
|
* $users = PMA_DBI_fetch_result( $sql, 'id' );
|
||||||
* // produces
|
* // produces
|
||||||
@@ -663,7 +663,7 @@ function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = NULL, $opti
|
|||||||
* $users = PMA_DBI_fetch_result( $sql, 0, 1 );
|
* $users = PMA_DBI_fetch_result( $sql, 0, 1 );
|
||||||
* // produces
|
* // produces
|
||||||
* // $users['123'] = 'John Doe'
|
* // $users['123'] = 'John Doe'
|
||||||
*
|
*
|
||||||
* $sql = 'SELECT `name` FROM `user`';
|
* $sql = 'SELECT `name` FROM `user`';
|
||||||
* $users = PMA_DBI_fetch_result( $sql );
|
* $users = PMA_DBI_fetch_result( $sql );
|
||||||
* // produces
|
* // produces
|
||||||
@@ -684,35 +684,35 @@ function PMA_DBI_fetch_single_row( $result, $type = 'ASSOC', $link = NULL, $opti
|
|||||||
* @param string|integer $value value-name or offset
|
* @param string|integer $value value-name or offset
|
||||||
* used as value for array
|
* used as value for array
|
||||||
* @param resource $link mysql link
|
* @param resource $link mysql link
|
||||||
* @param mixed $options
|
* @param mixed $options
|
||||||
* @return array resultrows or values indexed by $key
|
* @return array resultrows or values indexed by $key
|
||||||
*/
|
*/
|
||||||
function PMA_DBI_fetch_result( $result, $key = NULL, $value = NULL, $link = NULL, $options = 0 )
|
function PMA_DBI_fetch_result( $result, $key = NULL, $value = NULL, $link = NULL, $options = 0 )
|
||||||
{
|
{
|
||||||
$resultrows = array();
|
$resultrows = array();
|
||||||
|
|
||||||
if ( is_string( $result ) ) {
|
if ( is_string( $result ) ) {
|
||||||
$result = PMA_DBI_try_query( $result, $link, $options );
|
$result = PMA_DBI_try_query( $result, $link, $options );
|
||||||
}
|
}
|
||||||
|
|
||||||
// return empty array if result is empty or false
|
// return empty array if result is empty or false
|
||||||
if ( ! $result ) {
|
if ( ! $result ) {
|
||||||
return $resultrows;
|
return $resultrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
$fetch_function = 'PMA_DBI_fetch_assoc';
|
$fetch_function = 'PMA_DBI_fetch_assoc';
|
||||||
|
|
||||||
// no nested array if only one field is in result
|
// no nested array if only one field is in result
|
||||||
if ( NULL === $key && 1 === PMA_DBI_num_fields( $result ) ) {
|
if ( NULL === $key && 1 === PMA_DBI_num_fields( $result ) ) {
|
||||||
$value = 0;
|
$value = 0;
|
||||||
$fetch_function = 'PMA_DBI_fetch_row';
|
$fetch_function = 'PMA_DBI_fetch_row';
|
||||||
}
|
}
|
||||||
|
|
||||||
// if $key is an integer use non associative mysql fetch function
|
// if $key is an integer use non associative mysql fetch function
|
||||||
if ( is_int( $key ) ) {
|
if ( is_int( $key ) ) {
|
||||||
$fetch_function = 'PMA_DBI_fetch_row';
|
$fetch_function = 'PMA_DBI_fetch_row';
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( NULL === $key && NULL === $value ) {
|
if ( NULL === $key && NULL === $value ) {
|
||||||
while ( $row = $fetch_function( $result ) ) {
|
while ( $row = $fetch_function( $result ) ) {
|
||||||
$resultrows[] = $row;
|
$resultrows[] = $row;
|
||||||
@@ -730,8 +730,21 @@ function PMA_DBI_fetch_result( $result, $key = NULL, $value = NULL, $link = NULL
|
|||||||
$resultrows[$row[$key]] = $row[$value];
|
$resultrows[$row[$key]] = $row[$value];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
PMA_DBI_free_result( $result );
|
PMA_DBI_free_result( $result );
|
||||||
return $resultrows;
|
return $resultrows;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* return default able engine for gicen database
|
||||||
|
*
|
||||||
|
* @return string default table engine
|
||||||
|
*/
|
||||||
|
function PMA_DBI_get_default_engine() {
|
||||||
|
if ( PMA_MYSQL_INT_VERSION > 50002 ) {
|
||||||
|
return PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'storage_engine\';', 0, 1 );
|
||||||
|
} else {
|
||||||
|
return PMA_DBI_fetch_value( 'SHOW VARIABLES LIKE \'table_type\';', 0, 1 );
|
||||||
|
}
|
||||||
|
}
|
||||||
?>
|
?>
|
||||||
|
Reference in New Issue
Block a user