Merge pull request #401 from madhuracj/OOP_DBI
OOPing the database interface
This commit is contained in:
commit
e193524a28
@ -52,10 +52,10 @@ if (! empty($db_collation)) {
|
||||
}
|
||||
$sql_query .= ';';
|
||||
|
||||
$result = PMA_DBI_tryQuery($sql_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($sql_query);
|
||||
|
||||
if (! $result) {
|
||||
$message = PMA_Message::rawError(PMA_DBI_getError());
|
||||
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
|
||||
// avoid displaying the not-created db name in header or navi panel
|
||||
$GLOBALS['db'] = '';
|
||||
$GLOBALS['table'] = '';
|
||||
@ -91,7 +91,7 @@ if (! $result) {
|
||||
*/
|
||||
$db_url_params['db'] = $new_db;
|
||||
|
||||
$is_superuser = PMA_isSuperuser();
|
||||
$is_superuser = $GLOBALS['dbi']->isSuperuser();
|
||||
$column_order = PMA_getColumnOrder();
|
||||
$url_query = PMA_generate_common_url($new_db);
|
||||
|
||||
|
||||
@ -57,8 +57,8 @@ if ($cfgRelation['commwork']) {
|
||||
/**
|
||||
* Selects the database and gets tables names
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$tables = PMA_DBI_getTables($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$tables = $GLOBALS['dbi']->getTables($db);
|
||||
|
||||
$count = 0;
|
||||
foreach ($tables as $table) {
|
||||
@ -77,8 +77,8 @@ foreach ($tables as $table) {
|
||||
* Gets table keys and retains them
|
||||
*/
|
||||
|
||||
PMA_DBI_selectDb($db);
|
||||
$indexes = PMA_DBI_getTableIndexes($db, $table);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
|
||||
$primary = '';
|
||||
$indexes = array();
|
||||
$lastIndex = '';
|
||||
@ -117,7 +117,7 @@ foreach ($tables as $table) {
|
||||
/**
|
||||
* Gets columns properties
|
||||
*/
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
|
||||
if (PMA_MYSQL_INT_VERSION < 50025) {
|
||||
// We need this to correctly learn if a TIMESTAMP is NOT NULL, since
|
||||
@ -128,7 +128,7 @@ foreach ($tables as $table) {
|
||||
$show_create_table_query = 'SHOW CREATE TABLE '
|
||||
. PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table);
|
||||
$show_create_table = PMA_DBI_fetchValue(
|
||||
$show_create_table = $GLOBALS['dbi']->fetchValue(
|
||||
$show_create_table_query, 0, 1
|
||||
);
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
|
||||
@ -215,7 +215,7 @@ foreach ($tables as $table) {
|
||||
// contrary. Believe the latter.
|
||||
/**
|
||||
* @todo merge this logic with the one in tbl_structure.php
|
||||
* or move it in a function similar to PMA_DBI_getColumnsFull()
|
||||
* or move it in a function similar to $GLOBALS['dbi']->getColumnsFull()
|
||||
* but based on SHOW CREATE TABLE because information_schema
|
||||
* cannot be trusted in this case (MySQL bug)
|
||||
*/
|
||||
|
||||
@ -62,9 +62,9 @@ if (strlen($db)
|
||||
PMA_runProcedureAndFunctionDefinitions($db);
|
||||
|
||||
// go back to current db, just in case
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
$tables_full = PMA_DBI_getTablesFull($db);
|
||||
$tables_full = $GLOBALS['dbi']->getTablesFull($db);
|
||||
|
||||
include_once "libraries/plugin_interface.lib.php";
|
||||
// remove all foreign key constraints, otherwise we can get errors
|
||||
@ -109,7 +109,7 @@ if (strlen($db)
|
||||
}
|
||||
|
||||
// go back to current db, just in case
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Duplicate the bookmarks for this db (done once for each db)
|
||||
PMA_duplicateBookmarks($_error, $db);
|
||||
@ -124,7 +124,7 @@ if (strlen($db)
|
||||
// if someday the RENAME DATABASE reappears, do not DROP
|
||||
$local_query = 'DROP DATABASE ' . PMA_Util::backquote($db) . ';';
|
||||
$sql_query .= "\n" . $local_query;
|
||||
PMA_DBI_query($local_query);
|
||||
$GLOBALS['dbi']->query($local_query);
|
||||
|
||||
$message = PMA_Message::success(__('Database %1$s has been renamed to %2$s'));
|
||||
$message->addParam($db);
|
||||
@ -206,7 +206,7 @@ if (empty($is_info)) {
|
||||
}
|
||||
|
||||
$_REQUEST['db_collation'] = PMA_getDbCollation($db);
|
||||
$is_information_schema = PMA_isSystemSchema($db);
|
||||
$is_information_schema = $GLOBALS['dbi']->isSystemSchema($db);
|
||||
|
||||
$response->addHTML('<div id="boxContainer" data-box-width="300">');
|
||||
|
||||
@ -285,7 +285,11 @@ if ($cfgRelation['pdfwork'] && $num_tables > 0) {
|
||||
FROM ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
|
||||
. '.' . PMA_Util::backquote($cfgRelation['pdf_pages']) . '
|
||||
WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'';
|
||||
$test_rs = PMA_queryAsControlUser($test_query, null, PMA_DBI_QUERY_STORE);
|
||||
$test_rs = PMA_queryAsControlUser(
|
||||
$test_query,
|
||||
null,
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
/*
|
||||
* Export Relational Schema View
|
||||
|
||||
@ -31,7 +31,7 @@ $cfgRelation = PMA_getRelationsParam();
|
||||
* If there is at least one table, displays the printer friendly view, else
|
||||
* an error message
|
||||
*/
|
||||
$tables = PMA_DBI_getTablesFull($db);
|
||||
$tables = $GLOBALS['dbi']->getTablesFull($db);
|
||||
$num_tables = count($tables);
|
||||
|
||||
echo '<br />';
|
||||
|
||||
@ -67,7 +67,7 @@ $all_tables_query = ' SELECT table_name, MAX(version) as version FROM ' .
|
||||
$all_tables_result = PMA_queryAsControlUser($all_tables_query);
|
||||
|
||||
// If a HEAD version exists
|
||||
if (PMA_DBI_numRows($all_tables_result) > 0) {
|
||||
if ($GLOBALS['dbi']->numRows($all_tables_result) > 0) {
|
||||
?>
|
||||
<div id="tracked_tables">
|
||||
<h3><?php echo __('Tracked tables');?></h3>
|
||||
@ -104,7 +104,7 @@ if (PMA_DBI_numRows($all_tables_result) > 0) {
|
||||
}
|
||||
|
||||
$style = 'odd';
|
||||
while ($one_result = PMA_DBI_fetchArray($all_tables_result)) {
|
||||
while ($one_result = $GLOBALS['dbi']->fetchArray($all_tables_result)) {
|
||||
list($table_name, $version_number) = $one_result;
|
||||
$table_query = ' SELECT * FROM ' .
|
||||
PMA_Util::backquote($GLOBALS['cfg']['Server']['pmadb']) . '.' .
|
||||
@ -114,7 +114,7 @@ if (PMA_DBI_numRows($all_tables_result) > 0) {
|
||||
. '\' AND `version` = \'' . $version_number . '\'';
|
||||
|
||||
$table_result = PMA_queryAsControlUser($table_query);
|
||||
$version_data = PMA_DBI_fetchArray($table_result);
|
||||
$version_data = $GLOBALS['dbi']->fetchArray($table_result);
|
||||
|
||||
if ($version_data['tracking_active'] == 1) {
|
||||
$version_status = __('active');
|
||||
|
||||
@ -649,7 +649,7 @@ do {
|
||||
$export_plugin->exportRoutines($current_db);
|
||||
}
|
||||
|
||||
$tables = PMA_DBI_getTables($current_db);
|
||||
$tables = $GLOBALS['dbi']->getTables($current_db);
|
||||
$views = array();
|
||||
foreach ($tables as $table) {
|
||||
// if this is a view, collect it for later;
|
||||
@ -836,7 +836,7 @@ do {
|
||||
$sql_query = preg_replace('%;\s*$%', '', $sql_query);
|
||||
}
|
||||
$local_query = $sql_query . $add_query;
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
} else {
|
||||
$local_query = 'SELECT * FROM ' . PMA_Util::backquote($db)
|
||||
. '.' . PMA_Util::backquote($table) . $add_query;
|
||||
|
||||
@ -182,7 +182,7 @@ if ($import_type == 'table') {
|
||||
|
||||
|
||||
if (strlen($db)) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
}
|
||||
|
||||
@set_time_limit($cfg['ExecTimeLimit']);
|
||||
@ -447,7 +447,7 @@ if ($GLOBALS['PMA_recoding_engine'] != PMA_CHARSET_NONE && isset($charset_of_fil
|
||||
__('Cannot convert file\'s character set without character set conversion library')
|
||||
);
|
||||
} else {
|
||||
PMA_DBI_query('SET NAMES \'' . $charset_of_file . '\'');
|
||||
$GLOBALS['dbi']->query('SET NAMES \'' . $charset_of_file . '\'');
|
||||
// We can not show query in this case, it is in different charset
|
||||
$sql_query_disabled = true;
|
||||
$reset_charset = true;
|
||||
@ -501,8 +501,8 @@ if ($file_to_unlink != '') {
|
||||
|
||||
// Reset charset back, if we did some changes
|
||||
if ($reset_charset) {
|
||||
PMA_DBI_query('SET CHARACTER SET utf8');
|
||||
PMA_DBI_query(
|
||||
$GLOBALS['dbi']->query('SET CHARACTER SET utf8');
|
||||
$GLOBALS['dbi']->query(
|
||||
'SET SESSION collation_connection =\'' . $collation_connection . '\''
|
||||
);
|
||||
}
|
||||
|
||||
14
index.php
14
index.php
@ -93,12 +93,12 @@ if ($server > 0) {
|
||||
}
|
||||
}
|
||||
if ($GLOBALS['cfg']['ShowServerInfo'] || empty($cfg['Server']['verbose'])) {
|
||||
$server_info .= PMA_DBI_getHostInfo();
|
||||
$server_info .= $GLOBALS['dbi']->getHostInfo();
|
||||
}
|
||||
if (! empty($cfg['Server']['verbose']) && $GLOBALS['cfg']['ShowServerInfo']) {
|
||||
$server_info .= ')';
|
||||
}
|
||||
$mysql_cur_user_and_host = PMA_DBI_fetchValue('SELECT USER();');
|
||||
$mysql_cur_user_and_host = $GLOBALS['dbi']->fetchValue('SELECT USER();');
|
||||
|
||||
// should we add the port info here?
|
||||
$short_server_info = (!empty($GLOBALS['cfg']['Server']['verbose'])
|
||||
@ -246,7 +246,7 @@ if ($server > 0 && $GLOBALS['cfg']['ShowServerInfo']) {
|
||||
'li_server_version'
|
||||
);
|
||||
PMA_printListItem(
|
||||
__('Protocol version:') . ' ' . PMA_DBI_getProtoInfo(),
|
||||
__('Protocol version:') . ' ' . $GLOBALS['dbi']->getProtoInfo(),
|
||||
'li_mysql_proto'
|
||||
);
|
||||
PMA_printListItem(
|
||||
@ -273,7 +273,7 @@ if ($GLOBALS['cfg']['ShowServerInfo'] || $GLOBALS['cfg']['ShowPhpInfo']) {
|
||||
PMA_printListItem($_SERVER['SERVER_SOFTWARE'], 'li_web_server_software');
|
||||
|
||||
if ($server > 0) {
|
||||
$client_version_str = PMA_DBI_getClientInfo();
|
||||
$client_version_str = $GLOBALS['dbi']->getClientInfo();
|
||||
if (preg_match('#\d+\.\d+\.\d+#', $client_version_str)
|
||||
&& in_array($GLOBALS['cfg']['Server']['extension'], array('mysql', 'mysqli'))
|
||||
) {
|
||||
@ -502,12 +502,12 @@ if ($server > 0) {
|
||||
* (a difference on the third digit does not count).
|
||||
* If someday there is a constant that we can check about mysqlnd,
|
||||
* we can use it instead of strpos().
|
||||
* If no default server is set, PMA_DBI_getClientInfo() is not defined yet.
|
||||
* If no default server is set, $GLOBALS['dbi'] is not defined yet.
|
||||
* Drizzle can speak MySQL protocol, so don't warn about version mismatch for
|
||||
* Drizzle servers.
|
||||
*/
|
||||
if (function_exists('PMA_DBI_getClientInfo') && !PMA_DRIZZLE) {
|
||||
$_client_info = PMA_DBI_getClientInfo();
|
||||
if (isset($GLOBALS['dbi']) && !PMA_DRIZZLE) {
|
||||
$_client_info = $GLOBALS['dbi']->getClientInfo();
|
||||
if ($server > 0
|
||||
&& strpos($_client_info, 'mysqlnd') === false
|
||||
&& substr(PMA_MYSQL_CLIENT_API, 0, 3) != substr(PMA_MYSQL_INT_VERSION, 0, 3)
|
||||
|
||||
@ -32,13 +32,13 @@ class Advisor
|
||||
|
||||
// Step 1: Get some variables to evaluate on
|
||||
$this->variables = array_merge(
|
||||
PMA_DBI_fetchResult('SHOW GLOBAL STATUS', 0, 1),
|
||||
PMA_DBI_fetchResult('SHOW GLOBAL VARIABLES', 0, 1)
|
||||
$GLOBALS['dbi']->fetchResult('SHOW GLOBAL STATUS', 0, 1),
|
||||
$GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES', 0, 1)
|
||||
);
|
||||
if (PMA_DRIZZLE) {
|
||||
$this->variables = array_merge(
|
||||
$this->variables,
|
||||
PMA_DBI_fetchResult(
|
||||
$GLOBALS['dbi']->fetchResult(
|
||||
"SELECT concat('Com_', variable_name), variable_value
|
||||
FROM data_dictionary.GLOBAL_STATEMENTS", 0, 1
|
||||
)
|
||||
|
||||
@ -258,19 +258,19 @@ class PMA_DbQbe
|
||||
$this->_criteriaTables[$each_table] = ' selected="selected"';
|
||||
}
|
||||
} // end if
|
||||
$all_tables = PMA_DBI_query(
|
||||
$all_tables = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLES FROM ' . PMA_Util::backquote($this->_db) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$all_tables_count = PMA_DBI_numRows($all_tables);
|
||||
$all_tables_count = $GLOBALS['dbi']->numRows($all_tables);
|
||||
if (0 == $all_tables_count) {
|
||||
PMA_Message::error(__('No tables found in database.'))->display();
|
||||
exit;
|
||||
}
|
||||
// The tables list gets from MySQL
|
||||
while (list($table) = PMA_DBI_fetchRow($all_tables)) {
|
||||
$columns = PMA_DBI_getColumns($this->_db, $table);
|
||||
while (list($table) = $GLOBALS['dbi']->fetchRow($all_tables)) {
|
||||
$columns = $GLOBALS['dbi']->getColumns($this->_db, $table);
|
||||
|
||||
if (empty($this->_criteriaTables[$table])
|
||||
&& ! empty($_REQUEST['TableList'])
|
||||
@ -296,7 +296,7 @@ class PMA_DbQbe
|
||||
} // end foreach
|
||||
} // end if
|
||||
} // end while
|
||||
PMA_DBI_freeResult($all_tables);
|
||||
$GLOBALS['dbi']->freeResult($all_tables);
|
||||
|
||||
// sets the largest width found
|
||||
$this->_realwidth = $this->_form_column_width . 'ex';
|
||||
@ -1026,7 +1026,7 @@ class PMA_DbQbe
|
||||
$index_columns = array();
|
||||
|
||||
foreach ($all_tables as $table) {
|
||||
$indexes = PMA_DBI_getTableIndexes($this->_db, $table);
|
||||
$indexes = $GLOBALS['dbi']->getTableIndexes($this->_db, $table);
|
||||
foreach ($indexes as $index) {
|
||||
$column = $table . '.' . $index['Column_name'];
|
||||
if (isset($all_columns[$column])) {
|
||||
@ -1065,7 +1065,7 @@ class PMA_DbQbe
|
||||
private function _getLeftJoinColumnCandidates($all_tables, $all_columns,
|
||||
$where_clause_columns
|
||||
) {
|
||||
PMA_DBI_selectDb($this->_db);
|
||||
$GLOBALS['dbi']->selectDb($this->_db);
|
||||
$candidate_columns = array();
|
||||
|
||||
// Get unique columns and index columns
|
||||
|
||||
2381
libraries/DatabaseInterface.class.php
Normal file
2381
libraries/DatabaseInterface.class.php
Normal file
File diff suppressed because it is too large
Load Diff
@ -92,7 +92,7 @@ class PMA_DbSearch
|
||||
*/
|
||||
private function _setSearchParams()
|
||||
{
|
||||
$this->_tables_names_only = PMA_DBI_getTables($this->_db);
|
||||
$this->_tables_names_only = $GLOBALS['dbi']->getTables($this->_db);
|
||||
|
||||
$this->_searchTypes = array(
|
||||
'1' => __('at least one of the words'),
|
||||
@ -153,8 +153,8 @@ class PMA_DbSearch
|
||||
*
|
||||
* @todo can we make use of fulltextsearch IN BOOLEAN MODE for this?
|
||||
* PMA_backquote
|
||||
* PMA_DBI_freeResult
|
||||
* PMA_DBI_fetchAssoc
|
||||
* DatabaseInterface::freeResult
|
||||
* DatabaseInterface::fetchAssoc
|
||||
* $GLOBALS['db']
|
||||
* explode
|
||||
* count
|
||||
@ -193,7 +193,7 @@ class PMA_DbSearch
|
||||
{
|
||||
$where_clause = '';
|
||||
// Columns to select
|
||||
$allColumns = PMA_DBI_getColumns($GLOBALS['db'], $table);
|
||||
$allColumns = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $table);
|
||||
$likeClauses = array();
|
||||
// Based on search type, decide like/regex & '%'/''
|
||||
$like_or_regex = (($this->_criteriaSearchType == 4) ? 'REGEXP' : 'LIKE');
|
||||
@ -277,7 +277,7 @@ class PMA_DbSearch
|
||||
// Gets the SQL statements
|
||||
$newsearchsqls = $this->_getSearchSqls($each_table);
|
||||
// Executes the "COUNT" statement
|
||||
$res_cnt = PMA_DBI_fetchValue($newsearchsqls['select_count']);
|
||||
$res_cnt = $GLOBALS['dbi']->fetchValue($newsearchsqls['select_count']);
|
||||
$num_search_result_total += $res_cnt;
|
||||
// Gets the result row's HTML for a table
|
||||
$html_output .= $this->_getResultsRow(
|
||||
|
||||
@ -2509,7 +2509,7 @@ class PMA_DisplayResults
|
||||
|| ($_SESSION['tmp_user_values']['disp_direction']
|
||||
== self::DISP_DIR_HORIZONTAL_FLIPPED);
|
||||
|
||||
while ($row = PMA_DBI_fetchRow($dt_result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($dt_result)) {
|
||||
|
||||
// "vertical display" mode stuff
|
||||
$table_body_html .= $this->_getVerticalDisplaySupportSegments(
|
||||
@ -2862,7 +2862,7 @@ class PMA_DisplayResults
|
||||
|
||||
// PMA_mysql_fetch_fields returns BLOB in place of
|
||||
// TEXT fields type so we have to ensure it's really a BLOB
|
||||
$field_flags = PMA_DBI_fieldFlags($dt_result, $i);
|
||||
$field_flags = $GLOBALS['dbi']->fieldFlags($dt_result, $i);
|
||||
|
||||
$vertical_display['data'][$row_no][$i]
|
||||
= $this->_getDataCellForBlobColumns(
|
||||
@ -3843,7 +3843,7 @@ class PMA_DisplayResults
|
||||
) {
|
||||
|
||||
$is_analyse = $this->__get('is_analyse');
|
||||
$field_flags = PMA_DBI_fieldFlags($dt_result, $col_index);
|
||||
$field_flags = $GLOBALS['dbi']->fieldFlags($dt_result, $col_index);
|
||||
if (stristr($field_flags, self::BINARY_FIELD)
|
||||
&& ($GLOBALS['cfg']['ProtectBinary'] == 'all'
|
||||
|| $GLOBALS['cfg']['ProtectBinary'] == 'noblob')
|
||||
@ -4777,7 +4777,7 @@ class PMA_DisplayResults
|
||||
if ($sorted_column_index !== false) {
|
||||
|
||||
// fetch first row of the result set
|
||||
$row = PMA_DBI_fetchRow($dt_result);
|
||||
$row = $GLOBALS['dbi']->fetchRow($dt_result);
|
||||
|
||||
// initializing default arguments
|
||||
$default_function = '_mimeDefaultFunction';
|
||||
@ -4806,8 +4806,8 @@ class PMA_DisplayResults
|
||||
);
|
||||
|
||||
// fetch last row of the result set
|
||||
PMA_DBI_dataSeek($dt_result, $this->__get('num_rows') - 1);
|
||||
$row = PMA_DBI_fetchRow($dt_result);
|
||||
$GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
|
||||
$row = $GLOBALS['dbi']->fetchRow($dt_result);
|
||||
|
||||
// check for non printable sorted row data
|
||||
$meta = $fields_meta[$sorted_column_index];
|
||||
@ -4830,7 +4830,7 @@ class PMA_DisplayResults
|
||||
);
|
||||
|
||||
// reset to first row for the loop in _getTableBody()
|
||||
PMA_DBI_dataSeek($dt_result, 0);
|
||||
$GLOBALS['dbi']->dataSeek($dt_result, 0);
|
||||
|
||||
// we could also use here $sort_expression_nodirection
|
||||
return ' [' . htmlspecialchars($sort_column)
|
||||
@ -5077,8 +5077,8 @@ class PMA_DisplayResults
|
||||
}
|
||||
|
||||
// fetch last row of the result set
|
||||
PMA_DBI_dataSeek($dt_result, $this->__get('num_rows') - 1);
|
||||
$row = PMA_DBI_fetchRow($dt_result);
|
||||
$GLOBALS['dbi']->dataSeek($dt_result, $this->__get('num_rows') - 1);
|
||||
$row = $GLOBALS['dbi']->fetchRow($dt_result);
|
||||
|
||||
// $clause_is_unique is needed by getTable() to generate the proper param
|
||||
// in the multi-edit and multi-delete form
|
||||
@ -5091,7 +5091,7 @@ class PMA_DisplayResults
|
||||
);
|
||||
|
||||
// reset to first row for the loop in _getTableBody()
|
||||
PMA_DBI_dataSeek($dt_result, 0);
|
||||
$GLOBALS['dbi']->dataSeek($dt_result, 0);
|
||||
|
||||
$links_html .= '<input type="hidden" name="clause_is_unique"'
|
||||
.' value="' . $clause_is_unique . '" />' . "\n";
|
||||
@ -5321,7 +5321,7 @@ class PMA_DisplayResults
|
||||
* the script it calls do not fail
|
||||
*/
|
||||
if (empty($_url_params['table']) && ! empty($_url_params['db'])) {
|
||||
$_url_params['table'] = PMA_DBI_fetchValue("SHOW TABLES");
|
||||
$_url_params['table'] = $GLOBALS['dbi']->fetchValue("SHOW TABLES");
|
||||
/* No result (probably no database selected) */
|
||||
if ($_url_params['table'] === false) {
|
||||
unset($_url_params['table']);
|
||||
@ -5574,15 +5574,19 @@ class PMA_DisplayResults
|
||||
. PMA_Util::backquote($map[$meta->name][1])
|
||||
. $where_comparison;
|
||||
|
||||
$dispresult = PMA_DBI_tryQuery($dispsql, null, PMA_DBI_QUERY_STORE);
|
||||
$dispresult = $GLOBALS['dbi']->tryQuery(
|
||||
$dispsql,
|
||||
null,
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if ($dispresult && PMA_DBI_numRows($dispresult) > 0) {
|
||||
list($dispval) = PMA_DBI_fetchRow($dispresult, 0);
|
||||
if ($dispresult && $GLOBALS['dbi']->numRows($dispresult) > 0) {
|
||||
list($dispval) = $GLOBALS['dbi']->fetchRow($dispresult, 0);
|
||||
} else {
|
||||
$dispval = __('Link not found');
|
||||
}
|
||||
|
||||
@PMA_DBI_freeResult($dispresult);
|
||||
@$GLOBALS['dbi']->freeResult($dispresult);
|
||||
|
||||
} else {
|
||||
$dispval = '';
|
||||
|
||||
@ -305,8 +305,6 @@ class PMA_Error extends PMA_Message
|
||||
'mysql_pconnect',
|
||||
'mysqli_connect',
|
||||
'mysqli_real_connect',
|
||||
'PMA_DBI_connect',
|
||||
'PMA_DBI_realConnect',
|
||||
);
|
||||
|
||||
if (in_array($function, $include_functions)) {
|
||||
|
||||
@ -172,7 +172,7 @@ class PMA_Index
|
||||
return true;
|
||||
}
|
||||
|
||||
$_raw_indexes = PMA_DBI_getTableIndexes($schema, $table);
|
||||
$_raw_indexes = $GLOBALS['dbi']->getTableIndexes($schema, $table);
|
||||
foreach ($_raw_indexes as $_each_index) {
|
||||
$_each_index['Schema'] = $schema;
|
||||
if (! isset(PMA_Index::$_registry[$schema][$table][$_each_index['Key_name']])) {
|
||||
|
||||
@ -87,7 +87,7 @@ abstract class PMA_List extends ArrayObject
|
||||
$options = '';
|
||||
foreach ($this as $each_item) {
|
||||
if (false === $include_information_schema
|
||||
&& PMA_isSystemSchema($each_item)
|
||||
&& $GLOBALS['dbi']->isSystemSchema($each_item)
|
||||
) {
|
||||
continue;
|
||||
}
|
||||
|
||||
@ -122,18 +122,18 @@ class PMA_List_Database extends PMA_List
|
||||
$command = $this->command;
|
||||
}
|
||||
|
||||
$database_list = PMA_DBI_fetchResult($command, null, null, $this->db_link);
|
||||
PMA_DBI_getError();
|
||||
$database_list = $GLOBALS['dbi']->fetchResult($command, null, null, $this->db_link);
|
||||
$GLOBALS['dbi']->getError();
|
||||
|
||||
if ($GLOBALS['errno'] !== 0) {
|
||||
// failed to get database list, try the control user
|
||||
// (hopefully there is one and he has SHOW DATABASES right)
|
||||
$this->db_link = $this->db_link_control;
|
||||
$database_list = PMA_DBI_fetchResult(
|
||||
$database_list = $GLOBALS['dbi']->fetchResult(
|
||||
$command, null, null, $this->db_link
|
||||
);
|
||||
|
||||
PMA_DBI_getError();
|
||||
$GLOBALS['dbi']->getError();
|
||||
|
||||
if ($GLOBALS['errno'] !== 0) {
|
||||
// failed! we will display a warning that phpMyAdmin could not safely
|
||||
@ -244,7 +244,7 @@ class PMA_List_Database extends PMA_List
|
||||
WHERE `Select_priv` = 'Y'
|
||||
AND `User`
|
||||
IN ('" . PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . "', '')";
|
||||
$tmp_mydbs = PMA_DBI_fetchResult(
|
||||
$tmp_mydbs = $GLOBALS['dbi']->fetchResult(
|
||||
$local_query, null, null, $GLOBALS['controllink']
|
||||
);
|
||||
if ($tmp_mydbs) {
|
||||
@ -258,14 +258,14 @@ class PMA_List_Database extends PMA_List
|
||||
// populating $dblist[], as previous code did. But it is
|
||||
// now populated with actual database names instead of
|
||||
// with regular expressions.
|
||||
$tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['controllink']);
|
||||
$tmp_alldbs = $GLOBALS['dbi']->query('SHOW DATABASES;', $GLOBALS['controllink']);
|
||||
// all databases cases - part 2
|
||||
if (isset($tmp_mydbs['%'])) {
|
||||
while ($tmp_row = PMA_DBI_fetchRow($tmp_alldbs)) {
|
||||
while ($tmp_row = $GLOBALS['dbi']->fetchRow($tmp_alldbs)) {
|
||||
$dblist[] = $tmp_row[0];
|
||||
} // end while
|
||||
} else {
|
||||
while ($tmp_row = PMA_DBI_fetchRow($tmp_alldbs)) {
|
||||
while ($tmp_row = $GLOBALS['dbi']->fetchRow($tmp_alldbs)) {
|
||||
$tmp_db = $tmp_row[0];
|
||||
if (isset($tmp_mydbs[$tmp_db]) && $tmp_mydbs[$tmp_db] == 1) {
|
||||
$dblist[] = $tmp_db;
|
||||
@ -295,7 +295,7 @@ class PMA_List_Database extends PMA_List
|
||||
} // end if ... elseif ...
|
||||
} // end while
|
||||
} // end else
|
||||
PMA_DBI_freeResult($tmp_alldbs);
|
||||
$GLOBALS['dbi']->freeResult($tmp_alldbs);
|
||||
unset($tmp_mydbs);
|
||||
} // end if
|
||||
|
||||
@ -304,14 +304,14 @@ class PMA_List_Database extends PMA_List
|
||||
$local_query .= ' WHERE `Table_priv` LIKE \'%Select%\'';
|
||||
$local_query .= ' AND `User` = \'';
|
||||
$local_query .= PMA_Util::sqlAddSlashes($GLOBALS['cfg']['Server']['user']) . '\'';
|
||||
$rs = PMA_DBI_tryQuery($local_query, $GLOBALS['controllink']);
|
||||
if ($rs && @PMA_DBI_numRows($rs)) {
|
||||
while ($row = PMA_DBI_fetchAssoc($rs)) {
|
||||
$rs = $GLOBALS['dbi']->tryQuery($local_query, $GLOBALS['controllink']);
|
||||
if ($rs && @$GLOBALS['dbi']->numRows($rs)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($rs)) {
|
||||
if (!in_array($row['Db'], $dblist)) {
|
||||
$dblist[] = $row['Db'];
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($rs);
|
||||
$GLOBALS['dbi']->freeResult($rs);
|
||||
} // end if
|
||||
}
|
||||
}
|
||||
|
||||
@ -240,7 +240,7 @@ class PMA_Menu
|
||||
*/
|
||||
private function _getTableTabs()
|
||||
{
|
||||
$db_is_information_schema = PMA_isSystemSchema($this->_db);
|
||||
$db_is_information_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
|
||||
$tbl_is_view = PMA_Table::isView($this->_db, $this->_table);
|
||||
$table_info_num_rows = PMA_Table::countRecords($this->_db, $this->_table);
|
||||
|
||||
@ -325,9 +325,9 @@ class PMA_Menu
|
||||
*/
|
||||
private function _getDbTabs()
|
||||
{
|
||||
$db_is_information_schema = PMA_isSystemSchema($this->_db);
|
||||
$num_tables = count(PMA_DBI_getTables($this->_db));
|
||||
$is_superuser = PMA_isSuperuser();
|
||||
$db_is_information_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
|
||||
$num_tables = count($GLOBALS['dbi']->getTables($this->_db));
|
||||
$is_superuser = $GLOBALS['dbi']->isSuperuser();
|
||||
|
||||
/**
|
||||
* Gets the relation settings
|
||||
@ -427,15 +427,15 @@ class PMA_Menu
|
||||
*/
|
||||
private function _getServerTabs()
|
||||
{
|
||||
$is_superuser = PMA_isSuperuser();
|
||||
$is_superuser = $GLOBALS['dbi']->isSuperuser();
|
||||
$binary_logs = null;
|
||||
if (!defined('PMA_DRIZZLE') || (defined('PMA_DRIZZLE') && ! PMA_DRIZZLE)) {
|
||||
$binary_logs = PMA_DBI_fetchResult(
|
||||
$binary_logs = $GLOBALS['dbi']->fetchResult(
|
||||
'SHOW MASTER LOGS',
|
||||
'Log_name',
|
||||
null,
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -28,7 +28,7 @@ class PMA_Partition
|
||||
static public function getPartitionNames($db, $table)
|
||||
{
|
||||
if (PMA_Partition::havePartitioning()) {
|
||||
return PMA_DBI_fetchResult(
|
||||
return $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT `PARTITION_NAME` FROM `information_schema`.`PARTITIONS`"
|
||||
. " WHERE `TABLE_SCHEMA` = '" . $db
|
||||
. "' AND `TABLE_NAME` = '" . $table . "'"
|
||||
@ -55,14 +55,14 @@ class PMA_Partition
|
||||
if (! $already_checked) {
|
||||
if (PMA_MYSQL_INT_VERSION >= 50100) {
|
||||
if (PMA_MYSQL_INT_VERSION < 50600) {
|
||||
if (PMA_DBI_fetchValue(
|
||||
if ($GLOBALS['dbi']->fetchValue(
|
||||
"SHOW VARIABLES LIKE 'have_partitioning';"
|
||||
)) {
|
||||
$have_partitioning = true;
|
||||
}
|
||||
} else {
|
||||
// see http://dev.mysql.com/doc/refman/5.6/en/partitioning.html
|
||||
$plugins = PMA_DBI_fetchResult("SHOW PLUGINS");
|
||||
$plugins = $GLOBALS['dbi']->fetchResult("SHOW PLUGINS");
|
||||
foreach ($plugins as $value) {
|
||||
if ($value['Name'] == 'partition') {
|
||||
$have_partitioning = true;
|
||||
|
||||
@ -85,7 +85,7 @@ class PMA_RecentTable
|
||||
= " SELECT `tables` FROM " . $this->_pmaTable .
|
||||
" WHERE `username` = '" . $GLOBALS['cfg']['Server']['user'] . "'";
|
||||
|
||||
$row = PMA_DBI_fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
$row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
return json_decode($row[0], true);
|
||||
} else {
|
||||
@ -108,13 +108,13 @@ class PMA_RecentTable
|
||||
json_encode($this->tables)
|
||||
) . "')";
|
||||
|
||||
$success = PMA_DBI_tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
|
||||
if (! $success) {
|
||||
$message = PMA_Message::error(__('Could not save recent table'));
|
||||
$message->addMessage('<br /><br />');
|
||||
$message->addMessage(
|
||||
PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
|
||||
PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink']))
|
||||
);
|
||||
return $message;
|
||||
}
|
||||
|
||||
@ -57,19 +57,19 @@ class PMA_ServerStatusData
|
||||
/**
|
||||
* get status from server
|
||||
*/
|
||||
$server_status = PMA_DBI_fetchResult('SHOW GLOBAL STATUS', 0, 1);
|
||||
$server_status = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL STATUS', 0, 1);
|
||||
if (PMA_DRIZZLE) {
|
||||
// Drizzle doesn't put query statistics into variables, add it
|
||||
$sql = "SELECT concat('Com_', variable_name), variable_value
|
||||
FROM data_dictionary.GLOBAL_STATEMENTS";
|
||||
$statements = PMA_DBI_fetchResult($sql, 0, 1);
|
||||
$statements = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
|
||||
$server_status = array_merge($server_status, $statements);
|
||||
}
|
||||
|
||||
/**
|
||||
* for some calculations we require also some server settings
|
||||
*/
|
||||
$server_variables = PMA_DBI_fetchResult('SHOW GLOBAL VARIABLES', 0, 1);
|
||||
$server_variables = $GLOBALS['dbi']->fetchResult('SHOW GLOBAL VARIABLES', 0, 1);
|
||||
|
||||
/**
|
||||
* cleanup of some deprecated values
|
||||
@ -275,7 +275,7 @@ class PMA_ServerStatusData
|
||||
}
|
||||
|
||||
if (PMA_DRIZZLE) {
|
||||
$used_queries = PMA_DBI_fetchResult(
|
||||
$used_queries = $GLOBALS['dbi']->fetchResult(
|
||||
'SELECT * FROM data_dictionary.global_statements',
|
||||
0,
|
||||
1
|
||||
|
||||
@ -75,10 +75,10 @@ class PMA_StorageEngine
|
||||
JOIN data_dictionary.modules m USING (module_name)
|
||||
WHERE p.plugin_type = 'StorageEngine'
|
||||
AND p.plugin_name NOT IN ('FunctionEngine', 'schema')";
|
||||
$storage_engines = PMA_DBI_fetchResult($sql, 'Engine');
|
||||
$storage_engines = $GLOBALS['dbi']->fetchResult($sql, 'Engine');
|
||||
} else {
|
||||
$storage_engines
|
||||
= PMA_DBI_fetchResult('SHOW STORAGE ENGINES', 'Engine');
|
||||
= $GLOBALS['dbi']->fetchResult('SHOW STORAGE ENGINES', 'Engine');
|
||||
}
|
||||
}
|
||||
|
||||
@ -259,8 +259,8 @@ class PMA_StorageEngine
|
||||
$mysql_vars = array();
|
||||
|
||||
$sql_query = 'SHOW GLOBAL VARIABLES ' . $like . ';';
|
||||
$res = PMA_DBI_query($sql_query);
|
||||
while ($row = PMA_DBI_fetchAssoc($res)) {
|
||||
$res = $GLOBALS['dbi']->query($sql_query);
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
|
||||
if (isset($variables[$row['Variable_name']])) {
|
||||
$mysql_vars[$row['Variable_name']] = $variables[$row['Variable_name']];
|
||||
} elseif (! $like
|
||||
@ -279,7 +279,7 @@ class PMA_StorageEngine
|
||||
= PMA_ENGINE_DETAILS_TYPE_PLAINTEXT;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($res);
|
||||
$GLOBALS['dbi']->freeResult($res);
|
||||
|
||||
return $mysql_vars;
|
||||
}
|
||||
|
||||
@ -199,7 +199,7 @@ class PMA_Table
|
||||
}
|
||||
|
||||
// query information_schema
|
||||
$result = PMA_DBI_fetchResult(
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
|
||||
@ -222,7 +222,7 @@ class PMA_Table
|
||||
return false;
|
||||
}
|
||||
|
||||
$result = PMA_DBI_fetchResult(
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT TABLE_NAME
|
||||
FROM information_schema.VIEWS
|
||||
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
|
||||
@ -250,12 +250,12 @@ class PMA_Table
|
||||
$analyzed_sql = array();
|
||||
if (self::isView($db, $table)) {
|
||||
// For a view, 'SHOW CREATE TABLE' returns the definition,
|
||||
// but the structure of the view. So, we try to mock
|
||||
// but the structure of the view. So, we try to mock
|
||||
// the result of analyzing 'SHOW CREATE TABLE' query.
|
||||
$analyzed_sql[0] = array();
|
||||
$analyzed_sql[0]['create_table_fields'] = array();
|
||||
|
||||
$results = PMA_DBI_fetchResult(
|
||||
$results = $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT COLUMN_NAME, DATA_TYPE
|
||||
FROM information_schema.COLUMNS
|
||||
WHERE TABLE_SCHEMA = '" . PMA_Util::sqlAddSlashes($db) . "'
|
||||
@ -266,7 +266,7 @@ class PMA_Table
|
||||
= array('type' => strtoupper($result['DATA_TYPE']));
|
||||
}
|
||||
} else {
|
||||
$show_create_table = PMA_DBI_fetchValue(
|
||||
$show_create_table = $GLOBALS['dbi']->fetchValue(
|
||||
'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table),
|
||||
0,
|
||||
1
|
||||
@ -360,8 +360,8 @@ class PMA_Table
|
||||
* @param boolean $force_read read new rather than serving from cache
|
||||
* @param boolean $disable_error if true, disables error message
|
||||
*
|
||||
* @todo PMA_DBI_getTablesFull needs to be merged somehow into this class
|
||||
* or at least better documented
|
||||
* @todo DatabaseInterface::getTablesFull needs to be merged
|
||||
* somehow into this class or at least better documented
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
@ -373,7 +373,7 @@ class PMA_Table
|
||||
}
|
||||
|
||||
if (! isset(PMA_Table::$cache[$db][$table]) || $force_read) {
|
||||
PMA_DBI_getTablesFull($db, $table);
|
||||
$GLOBALS['dbi']->getTablesFull($db, $table);
|
||||
}
|
||||
|
||||
if (! isset(PMA_Table::$cache[$db][$table])) {
|
||||
@ -573,7 +573,7 @@ class PMA_Table
|
||||
|
||||
if (! $force_exact) {
|
||||
if (! isset(PMA_Table::$cache[$db][$table]['Rows']) && ! $is_view) {
|
||||
$tmp_tables = PMA_DBI_getTablesFull($db, $table);
|
||||
$tmp_tables = $GLOBALS['dbi']->getTablesFull($db, $table);
|
||||
if (isset($tmp_tables[$table])) {
|
||||
PMA_Table::$cache[$db][$table] = $tmp_tables[$table];
|
||||
}
|
||||
@ -592,8 +592,8 @@ class PMA_Table
|
||||
// Make an exception for views in I_S and D_D schema in
|
||||
// Drizzle, as these map to in-memory data and should execute
|
||||
// fast enough
|
||||
if (! $is_view || (PMA_DRIZZLE && PMA_isSystemSchema($db))) {
|
||||
$row_count = PMA_DBI_fetchValue(
|
||||
if (! $is_view || (PMA_DRIZZLE && $GLOBALS['dbi']->isSystemSchema($db))) {
|
||||
$row_count = $GLOBALS['dbi']->fetchValue(
|
||||
'SELECT COUNT(*) FROM ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table)
|
||||
);
|
||||
@ -610,16 +610,16 @@ class PMA_Table
|
||||
// so use a LIMIT clause.
|
||||
// Use try_query because it can fail (when a VIEW is
|
||||
// based on a table that no longer exists)
|
||||
$result = PMA_DBI_tryQuery(
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
'SELECT 1 FROM ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table) . ' LIMIT '
|
||||
. $GLOBALS['cfg']['MaxExactCountViews'],
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (!PMA_DBI_getError()) {
|
||||
$row_count = PMA_DBI_numRows($result);
|
||||
PMA_DBI_freeResult($result);
|
||||
if (!$GLOBALS['dbi']->getError()) {
|
||||
$row_count = $GLOBALS['dbi']->numRows($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -720,13 +720,13 @@ class PMA_Table
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation'][$pma_table]) . '
|
||||
WHERE ' . implode(' AND ', $where_parts);
|
||||
|
||||
// must use PMA_DBI_QUERY_STORE here, since we execute another
|
||||
// must use PMA_DatabaseInterface::QUERY_STORE here, since we execute another
|
||||
// query inside the loop
|
||||
$table_copy_rs = PMA_queryAsControlUser(
|
||||
$table_copy_query, true, PMA_DBI_QUERY_STORE
|
||||
$table_copy_query, true, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
while ($table_copy_row = @PMA_DBI_fetchAssoc($table_copy_rs)) {
|
||||
while ($table_copy_row = @$GLOBALS['dbi']->fetchAssoc($table_copy_rs)) {
|
||||
$value_parts = array();
|
||||
foreach ($table_copy_row as $_key => $_val) {
|
||||
if (isset($row_fields[$_key]) && $row_fields[$_key] == 'cc') {
|
||||
@ -744,10 +744,10 @@ class PMA_Table
|
||||
\'' . implode('\', \'', $new_value_parts) . '\')';
|
||||
|
||||
PMA_queryAsControlUser($new_table_query);
|
||||
$last_id = PMA_DBI_insertId();
|
||||
$last_id = $GLOBALS['dbi']->insertId();
|
||||
} // end while
|
||||
|
||||
PMA_DBI_freeResult($table_copy_rs);
|
||||
$GLOBALS['dbi']->freeResult($table_copy_rs);
|
||||
|
||||
return $last_id;
|
||||
}
|
||||
@ -815,7 +815,7 @@ class PMA_Table
|
||||
|
||||
// Doing a select_db could avoid some problems with replicated databases,
|
||||
// when moving table from replicated one to not replicated one
|
||||
PMA_DBI_selectDb($target_db);
|
||||
$GLOBALS['dbi']->selectDb($target_db);
|
||||
|
||||
$target = PMA_Util::backquote($target_db) . '.' . PMA_Util::backquote($target_table);
|
||||
|
||||
@ -859,7 +859,7 @@ class PMA_Table
|
||||
if (PMA_DRIZZLE) {
|
||||
$table_delimiter = 'quote_backtick';
|
||||
} else {
|
||||
$server_sql_mode = PMA_DBI_fetchValue(
|
||||
$server_sql_mode = $GLOBALS['dbi']->fetchValue(
|
||||
"SHOW VARIABLES LIKE 'sql_mode'",
|
||||
0,
|
||||
1
|
||||
@ -918,7 +918,7 @@ class PMA_Table
|
||||
$drop_query .= ' IF EXISTS '
|
||||
. PMA_Util::backquote($target_db) . '.'
|
||||
. PMA_Util::backquote($target_table);
|
||||
PMA_DBI_query($drop_query);
|
||||
$GLOBALS['dbi']->query($drop_query);
|
||||
|
||||
$GLOBALS['sql_query'] .= "\n" . $drop_query . ';';
|
||||
|
||||
@ -927,7 +927,7 @@ class PMA_Table
|
||||
$maintain_relations = true;
|
||||
}
|
||||
|
||||
@PMA_DBI_query($sql_structure);
|
||||
@$GLOBALS['dbi']->query($sql_structure);
|
||||
$GLOBALS['sql_query'] .= "\n" . $sql_structure . ';';
|
||||
|
||||
if (($move || isset($GLOBALS['add_constraints']))
|
||||
@ -971,7 +971,7 @@ class PMA_Table
|
||||
$parsed_sql, 'query_only'
|
||||
);
|
||||
if ($mode == 'one_table') {
|
||||
PMA_DBI_query($GLOBALS['sql_constraints_query']);
|
||||
$GLOBALS['dbi']->query($GLOBALS['sql_constraints_query']);
|
||||
}
|
||||
$GLOBALS['sql_query'] .= "\n" . $GLOBALS['sql_constraints_query'];
|
||||
if ($mode == 'one_table') {
|
||||
@ -987,12 +987,12 @@ class PMA_Table
|
||||
&& ! PMA_Table::isView($target_db, $target_table)
|
||||
) {
|
||||
$sql_set_mode = "SET SQL_MODE='NO_AUTO_VALUE_ON_ZERO'";
|
||||
PMA_DBI_query($sql_set_mode);
|
||||
$GLOBALS['dbi']->query($sql_set_mode);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_set_mode . ';';
|
||||
|
||||
$sql_insert_data = 'INSERT INTO ' . $target
|
||||
. ' SELECT * FROM ' . $source;
|
||||
PMA_DBI_query($sql_insert_data);
|
||||
$GLOBALS['dbi']->query($sql_insert_data);
|
||||
$GLOBALS['sql_query'] .= "\n\n" . $sql_insert_data . ';';
|
||||
}
|
||||
|
||||
@ -1003,7 +1003,7 @@ class PMA_Table
|
||||
|
||||
// This could avoid some problems with replicated databases, when
|
||||
// moving table from replicated one to not replicated one
|
||||
PMA_DBI_selectDb($source_db);
|
||||
$GLOBALS['dbi']->selectDb($source_db);
|
||||
|
||||
if (PMA_Table::isView($source_db, $source_table)) {
|
||||
$sql_drop_query = 'DROP VIEW';
|
||||
@ -1011,7 +1011,7 @@ class PMA_Table
|
||||
$sql_drop_query = 'DROP TABLE';
|
||||
}
|
||||
$sql_drop_query .= ' ' . $source;
|
||||
PMA_DBI_query($sql_drop_query);
|
||||
$GLOBALS['dbi']->query($sql_drop_query);
|
||||
|
||||
// Renable table in configuration storage
|
||||
PMA_REL_renameTable(
|
||||
@ -1036,7 +1036,7 @@ class PMA_Table
|
||||
$comments_copy_rs = PMA_queryAsControlUser($comments_copy_query);
|
||||
|
||||
// Write every comment as new copied entry. [MIME]
|
||||
while ($comments_copy_row = PMA_DBI_fetchAssoc($comments_copy_rs)) {
|
||||
while ($comments_copy_row = $GLOBALS['dbi']->fetchAssoc($comments_copy_rs)) {
|
||||
$new_comment_query = 'REPLACE INTO ' . PMA_Util::backquote($GLOBALS['cfgRelation']['db']) . '.' . PMA_Util::backquote($GLOBALS['cfgRelation']['column_info'])
|
||||
. ' (db_name, table_name, column_name, comment' . ($GLOBALS['cfgRelation']['mimework'] ? ', mimetype, transformation, transformation_options' : '') . ') '
|
||||
. ' VALUES('
|
||||
@ -1050,7 +1050,7 @@ class PMA_Table
|
||||
. ')';
|
||||
PMA_queryAsControlUser($new_comment_query);
|
||||
} // end while
|
||||
PMA_DBI_freeResult($comments_copy_rs);
|
||||
$GLOBALS['dbi']->freeResult($comments_copy_rs);
|
||||
unset($comments_copy_rs);
|
||||
}
|
||||
|
||||
@ -1248,13 +1248,13 @@ class PMA_Table
|
||||
}
|
||||
|
||||
// If the table is moved to a different database drop its triggers first
|
||||
$triggers = PMA_DBI_getTriggers($this->getDbName(), $this->getName(), '');
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($this->getDbName(), $this->getName(), '');
|
||||
$handle_triggers = $this->getDbName() != $new_db && $triggers;
|
||||
if ($handle_triggers) {
|
||||
foreach ($triggers as $trigger) {
|
||||
$sql = 'DROP TRIGGER IF EXISTS ' . PMA_Util::backquote($this->getDbName())
|
||||
. '.' . PMA_Util::backquote($trigger['name']) . ';';
|
||||
PMA_DBI_query($sql);
|
||||
$GLOBALS['dbi']->query($sql);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1265,12 +1265,12 @@ class PMA_Table
|
||||
RENAME TABLE ' . $this->getFullName(true) . '
|
||||
TO ' . $new_table->getFullName(true) . ';';
|
||||
// I don't think a specific error message for views is necessary
|
||||
if (! PMA_DBI_query($GLOBALS['sql_query'])) {
|
||||
if (! $GLOBALS['dbi']->query($GLOBALS['sql_query'])) {
|
||||
// Restore triggers in the old database
|
||||
if ($handle_triggers) {
|
||||
PMA_DBI_selectDb($this->getDbName());
|
||||
$GLOBALS['dbi']->selectDb($this->getDbName());
|
||||
foreach ($triggers as $trigger) {
|
||||
PMA_DBI_query($trigger['create']);
|
||||
$GLOBALS['dbi']->query($trigger['create']);
|
||||
}
|
||||
}
|
||||
$this->errors[] = sprintf(
|
||||
@ -1318,12 +1318,12 @@ class PMA_Table
|
||||
*/
|
||||
public function getUniqueColumns($backquoted = true)
|
||||
{
|
||||
$sql = PMA_DBI_getTableIndexesSql(
|
||||
$sql = $GLOBALS['dbi']->getTableIndexesSql(
|
||||
$this->getDbName(),
|
||||
$this->getName(),
|
||||
'Non_unique = 0'
|
||||
);
|
||||
$uniques = PMA_DBI_fetchResult(
|
||||
$uniques = $GLOBALS['dbi']->fetchResult(
|
||||
$sql,
|
||||
array('Key_name', null),
|
||||
'Column_name'
|
||||
@ -1355,12 +1355,12 @@ class PMA_Table
|
||||
*/
|
||||
public function getIndexedColumns($backquoted = true)
|
||||
{
|
||||
$sql = PMA_DBI_getTableIndexesSql(
|
||||
$sql = $GLOBALS['dbi']->getTableIndexesSql(
|
||||
$this->getDbName(),
|
||||
$this->getName(),
|
||||
'Seq_in_index = 1'
|
||||
);
|
||||
$indexed = PMA_DBI_fetchResult($sql, 'Column_name', 'Column_name');
|
||||
$indexed = $GLOBALS['dbi']->fetchResult($sql, 'Column_name', 'Column_name');
|
||||
|
||||
$return = array();
|
||||
foreach ($indexed as $column) {
|
||||
@ -1383,7 +1383,7 @@ class PMA_Table
|
||||
public function getColumns($backquoted = true)
|
||||
{
|
||||
$sql = 'SHOW COLUMNS FROM ' . $this->getFullName(true);
|
||||
$indexed = PMA_DBI_fetchResult($sql, 'Field', 'Field');
|
||||
$indexed = $GLOBALS['dbi']->fetchResult($sql, 'Field', 'Field');
|
||||
|
||||
$return = array();
|
||||
foreach ($indexed as $column) {
|
||||
@ -1410,7 +1410,7 @@ class PMA_Table
|
||||
. " AND `db_name` = '" . PMA_Util::sqlAddSlashes($this->db_name) . "'"
|
||||
. " AND `table_name` = '" . PMA_Util::sqlAddSlashes($this->name) . "'";
|
||||
|
||||
$row = PMA_DBI_fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
$row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
if (isset($row[0])) {
|
||||
return json_decode($row[0], true);
|
||||
} else {
|
||||
@ -1434,13 +1434,13 @@ class PMA_Table
|
||||
. "', '" . PMA_Util::sqlAddSlashes($this->name) . "', '"
|
||||
. PMA_Util::sqlAddSlashes(json_encode($this->uiprefs)) . "', NULL)";
|
||||
|
||||
$success = PMA_DBI_tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
|
||||
if (!$success) {
|
||||
$message = PMA_Message::error(__('Could not save table UI preferences'));
|
||||
$message->addMessage('<br /><br />');
|
||||
$message->addMessage(
|
||||
PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
|
||||
PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink']))
|
||||
);
|
||||
return $message;
|
||||
}
|
||||
@ -1448,7 +1448,7 @@ class PMA_Table
|
||||
// Remove some old rows in table_uiprefs if it exceeds the configured
|
||||
// maximum rows
|
||||
$sql_query = 'SELECT COUNT(*) FROM ' . $pma_table;
|
||||
$rows_count = PMA_DBI_fetchValue($sql_query);
|
||||
$rows_count = $GLOBALS['dbi']->fetchValue($sql_query);
|
||||
$max_rows = $GLOBALS['cfg']['Server']['MaxTableUiprefs'];
|
||||
if ($rows_count > $max_rows) {
|
||||
$num_rows_to_delete = $rows_count - $max_rows;
|
||||
@ -1456,7 +1456,7 @@ class PMA_Table
|
||||
= ' DELETE FROM ' . $pma_table .
|
||||
' ORDER BY last_update ASC' .
|
||||
' LIMIT ' . $num_rows_to_delete;
|
||||
$success = PMA_DBI_tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
$success = $GLOBALS['dbi']->tryQuery($sql_query, $GLOBALS['controllink']);
|
||||
|
||||
if (!$success) {
|
||||
$message = PMA_Message::error(
|
||||
@ -1467,7 +1467,7 @@ class PMA_Table
|
||||
);
|
||||
$message->addMessage('<br /><br />');
|
||||
$message->addMessage(
|
||||
PMA_Message::rawError(PMA_DBI_getError($GLOBALS['controllink']))
|
||||
PMA_Message::rawError($GLOBALS['dbi']->getError($GLOBALS['controllink']))
|
||||
);
|
||||
print_r($message);
|
||||
return $message;
|
||||
|
||||
@ -123,7 +123,7 @@ class PMA_TableSearch
|
||||
private function _loadTableInfo()
|
||||
{
|
||||
// Gets the list and number of columns
|
||||
$columns = PMA_DBI_getColumns($this->_db, $this->_table, null, true);
|
||||
$columns = $GLOBALS['dbi']->getColumns($this->_db, $this->_table, null, true);
|
||||
// Get details about the geometry fucntions
|
||||
$geom_types = PMA_Util::getGISDatatypes();
|
||||
|
||||
|
||||
@ -213,7 +213,7 @@ class PMA_Tracker
|
||||
" AND table_name = '" . PMA_Util::sqlAddSlashes($tablename) . "' " .
|
||||
" ORDER BY version DESC";
|
||||
|
||||
$row = PMA_DBI_fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
$row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
|
||||
if (isset($row['tracking_active']) && $row['tracking_active'] == 1) {
|
||||
return true;
|
||||
@ -275,7 +275,7 @@ class PMA_Tracker
|
||||
|
||||
// Get data definition snapshot of table
|
||||
|
||||
$columns = PMA_DBI_getColumns($dbname, $tablename, null, true);
|
||||
$columns = $GLOBALS['dbi']->getColumns($dbname, $tablename, null, true);
|
||||
// int indices to reduce size
|
||||
$columns = array_values($columns);
|
||||
// remove Privileges to reduce size
|
||||
@ -283,7 +283,7 @@ class PMA_Tracker
|
||||
unset($columns[$i]['Privileges']);
|
||||
}
|
||||
|
||||
$indexes = PMA_DBI_getTableIndexes($dbname, $tablename);
|
||||
$indexes = $GLOBALS['dbi']->getTableIndexes($dbname, $tablename);
|
||||
|
||||
$snapshot = array('COLUMNS' => $columns, 'INDEXES' => $indexes);
|
||||
$snapshot = serialize($snapshot);
|
||||
@ -560,7 +560,7 @@ class PMA_Tracker
|
||||
? ' AND tracking & ' . self::_transformTrackingSet($statement) . ' <> 0'
|
||||
: " AND FIND_IN_SET('" . $statement . "',tracking) > 0" ;
|
||||
}
|
||||
$row = PMA_DBI_fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
$row = $GLOBALS['dbi']->fetchArray(PMA_queryAsControlUser($sql_query));
|
||||
return isset($row[0])
|
||||
? $row[0]
|
||||
: -1;
|
||||
@ -592,7 +592,7 @@ class PMA_Tracker
|
||||
$sql_query .= " AND `version` = '" . PMA_Util::sqlAddSlashes($version) ."' ".
|
||||
" ORDER BY `version` DESC LIMIT 1";
|
||||
|
||||
$mixed = PMA_DBI_fetchAssoc(PMA_queryAsControlUser($sql_query));
|
||||
$mixed = $GLOBALS['dbi']->fetchAssoc(PMA_queryAsControlUser($sql_query));
|
||||
|
||||
// Parse log
|
||||
$log_schema_entries = explode('# log ', $mixed['schema_sql']);
|
||||
|
||||
@ -832,7 +832,7 @@ class PMA_Types_Drizzle extends PMA_Types
|
||||
WHERE plugin_name IN ('" . implode("','", $functions) . "')
|
||||
AND plugin_type = 'Function'
|
||||
AND is_active";
|
||||
$drizzle_functions = PMA_DBI_fetchResult($sql, 'f', 'f');
|
||||
$drizzle_functions = $GLOBALS['dbi']->fetchResult($sql, 'f', 'f');
|
||||
if (count($drizzle_functions) > 0) {
|
||||
$ret = array_merge($ret, $drizzle_functions);
|
||||
sort($ret);
|
||||
|
||||
@ -633,7 +633,7 @@ class PMA_Util
|
||||
$error_msg = '';
|
||||
|
||||
if (! $error_message) {
|
||||
$error_message = PMA_DBI_getError();
|
||||
$error_message = $GLOBALS['dbi']->getError();
|
||||
}
|
||||
if (! $the_query && ! empty($GLOBALS['sql_query'])) {
|
||||
$the_query = $GLOBALS['sql_query'];
|
||||
@ -791,7 +791,7 @@ class PMA_Util
|
||||
$sep = $GLOBALS['cfg']['NavigationTreeTableSeparator'];
|
||||
|
||||
if ($tables === null) {
|
||||
$tables = PMA_DBI_getTablesFull(
|
||||
$tables = $GLOBALS['dbi']->getTablesFull(
|
||||
$db, false, false, null, $limit_offset, $limit_count
|
||||
);
|
||||
if ($GLOBALS['cfg']['NaturalOrder']) {
|
||||
@ -826,7 +826,7 @@ class PMA_Util
|
||||
// set this because PMA_Table::countRecords() can use it
|
||||
$tbl_is_view = $table['TABLE_TYPE'] == 'VIEW';
|
||||
|
||||
if ($tbl_is_view || PMA_isSystemSchema($db)) {
|
||||
if ($tbl_is_view || $GLOBALS['dbi']->isSystemSchema($db)) {
|
||||
$table['Rows'] = PMA_Table::countRecords(
|
||||
$db,
|
||||
$table['Name'],
|
||||
@ -1397,7 +1397,7 @@ class PMA_Util
|
||||
// and do not set a constant as we might be switching servers
|
||||
if (defined('PMA_MYSQL_INT_VERSION')
|
||||
&& (PMA_MYSQL_INT_VERSION >= 50037)
|
||||
&& PMA_DBI_fetchValue("SHOW VARIABLES LIKE 'profiling'")
|
||||
&& $GLOBALS['dbi']->fetchValue("SHOW VARIABLES LIKE 'profiling'")
|
||||
) {
|
||||
self::cacheSet('profiling_supported', true, true);
|
||||
} else {
|
||||
@ -2181,7 +2181,7 @@ class PMA_Util
|
||||
$condition = '';
|
||||
$con_key = '';
|
||||
$con_val = '';
|
||||
$field_flags = PMA_DBI_fieldFlags($handle, $i);
|
||||
$field_flags = $GLOBALS['dbi']->fieldFlags($handle, $i);
|
||||
$meta = $fields_meta[$i];
|
||||
|
||||
// do not use a column alias in a condition
|
||||
@ -3174,15 +3174,17 @@ class PMA_Util
|
||||
$wktsql .= ", SRID(x'" . $hex . "')";
|
||||
}
|
||||
|
||||
$wktresult = PMA_DBI_tryQuery($wktsql, null, PMA_DBI_QUERY_STORE);
|
||||
$wktarr = PMA_DBI_fetchRow($wktresult, 0);
|
||||
$wktresult = $GLOBALS['dbi']->tryQuery(
|
||||
$wktsql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$wktarr = $GLOBALS['dbi']->fetchRow($wktresult, 0);
|
||||
$wktval = $wktarr[0];
|
||||
|
||||
if ($includeSRID) {
|
||||
$srid = $wktarr[1];
|
||||
$wktval = "'" . $wktval . "'," . $srid;
|
||||
}
|
||||
@PMA_DBI_freeResult($wktresult);
|
||||
@$GLOBALS['dbi']->freeResult($wktresult);
|
||||
|
||||
return $wktval;
|
||||
}
|
||||
@ -3312,7 +3314,7 @@ class PMA_Util
|
||||
|
||||
/* Fetch columns list if required */
|
||||
if (strpos($string, '@COLUMNS@') !== false) {
|
||||
$columns_list = PMA_DBI_getColumns($GLOBALS['db'], $GLOBALS['table']);
|
||||
$columns_list = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $GLOBALS['table']);
|
||||
|
||||
// sometimes the table no longer exists at this point
|
||||
if (! is_null($columns_list)) {
|
||||
@ -3851,7 +3853,7 @@ class PMA_Util
|
||||
{
|
||||
// Get the username for the current user in the format
|
||||
// required to use in the information schema database.
|
||||
$user = PMA_DBI_fetchValue("SELECT CURRENT_USER();");
|
||||
$user = $GLOBALS['dbi']->fetchValue("SELECT CURRENT_USER();");
|
||||
if ($user === false) {
|
||||
return false;
|
||||
}
|
||||
@ -3868,7 +3870,7 @@ class PMA_Util
|
||||
. "WHERE GRANTEE='%s' AND PRIVILEGE_TYPE='%s'";
|
||||
|
||||
// Check global privileges first.
|
||||
$user_privileges = PMA_DBI_fetchValue(
|
||||
$user_privileges = $GLOBALS['dbi']->fetchValue(
|
||||
sprintf(
|
||||
$query,
|
||||
'USER_PRIVILEGES',
|
||||
@ -3885,7 +3887,7 @@ class PMA_Util
|
||||
// need to escape wildcards in db and table names, see bug #3518484
|
||||
$db = str_replace(array('%', '_'), array('\%', '\_'), $db);
|
||||
$query .= " AND TABLE_SCHEMA='%s'";
|
||||
$schema_privileges = PMA_DBI_fetchValue(
|
||||
$schema_privileges = $GLOBALS['dbi']->fetchValue(
|
||||
sprintf(
|
||||
$query,
|
||||
'SCHEMA_PRIVILEGES',
|
||||
@ -3908,7 +3910,7 @@ class PMA_Util
|
||||
// need to escape wildcards in db and table names, see bug #3518484
|
||||
$tbl = str_replace(array('%', '_'), array('\%', '\_'), $tbl);
|
||||
$query .= " AND TABLE_NAME='%s'";
|
||||
$table_privileges = PMA_DBI_fetchValue(
|
||||
$table_privileges = $GLOBALS['dbi']->fetchValue(
|
||||
sprintf(
|
||||
$query,
|
||||
'TABLE_PRIVILEGES',
|
||||
@ -4098,5 +4100,31 @@ class PMA_Util
|
||||
. PMA_Util::localisedDate(strtotime($table['Check_time']));
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get regular expression which occur first inside the given sql query.
|
||||
*
|
||||
* @param Array $regex_array Comparing regular expressions.
|
||||
* @param String $query SQL query to be checked.
|
||||
*
|
||||
* @return String Matching regular expression.
|
||||
*/
|
||||
public static function getFirstOccuringRegularExpression($regex_array, $query)
|
||||
{
|
||||
$minimum_first_occurance_index = null;
|
||||
$regex = null;
|
||||
|
||||
for ($i = 0; $i < count($regex_array); $i++) {
|
||||
if (preg_match($regex_array[$i], $query, $matches, PREG_OFFSET_CAPTURE)) {
|
||||
if (is_null($minimum_first_occurance_index)
|
||||
|| ($matches[0][1] < $minimum_first_occurance_index)
|
||||
) {
|
||||
$regex = $regex_array[$i];
|
||||
$minimum_first_occurance_index = $matches[0][1];
|
||||
}
|
||||
}
|
||||
}
|
||||
return $regex;
|
||||
}
|
||||
}
|
||||
?>
|
||||
|
||||
@ -65,8 +65,8 @@ function PMA_Bookmark_getList($db)
|
||||
. ' WHERE dbase = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND user = \'' . PMA_Util::sqlAddSlashes($cfgBookmark['user']) . '\''
|
||||
. ' ORDER BY label';
|
||||
$per_user = PMA_DBI_fetchResult(
|
||||
$query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE
|
||||
$per_user = $GLOBALS['dbi']->fetchResult(
|
||||
$query, 'id', 'label', $controllink, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
$query = 'SELECT label, id FROM '. PMA_Util::backquote($cfgBookmark['db'])
|
||||
@ -74,8 +74,8 @@ function PMA_Bookmark_getList($db)
|
||||
. ' WHERE dbase = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND user = \'\''
|
||||
. ' ORDER BY label';
|
||||
$global = PMA_DBI_fetchResult(
|
||||
$query, 'id', 'label', $controllink, PMA_DBI_QUERY_STORE
|
||||
$global = $GLOBALS['dbi']->fetchResult(
|
||||
$query, 'id', 'label', $controllink, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
foreach ($global as $key => $val) {
|
||||
@ -132,7 +132,7 @@ function PMA_Bookmark_get($db, $id, $id_field = 'id', $action_bookmark_all = fal
|
||||
|
||||
$query .= ' AND ' . PMA_Util::backquote($id_field) . ' = ' . $id;
|
||||
|
||||
return PMA_DBI_fetchValue($query, 0, 0, $controllink);
|
||||
return $GLOBALS['dbi']->fetchValue($query, 0, 0, $controllink);
|
||||
} // end of the 'PMA_Bookmark_get()' function
|
||||
|
||||
/**
|
||||
@ -165,7 +165,7 @@ function PMA_Bookmark_save($fields, $all_users = false)
|
||||
. '\'' . ($all_users ? '' : PMA_Util::sqlAddSlashes($fields['user'])) . '\', '
|
||||
. '\'' . PMA_Util::sqlAddSlashes(urldecode($fields['query'])) . '\', '
|
||||
. '\'' . PMA_Util::sqlAddSlashes($fields['label']) . '\')';
|
||||
return PMA_DBI_query($query, $controllink);
|
||||
return $GLOBALS['dbi']->query($query, $controllink);
|
||||
} // end of the 'PMA_Bookmark_save()' function
|
||||
|
||||
|
||||
@ -196,7 +196,7 @@ function PMA_Bookmark_delete($db, $id)
|
||||
. ' WHERE (user = \'' . PMA_Util::sqlAddSlashes($cfgBookmark['user']) . '\''
|
||||
. ' OR user = \'\')'
|
||||
. ' AND id = ' . $id;
|
||||
return PMA_DBI_tryQuery($query, $controllink);
|
||||
return $GLOBALS['dbi']->tryQuery($query, $controllink);
|
||||
} // end of the 'PMA_Bookmark_delete()' function
|
||||
|
||||
|
||||
|
||||
@ -81,7 +81,7 @@ function PMA_buildHtmlForDb(
|
||||
. 'title="' . htmlspecialchars($current['SCHEMA_NAME']) . '" '
|
||||
. 'value="' . htmlspecialchars($current['SCHEMA_NAME']) . '"';
|
||||
|
||||
if (PMA_isSystemSchema($current['SCHEMA_NAME'], true)) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($current['SCHEMA_NAME'], true)) {
|
||||
$out .= ' disabled="disabled"';
|
||||
}
|
||||
$out .= ' /></td>';
|
||||
|
||||
@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
$GLOBALS['is_superuser'] = PMA_isSuperuser();
|
||||
$GLOBALS['is_superuser'] = $GLOBALS['dbi']->isSuperuser();
|
||||
|
||||
/**
|
||||
* sets privilege information extracted from SHOW GRANTS result
|
||||
@ -51,7 +51,7 @@ function PMA_analyseShowGrant()
|
||||
$GLOBALS['db_to_create'] = '';
|
||||
$GLOBALS['dbs_where_create_table_allowed'] = array();
|
||||
|
||||
$rs_usr = PMA_DBI_tryQuery('SHOW GRANTS');
|
||||
$rs_usr = $GLOBALS['dbi']->tryQuery('SHOW GRANTS');
|
||||
|
||||
if (! $rs_usr) {
|
||||
return;
|
||||
@ -60,7 +60,7 @@ function PMA_analyseShowGrant()
|
||||
$re0 = '(^|(\\\\\\\\)+|[^\\\\])'; // non-escaped wildcards
|
||||
$re1 = '(^|[^\\\\])(\\\)+'; // escaped wildcards
|
||||
|
||||
while ($row = PMA_DBI_fetchRow($rs_usr)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($rs_usr)) {
|
||||
// extract db from GRANT ... ON *.* or GRANT ... ON db.*
|
||||
$db_name_offset = strpos($row[0], ' ON ') + 4;
|
||||
$show_grants_dbname = substr(
|
||||
@ -107,8 +107,8 @@ function PMA_analyseShowGrant()
|
||||
// does this db exist?
|
||||
if ((preg_match('/' . $re0 . '%|_/', $show_grants_dbname)
|
||||
&& ! preg_match('/\\\\%|\\\\_/', $show_grants_dbname))
|
||||
|| (! PMA_DBI_tryQuery('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test))
|
||||
&& substr(PMA_DBI_getError(), 1, 4) != 1044)
|
||||
|| (! $GLOBALS['dbi']->tryQuery('USE ' . preg_replace('/' . $re1 . '(%|_)/', '\\1\\3', $dbname_to_test))
|
||||
&& substr($GLOBALS['dbi']->getError(), 1, 4) != 1044)
|
||||
) {
|
||||
/**
|
||||
* Do not handle the underscore wildcard
|
||||
@ -135,7 +135,7 @@ function PMA_analyseShowGrant()
|
||||
} // end if
|
||||
} // end while
|
||||
|
||||
PMA_DBI_freeResult($rs_usr);
|
||||
$GLOBALS['dbi']->freeResult($rs_usr);
|
||||
|
||||
// must also cacheUnset() them in
|
||||
// libraries/plugins/auth/AuthenticationCookie.class.php
|
||||
|
||||
@ -816,7 +816,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
/**
|
||||
* Loads the proper database interface for this server
|
||||
*/
|
||||
include_once './libraries/database_interface.lib.php';
|
||||
include_once './libraries/database_interface.inc.php';
|
||||
|
||||
include_once './libraries/logging.lib.php';
|
||||
|
||||
@ -951,14 +951,14 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
// otherwise we leave the $server_details['port'] unset,
|
||||
// allowing it to take default mysql port
|
||||
|
||||
$controllink = PMA_DBI_connect(
|
||||
$controllink = $GLOBALS['dbi']->connect(
|
||||
$cfg['Server']['controluser'],
|
||||
$cfg['Server']['controlpass'],
|
||||
true,
|
||||
$server_details
|
||||
);
|
||||
} else {
|
||||
$controllink = PMA_DBI_connect(
|
||||
$controllink = $GLOBALS['dbi']->connect(
|
||||
$cfg['Server']['controluser'],
|
||||
$cfg['Server']['controlpass'],
|
||||
true
|
||||
@ -967,7 +967,7 @@ if (! defined('PMA_MINIMUM_COMMON')) {
|
||||
}
|
||||
|
||||
// Connects to the server (validates user's login)
|
||||
$userlink = PMA_DBI_connect(
|
||||
$userlink = $GLOBALS['dbi']->connect(
|
||||
$cfg['Server']['user'], $cfg['Server']['password'], false
|
||||
);
|
||||
|
||||
@ -1143,7 +1143,8 @@ unset($dummy);
|
||||
|
||||
// here, the function does not exist with this configuration:
|
||||
// $cfg['ServerDefault'] = 0;
|
||||
$GLOBALS['is_superuser'] = function_exists('PMA_isSuperuser') && PMA_isSuperuser();
|
||||
$GLOBALS['is_superuser']
|
||||
= isset($GLOBALS['dbi']) && $GLOBALS['dbi']->isSuperuser();
|
||||
|
||||
if (!empty($__redirect) && in_array($__redirect, $goto_whitelist)) {
|
||||
/**
|
||||
|
||||
@ -323,13 +323,13 @@ function PMA_warnMissingExtension($extension, $fatal = false, $extra = '')
|
||||
*/
|
||||
function PMA_getTableCount($db)
|
||||
{
|
||||
$tables = PMA_DBI_tryQuery(
|
||||
$tables = $GLOBALS['dbi']->tryQuery(
|
||||
'SHOW TABLES FROM ' . PMA_Util::backquote($db) . ';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if ($tables) {
|
||||
$num_tables = PMA_DBI_numRows($tables);
|
||||
PMA_DBI_freeResult($tables);
|
||||
$num_tables = $GLOBALS['dbi']->numRows($tables);
|
||||
$GLOBALS['dbi']->freeResult($tables);
|
||||
} else {
|
||||
$num_tables = 0;
|
||||
}
|
||||
|
||||
81
libraries/database_interface.inc.php
Normal file
81
libraries/database_interface.inc.php
Normal file
@ -0,0 +1,81 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Creates the database interface required for database interctions
|
||||
* and add it to GLOBALS.
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/DatabaseInterface.class.php';
|
||||
|
||||
$extension = null;
|
||||
if (defined('TESTSUITE')) {
|
||||
/**
|
||||
* For testsuite we use dummy driver which can fake some queries.
|
||||
*/
|
||||
include_once './libraries/dbi/DBIDummy.class.php';
|
||||
$extension = new PMA_DBI_Dummy();
|
||||
} else {
|
||||
|
||||
/**
|
||||
* check for requested extension
|
||||
*/
|
||||
$extensionName = $GLOBALS['cfg']['Server']['extension'];
|
||||
if (! PMA_DatabaseInterface::checkDbExtension($extensionName)) {
|
||||
|
||||
// if it fails try alternative extension ...
|
||||
// and display an error ...
|
||||
|
||||
/**
|
||||
* @todo add different messages for alternative extension
|
||||
* and complete fail (no alternative extension too)
|
||||
*/
|
||||
PMA_warnMissingExtension(
|
||||
$extensionName,
|
||||
false,
|
||||
PMA_Util::showDocu('faq', 'faqmysql')
|
||||
);
|
||||
|
||||
if ($extensionName === 'mysql') {
|
||||
$alternativ_extension = 'mysqli';
|
||||
} else {
|
||||
$alternativ_extension = 'mysql';
|
||||
}
|
||||
|
||||
if (! PMA_DatabaseInterface::checkDbExtension($alternativ_extension)) {
|
||||
// if alternative fails too ...
|
||||
PMA_warnMissingExtension(
|
||||
$extensionName,
|
||||
true,
|
||||
PMA_Util::showDocu('faq', 'faqmysql')
|
||||
);
|
||||
}
|
||||
|
||||
$GLOBALS['cfg']['Server']['extension'] = $alternativ_extension;
|
||||
unset($alternativ_extension);
|
||||
}
|
||||
|
||||
/**
|
||||
* Including The DBI Plugin
|
||||
*/
|
||||
switch($GLOBALS['cfg']['Server']['extension']) {
|
||||
case 'mysql' :
|
||||
include_once './libraries/dbi/DBIMysql.class.php';
|
||||
$extension = new PMA_DBI_Mysql();
|
||||
break;
|
||||
case 'mysqli' :
|
||||
include_once './libraries/dbi/DBIMysqli.class.php';
|
||||
$extension = new PMA_DBI_Mysqli();
|
||||
break;
|
||||
case 'drizzle' :
|
||||
include_once './libraries/dbi/DBIDrizzle.class.php';
|
||||
$extension = new PMA_DBI_Drizzle();
|
||||
break;
|
||||
}
|
||||
}
|
||||
$GLOBALS['dbi'] = new PMA_DatabaseInterface($extension);
|
||||
?>
|
||||
File diff suppressed because it is too large
Load Diff
@ -18,7 +18,7 @@ PMA_Util::checkParameters(array('db'));
|
||||
|
||||
$is_show_stats = $cfg['ShowStats'];
|
||||
|
||||
$db_is_information_schema = PMA_isSystemSchema($db);
|
||||
$db_is_information_schema = $GLOBALS['dbi']->isSystemSchema($db);
|
||||
if ($db_is_information_schema) {
|
||||
$is_show_stats = false;
|
||||
}
|
||||
@ -36,11 +36,11 @@ $err_url = $cfg['DefaultTabDatabase'] . '?' . PMA_generate_common_url($db);
|
||||
*/
|
||||
if (! isset($is_db) || ! $is_db) {
|
||||
if (strlen($db)) {
|
||||
$is_db = PMA_DBI_selectDb($db);
|
||||
$is_db = $GLOBALS['dbi']->selectDb($db);
|
||||
// This "Command out of sync" 2014 error may happen, for example
|
||||
// after calling a MySQL procedure; at this point we can't select
|
||||
// the db but it's not necessarily wrong
|
||||
if (PMA_DBI_getError() && $GLOBALS['errno'] == 2014) {
|
||||
if ($GLOBALS['dbi']->getError() && $GLOBALS['errno'] == 2014) {
|
||||
$is_db = true;
|
||||
unset($GLOBALS['errno']);
|
||||
}
|
||||
@ -75,7 +75,7 @@ if (isset($_REQUEST['submitcollation'])
|
||||
$sql_query = 'ALTER DATABASE '
|
||||
. PMA_Util::backquote($db)
|
||||
. ' DEFAULT' . PMA_generateCharsetQueryPart($_REQUEST['db_collation']);
|
||||
$result = PMA_DBI_query($sql_query);
|
||||
$result = $GLOBALS['dbi']->query($sql_query);
|
||||
$message = PMA_Message::success();
|
||||
unset($db_charset);
|
||||
|
||||
|
||||
@ -41,7 +41,7 @@ $is_show_stats = $cfg['ShowStats'];
|
||||
*/
|
||||
$db_is_information_schema = false;
|
||||
|
||||
if (PMA_isSystemSchema($db)) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($db)) {
|
||||
$is_show_stats = false;
|
||||
$db_is_information_schema = true;
|
||||
}
|
||||
@ -66,34 +66,34 @@ $tooltip_aliasname = array();
|
||||
|
||||
// Special speedup for newer MySQL Versions (in 4.0 format changed)
|
||||
if (true === $cfg['SkipLockedTables']) {
|
||||
$db_info_result = PMA_DBI_query(
|
||||
$db_info_result = $GLOBALS['dbi']->query(
|
||||
'SHOW OPEN TABLES FROM ' . PMA_Util::backquote($db) . ';'
|
||||
);
|
||||
|
||||
// Blending out tables in use
|
||||
if ($db_info_result && PMA_DBI_numRows($db_info_result) > 0) {
|
||||
while ($tmp = PMA_DBI_fetchRow($db_info_result)) {
|
||||
if ($db_info_result && $GLOBALS['dbi']->numRows($db_info_result) > 0) {
|
||||
while ($tmp = $GLOBALS['dbi']->fetchRow($db_info_result)) {
|
||||
// if in use memorize tablename
|
||||
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
|
||||
$sot_cache[$tmp[0]] = true;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($db_info_result);
|
||||
$GLOBALS['dbi']->freeResult($db_info_result);
|
||||
|
||||
if (isset($sot_cache)) {
|
||||
$db_info_result = PMA_DBI_query(
|
||||
$db_info_result = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLES FROM ' . PMA_Util::backquote($db) . $tbl_group_sql . ';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if ($db_info_result && PMA_DBI_numRows($db_info_result) > 0) {
|
||||
while ($tmp = PMA_DBI_fetchRow($db_info_result)) {
|
||||
if ($db_info_result && $GLOBALS['dbi']->numRows($db_info_result) > 0) {
|
||||
while ($tmp = $GLOBALS['dbi']->fetchRow($db_info_result)) {
|
||||
if (! isset($sot_cache[$tmp[0]])) {
|
||||
$sts_result = PMA_DBI_query(
|
||||
$sts_result = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db)
|
||||
. ' LIKE \'' . PMA_Util::sqlAddSlashes($tmp[0], true) . '\';'
|
||||
);
|
||||
$sts_tmp = PMA_DBI_fetchAssoc($sts_result);
|
||||
PMA_DBI_freeResult($sts_result);
|
||||
$sts_tmp = $GLOBALS['dbi']->fetchAssoc($sts_result);
|
||||
$GLOBALS['dbi']->freeResult($sts_result);
|
||||
unset($sts_result);
|
||||
|
||||
if (! isset($sts_tmp['Type']) && isset($sts_tmp['Engine'])) {
|
||||
@ -123,13 +123,13 @@ if (true === $cfg['SkipLockedTables']) {
|
||||
|
||||
$sot_ready = true;
|
||||
} elseif ($db_info_result) {
|
||||
PMA_DBI_freeResult($db_info_result);
|
||||
$GLOBALS['dbi']->freeResult($db_info_result);
|
||||
}
|
||||
unset($sot_cache);
|
||||
}
|
||||
unset($tmp);
|
||||
} elseif ($db_info_result) {
|
||||
PMA_DBI_freeResult($db_info_result);
|
||||
$GLOBALS['dbi']->freeResult($db_info_result);
|
||||
}
|
||||
}
|
||||
|
||||
@ -163,14 +163,14 @@ if (! isset($sot_ready)) {
|
||||
|
||||
if (! empty($tbl_group)) {
|
||||
// only tables for selected group
|
||||
$tables = PMA_DBI_getTablesFull(
|
||||
$tables = $GLOBALS['dbi']->getTablesFull(
|
||||
$db, $tbl_group, true, null, 0, false, $sort, $sort_order
|
||||
);
|
||||
} else {
|
||||
// all tables in db
|
||||
// - get the total number of tables
|
||||
// (needed for proper working of the MaxTableList feature)
|
||||
$tables = PMA_DBI_getTables($db);
|
||||
$tables = $GLOBALS['dbi']->getTables($db);
|
||||
$total_num_tables = count($tables);
|
||||
if (isset($sub_part) && $sub_part == '_export') {
|
||||
// (don't fetch only a subset if we are coming from db_export.php,
|
||||
@ -180,12 +180,12 @@ if (! isset($sot_ready)) {
|
||||
*
|
||||
* @todo Page selector for table names?
|
||||
*/
|
||||
$tables = PMA_DBI_getTablesFull(
|
||||
$tables = $GLOBALS['dbi']->getTablesFull(
|
||||
$db, false, false, null, 0, false, $sort, $sort_order
|
||||
);
|
||||
} else {
|
||||
// fetch the details for a possible limited subset
|
||||
$tables = PMA_DBI_getTablesFull(
|
||||
$tables = $GLOBALS['dbi']->getTablesFull(
|
||||
$db, false, false, null, $pos, true, $sort, $sort_order
|
||||
);
|
||||
}
|
||||
|
||||
@ -12,7 +12,7 @@ if (! defined('PHPMYADMIN')) {
|
||||
|
||||
if (empty($is_db)) {
|
||||
if (strlen($db)) {
|
||||
$is_db = @PMA_DBI_selectDb($db);
|
||||
$is_db = @$GLOBALS['dbi']->selectDb($db);
|
||||
} else {
|
||||
$is_db = false;
|
||||
}
|
||||
@ -58,13 +58,13 @@ if (empty($is_table)
|
||||
$is_table = isset(PMA_Table::$cache[$db][$table]);
|
||||
|
||||
if (! $is_table) {
|
||||
$_result = PMA_DBI_tryQuery(
|
||||
$_result = $GLOBALS['dbi']->tryQuery(
|
||||
'SHOW TABLES LIKE \'' . PMA_Util::sqlAddSlashes($table, true)
|
||||
. '\';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$is_table = @PMA_DBI_numRows($_result);
|
||||
PMA_DBI_freeResult($_result);
|
||||
$is_table = @$GLOBALS['dbi']->numRows($_result);
|
||||
$GLOBALS['dbi']->freeResult($_result);
|
||||
}
|
||||
} else {
|
||||
$is_table = false;
|
||||
@ -81,13 +81,13 @@ if (empty($is_table)
|
||||
* @todo should this check really
|
||||
* only happen if IS_TRANSFORMATION_WRAPPER?
|
||||
*/
|
||||
$_result = PMA_DBI_tryQuery(
|
||||
$_result = $GLOBALS['dbi']->tryQuery(
|
||||
'SELECT COUNT(*) FROM ' . PMA_Util::backquote($table) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$is_table = ($_result && @PMA_DBI_numRows($_result));
|
||||
PMA_DBI_freeResult($_result);
|
||||
$is_table = ($_result && @$GLOBALS['dbi']->numRows($_result));
|
||||
$GLOBALS['dbi']->freeResult($_result);
|
||||
}
|
||||
|
||||
if (! $is_table) {
|
||||
|
||||
679
libraries/dbi/DBIDrizzle.class.php
Normal file
679
libraries/dbi/DBIDrizzle.class.php
Normal file
@ -0,0 +1,679 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the Drizzle extension
|
||||
*
|
||||
* WARNING - EXPERIMENTAL, never use in production,
|
||||
* drizzle module segfaults often and when you least expect it to
|
||||
*
|
||||
* TODO: This file and drizzle-wrappers.lib.php should be devoid
|
||||
* of any segault related hacks.
|
||||
* TODO: Crashing versions of drizzle module and/or libdrizzle
|
||||
* should be blacklisted
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Drizzle
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
require_once './libraries/dbi/drizzle-wrappers.lib.php';
|
||||
require_once './libraries/dbi/DBIExtension.int.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (!defined('PMA_MYSQL_CLIENT_API')) {
|
||||
define('PMA_MYSQL_CLIENT_API', (int)drizzle_version());
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to the Drizzle extension
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Drizzle
|
||||
*/
|
||||
class PMA_DBI_Drizzle implements PMA_DBI_Extension
|
||||
{
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param PMA_Drizzle $drizzle connection handle
|
||||
* @param string $host Drizzle host
|
||||
* @param integer $port Drizzle port
|
||||
* @param string $uds server socket
|
||||
* @param string $user username
|
||||
* @param string $password password
|
||||
* @param string $db database name
|
||||
* @param integer $options connection options
|
||||
*
|
||||
* @return PMA_DrizzleCon
|
||||
*/
|
||||
private function _realConnect($drizzle, $host, $port, $uds, $user, $password,
|
||||
$db = null, $options = DRIZZLE_CON_NONE
|
||||
) {
|
||||
if ($uds) {
|
||||
$con = $drizzle->addUds($uds, $user, $password, $db, $options);
|
||||
} else {
|
||||
$con = $drizzle->addTcp($host, $port, $user, $password, $db, $options);
|
||||
}
|
||||
|
||||
return $con;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user drizzle user name
|
||||
* @param string $password drizzle user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
public function connect($user, $password, $is_controluser = false,
|
||||
$server = null, $auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? false
|
||||
: (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: $server['socket'];
|
||||
$server['host'] = (empty($server['host']))
|
||||
? 'localhost'
|
||||
: $server['host'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? false
|
||||
: (int) $cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? null
|
||||
: $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
if (strtolower($GLOBALS['cfg']['Server']['connect_type']) == 'tcp') {
|
||||
$GLOBALS['cfg']['Server']['socket'] = '';
|
||||
}
|
||||
|
||||
$drizzle = new PMA_Drizzle();
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if ($GLOBALS['cfg']['Server']['compress']) {
|
||||
$client_flags |= DRIZZLE_CAPABILITIES_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if ($GLOBALS['cfg']['Server']['ssl']) {
|
||||
$client_flags |= DRIZZLE_CAPABILITIES_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$link = @$this->_realConnect(
|
||||
$drizzle, $cfg['Server']['host'],
|
||||
$server_port, $server_socket, $user,
|
||||
$password, false, $client_flags
|
||||
);
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($link == false && isset($cfg['Server']['nopassword'])
|
||||
&& $cfg['Server']['nopassword'] && ! $is_controluser
|
||||
) {
|
||||
$link = @$this->_realConnect(
|
||||
$drizzle, $cfg['Server']['host'], $server_port, $server_socket,
|
||||
$user, null, false, $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$link = @$this->_realConnect(
|
||||
$drizzle, $server['host'], $server_port, $server_socket,
|
||||
$user, $password
|
||||
);
|
||||
}
|
||||
|
||||
if ($link == false) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling $GLOBALS['dbi']->connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'drizzle-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$GLOBALS['dbi']->postConnect($link, $is_controluser);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname database name to select
|
||||
* @param PMA_DrizzleCom $link connection object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $link->selectDb($dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return PMA_DrizzleResult
|
||||
*/
|
||||
public function realQuery($query, $link, $options)
|
||||
{
|
||||
$buffer_mode = $options & PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
? PMA_Drizzle::BUFFER_ROW
|
||||
: PMA_Drizzle::BUFFER_RESULT;
|
||||
$res = $link->query($query, $buffer_mode);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchArray($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchRow($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $offset offset to seek
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
public function dataSeek($result, $offset)
|
||||
{
|
||||
return $result->seek($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function freeResult($result)
|
||||
{
|
||||
if ($result instanceof PMA_DrizzleResult) {
|
||||
$result->free();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
public function moreResults()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
public function nextResult()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
public function getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$str = $link->port()
|
||||
? $link->host() . ':' . $link->port() . ' via TCP/IP'
|
||||
: 'Localhost via UNIX socket';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the Drizzle protocol used
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return int version of the Drizzle protocol used
|
||||
*/
|
||||
public function getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $link->protocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string Drizzle client library version
|
||||
*/
|
||||
public function getClientInfo()
|
||||
{
|
||||
return 'libdrizzle (Drizzle ' . drizzle_version() . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
public function getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
// Do not stop now. We still can get the error code
|
||||
// with mysqli_connect_errno()
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link) {
|
||||
$error_number = drizzle_con_errno($link->getConnectionObject());
|
||||
$error_message = drizzle_con_error($link->getConnectionObject());
|
||||
} else {
|
||||
$error_number = drizzle_errno();
|
||||
$error_message = drizzle_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after
|
||||
// the call to getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return $GLOBALS['dbi']->formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function numRows($result)
|
||||
{
|
||||
// see the note for $GLOBALS['dbi']->tryQuery();
|
||||
if (!is_bool($result)) {
|
||||
return @$result->numRows();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link
|
||||
* or $GLOBALS['userlink']
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// copied from mysql and mysqli
|
||||
|
||||
// When no controluser is defined, using mysqli_insert_id($link)
|
||||
// does not always return the last insert id due to a mixup with
|
||||
// the tracking mechanism, but this works:
|
||||
return $GLOBALS['dbi']->fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
// Curiously, this problem does not happen with the mysql extension but
|
||||
// there is another problem with BIGINT primary keys so insertId()
|
||||
// in the mysql extension also uses this logic.
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param PMA_DrizzleResult $link connection object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return $link->affectedRows();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
public function getFieldsMeta($result)
|
||||
{
|
||||
// Build an associative array for a type look up
|
||||
$typeAr = array();
|
||||
/*$typeAr[DRIZZLE_COLUMN_TYPE_DECIMAL] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDECIMAL] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_BIT] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TINY] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_SHORT] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_FLOAT] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DOUBLE] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NULL] = 'null';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONGLONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_INT24] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TIME] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DATETIME] = 'datetime';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_YEAR] = 'year';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_ENUM] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_SET] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VIRTUAL] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TINY_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONG_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VAR_STRING] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VARCHAR] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_STRING] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_GEOMETRY] = 'geometry';*/
|
||||
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME] = 'datetime';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL] = 'null';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR] = 'string';
|
||||
|
||||
// array of DrizzleColumn
|
||||
$columns = $result->getColumns();
|
||||
// columns in a standarized format
|
||||
$std_columns = array();
|
||||
|
||||
foreach ($columns as $k => $column) {
|
||||
$c = new stdClass();
|
||||
$c->name = $column->name();
|
||||
$c->orgname = $column->origName();
|
||||
$c->table = $column->table();
|
||||
$c->orgtable = $column->origTable();
|
||||
$c->def = $column->defaultValue();
|
||||
$c->db = $column->db();
|
||||
$c->catalog = $column->catalog();
|
||||
// $column->maxSize() returns always 0 while size() seems
|
||||
// to return a correct value (drizzle extension v.0.5, API v.7)
|
||||
$c->max_length = $column->size();
|
||||
$c->decimals = $column->decimals();
|
||||
$c->charsetnr = $column->charset();
|
||||
$c->type = $typeAr[$column->typeDrizzle()];
|
||||
$c->_type = $column->type();
|
||||
$c->flags = $this->fieldFlags($result, $k);
|
||||
$c->_flags = $column->flags();
|
||||
|
||||
$c->multiple_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY);
|
||||
$c->primary_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_PRI_KEY);
|
||||
$c->unique_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY);
|
||||
$c->not_null = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_NOT_NULL);
|
||||
$c->unsigned = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_UNSIGNED);
|
||||
$c->zerofill = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_ZEROFILL);
|
||||
$c->numeric = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_NUM);
|
||||
$c->blob = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_BLOB);
|
||||
|
||||
$std_columns[] = $c;
|
||||
}
|
||||
|
||||
return $std_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
public function numFields($result)
|
||||
{
|
||||
return $result->numColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
public function fieldLen($result, $i)
|
||||
{
|
||||
$colums = $result->getColumns();
|
||||
return $colums[$i]->size();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
public function fieldName($result, $i)
|
||||
{
|
||||
$colums = $result->getColumns();
|
||||
return $colums[$i]->name();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
public function fieldFlags($result, $i)
|
||||
{
|
||||
$columns = $result->getColumns();
|
||||
$f = $columns[$i];
|
||||
$type = $f->typeDrizzle();
|
||||
$charsetnr = $f->charset();
|
||||
$f = $f->flags();
|
||||
$flags = '';
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
|
||||
$flags .= 'unique ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_NUM) {
|
||||
$flags .= 'num ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_PART_KEY) {
|
||||
$flags .= 'part_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_SET) {
|
||||
$flags .= 'set ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_TIMESTAMP) {
|
||||
$flags .= 'timestamp ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT) {
|
||||
$flags .= 'auto_increment ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_ENUM) {
|
||||
$flags .= 'enum ';
|
||||
}
|
||||
// See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
|
||||
// to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
|
||||
// but instead the charsetnr member of the MYSQL_FIELD
|
||||
// structure. Watch out: some types like DATE returns 63 in charsetnr
|
||||
// so we have to check also the type.
|
||||
// Unfortunately there is no equivalent in the mysql extension.
|
||||
if (($type == DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB
|
||||
|| $type == DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR)
|
||||
&& 63 == $charsetnr
|
||||
) {
|
||||
$flags .= 'binary ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_ZEROFILL) {
|
||||
$flags .= 'zerofill ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNSIGNED) {
|
||||
$flags .= 'unsigned ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_BLOB) {
|
||||
$flags .= 'blob ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY) {
|
||||
$flags .= 'multiple_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
|
||||
$flags .= 'unique_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_PRI_KEY) {
|
||||
$flags .= 'primary_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_NOT_NULL) {
|
||||
$flags .= 'not_null ';
|
||||
}
|
||||
return trim($flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
public function storeResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -14,6 +14,8 @@ if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/dbi/DBIExtension.int.php';
|
||||
|
||||
/**
|
||||
* Array of queries this "driver" supports
|
||||
*/
|
||||
@ -34,8 +36,16 @@ $GLOBALS['dummy_queries'] = array(
|
||||
array(
|
||||
'query' => 'SHOW STORAGE ENGINES',
|
||||
'result' => array(
|
||||
array('Engine' => 'dummy', 'Support' => 'YES', 'Comment' => 'dummy comment'),
|
||||
array('Engine' => 'dummy2', 'Support' => 'NO', 'Comment' => 'dummy2 comment'),
|
||||
array(
|
||||
'Engine' => 'dummy',
|
||||
'Support' => 'YES',
|
||||
'Comment' => 'dummy comment'
|
||||
),
|
||||
array(
|
||||
'Engine' => 'dummy2',
|
||||
'Support' => 'NO',
|
||||
'Comment' => 'dummy2 comment'
|
||||
),
|
||||
)
|
||||
),
|
||||
array(
|
||||
@ -260,252 +270,380 @@ if (! defined('PMA_DRIZZLE')) {
|
||||
define('PMA_DRIZZLE', 0);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
* Fake database driver for testing purposes
|
||||
*
|
||||
* @param mysqli $link mysqli object
|
||||
* @param string $query multi query statement to execute
|
||||
* It has hardcoded results for given queries what makes easy to use it
|
||||
* in testsuite. Feel free to include other queries which your test will
|
||||
* need.
|
||||
*
|
||||
* @return boolean false always false since mysql extention not support
|
||||
* for multi query executions
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Dummy
|
||||
*/
|
||||
function PMA_DBI_realMultiQuery($link, $query)
|
||||
class PMA_DBI_Dummy implements PMA_DBI_Extension
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
public function connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname name of db to select
|
||||
* @param resource $link mysql link resource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function selectDb($dbname, $link = null)
|
||||
{
|
||||
$GLOBALS['dummy_db'] = $dbname;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname name of db to select
|
||||
* @param resource $link mysql link resource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_DBI_selectDb($dbname, $link = null)
|
||||
{
|
||||
$GLOBALS['dummy_db'] = $dbname;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to run
|
||||
* @param resource $link mysql link resource
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_DBI_realQuery($query, $link = null, $options = 0)
|
||||
{
|
||||
$query = trim(preg_replace('/ */', ' ', str_replace("\n", ' ', $query)));
|
||||
for ($i = 0; $i < count($GLOBALS['dummy_queries']); $i++) {
|
||||
if ($GLOBALS['dummy_queries'][$i]['query'] == $query) {
|
||||
$GLOBALS['dummy_queries'][$i]['pos'] = 0;
|
||||
if (is_array($GLOBALS['dummy_queries'][$i]['result'])) {
|
||||
return $i;
|
||||
} else {
|
||||
return false;
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to run
|
||||
* @param resource $link mysql link resource
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function realQuery($query, $link = null, $options = 0)
|
||||
{
|
||||
$query = trim(preg_replace('/ */', ' ', str_replace("\n", ' ', $query)));
|
||||
for ($i = 0; $i < count($GLOBALS['dummy_queries']); $i++) {
|
||||
if ($GLOBALS['dummy_queries'][$i]['query'] == $query) {
|
||||
$GLOBALS['dummy_queries'][$i]['pos'] = 0;
|
||||
if (is_array($GLOBALS['dummy_queries'][$i]['result'])) {
|
||||
return $i;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
echo "Not supported query: $query\n";
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns result data from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchAny($result)
|
||||
{
|
||||
$query_data = $GLOBALS['dummy_queries'][$result];
|
||||
if ($query_data['pos'] >= count($query_data['result'])) {
|
||||
echo "Not supported query: $query\n";
|
||||
return false;
|
||||
}
|
||||
$ret = $query_data['result'][$query_data['pos']];
|
||||
$GLOBALS['dummy_queries'][$result]['pos'] += 1;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchArray($result)
|
||||
{
|
||||
$data = PMA_DBI_fetchAny($result);
|
||||
if (is_array($data) && isset($GLOBALS['dummy_queries'][$result]['columns'])) {
|
||||
foreach ($data as $key => $val) {
|
||||
$data[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param object $link connection object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return result collection | boolean(false)
|
||||
*/
|
||||
public function realMultiQuery($link, $query)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns result data from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAny($result)
|
||||
{
|
||||
$query_data = $GLOBALS['dummy_queries'][$result];
|
||||
if ($query_data['pos'] >= count($query_data['result'])) {
|
||||
return false;
|
||||
}
|
||||
$ret = $query_data['result'][$query_data['pos']];
|
||||
$GLOBALS['dummy_queries'][$result]['pos'] += 1;
|
||||
return $ret;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchArray($result)
|
||||
{
|
||||
$data = $this->fetchAny($result);
|
||||
if (is_array($data)
|
||||
&& isset($GLOBALS['dummy_queries'][$result]['columns'])
|
||||
) {
|
||||
foreach ($data as $key => $val) {
|
||||
$data[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchAssoc($result)
|
||||
{
|
||||
$data = PMA_DBI_fetchAny($result);
|
||||
if (is_array($data) && isset($GLOBALS['dummy_queries'][$result]['columns'])) {
|
||||
$ret = array();
|
||||
foreach ($data as $key => $val) {
|
||||
$ret[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($result)
|
||||
{
|
||||
$data = $this->fetchAny($result);
|
||||
if (is_array($data)
|
||||
&& isset($GLOBALS['dummy_queries'][$result]['columns'])
|
||||
) {
|
||||
$ret = array();
|
||||
foreach ($data as $key => $val) {
|
||||
$ret[$GLOBALS['dummy_queries'][$result]['columns'][$key]] = $val;
|
||||
}
|
||||
return $ret;
|
||||
}
|
||||
return $ret;
|
||||
return $data;
|
||||
}
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchRow($result)
|
||||
{
|
||||
$data = PMA_DBI_fetchAny($result);
|
||||
return $data;
|
||||
}
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchRow($result)
|
||||
{
|
||||
$data = $this->fetchAny($result);
|
||||
return $data;
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
function PMA_DBI_dataSeek($result, $offset)
|
||||
{
|
||||
if ($offset > count($GLOBALS['dummy_queries'][$result]['result'])) {
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function dataSeek($result, $offset)
|
||||
{
|
||||
if ($offset > count($GLOBALS['dummy_queries'][$result]['result'])) {
|
||||
return false;
|
||||
}
|
||||
$GLOBALS['dummy_queries'][$result]['pos'] = $offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function freeResult($result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @param object $link the connection object
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
public function moreResults($link = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
$GLOBALS['dummy_queries'][$result]['pos'] = $offset;
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_DBI_freeResult($result)
|
||||
{
|
||||
return;
|
||||
}
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @param object $link the connection object
|
||||
*
|
||||
* @return boo false
|
||||
*/
|
||||
public function nextResult($link = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
function PMA_DBI_moreResults()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return mixed false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @return boo false
|
||||
*/
|
||||
function PMA_DBI_nextResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param object $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
public function getHostInfo($link = null)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_numRows($result)
|
||||
{
|
||||
if (!is_bool($result)) {
|
||||
return count($GLOBALS['dummy_queries'][$result]['result']);
|
||||
} else {
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param object $link mysql link
|
||||
*
|
||||
* @return integer version of the MySQL protocol used
|
||||
*/
|
||||
public function getProtoInfo($link = null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
public function getClientInfo()
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param object $link connection link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
public function getError($link = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function numRows($result)
|
||||
{
|
||||
if (!is_bool($result)) {
|
||||
return count($GLOBALS['dummy_queries'][$result]['result']);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link
|
||||
* or $GLOBALS['userlink']
|
||||
*
|
||||
* @param object $link the connection object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function insertId($link = null)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
public function getFieldsMeta($result)
|
||||
{
|
||||
return array();
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
function PMA_DBI_numFields($result)
|
||||
{
|
||||
if (isset($GLOBALS['dummy_queries'][$result]['columns'])) {
|
||||
return count($GLOBALS['dummy_queries'][$result]['columns']);
|
||||
} else {
|
||||
return 0;
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
public function numFields($result)
|
||||
{
|
||||
if (isset($GLOBALS['dummy_queries'][$result]['columns'])) {
|
||||
return count($GLOBALS['dummy_queries'][$result]['columns']);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
public function fieldLen($result, $i)
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
public function fieldName($result, $i)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
public function fieldFlags($result, $i)
|
||||
{
|
||||
return '';
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
function PMA_DBI_getError($link = null)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
248
libraries/dbi/DBIExtension.int.php
Normal file
248
libraries/dbi/DBIExtension.int.php
Normal file
@ -0,0 +1,248 @@
|
||||
<?php
|
||||
/**
|
||||
* Contract for every database extension supported by phpMyAdmin
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Contract for every database extension supported by phpMyAdmin
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
*/
|
||||
interface PMA_DBI_Extension
|
||||
{
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user user name
|
||||
* @param string $password user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a connection object on success
|
||||
*/
|
||||
public function connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
);
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname database name to select
|
||||
* @param object $link connection object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function selectDb($dbname, $link = null);
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param object $link connection object
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return result object|bool
|
||||
*/
|
||||
public function realQuery($query, $link, $options);
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param object $link connection object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return result collection | boolean(false)
|
||||
*/
|
||||
public function realMultiQuery($link, $query);
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchArray($result);
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($result);
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchRow($result);
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param object $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function dataSeek($result, $offset);
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param object $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function freeResult($result);
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @param object $link the connection object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
public function moreResults($link = null);
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @param objecy $link the connection object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
public function nextResult($link = null);
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return mixed false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult();
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param object $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
public function getHostInfo($link = null);
|
||||
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param object $link mysql link
|
||||
*
|
||||
* @return integer version of the MySQL protocol used
|
||||
*/
|
||||
public function getProtoInfo($link = null);
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
public function getClientInfo();
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param object $link connection link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
public function getError($link = null);
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function numRows($result);
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link
|
||||
* or $GLOBALS['userlink']
|
||||
*
|
||||
* @param object $link the connection object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function insertId($link = null);
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param object $link the connection object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function affectedRows($link = null, $get_from_cache = true);
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
public function getFieldsMeta($result);
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
public function numFields($result);
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
public function fieldLen($result, $i);
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
public function fieldName($result, $i);
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param object $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
public function fieldFlags($result, $i);
|
||||
}
|
||||
?>
|
||||
566
libraries/dbi/DBIMysql.class.php
Normal file
566
libraries/dbi/DBIMysql.class.php
Normal file
@ -0,0 +1,566 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the classic MySQL extension
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQL
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
require_once './libraries/dbi/DBIExtension.int.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (! defined('PMA_MYSQL_CLIENT_API')) {
|
||||
$client_api = explode('.', mysql_get_client_info());
|
||||
define(
|
||||
'PMA_MYSQL_CLIENT_API',
|
||||
(int)sprintf(
|
||||
'%d%02d%02d',
|
||||
$client_api[0], $client_api[1], intval($client_api[2])
|
||||
)
|
||||
);
|
||||
unset($client_api);
|
||||
}
|
||||
|
||||
/**
|
||||
* Interface to the classic MySQL extension
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQL
|
||||
*/
|
||||
class PMA_DBI_Mysql implements PMA_DBI_Extension
|
||||
{
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param array $server host/port/socket
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param int $client_flags client flags of connection
|
||||
* @param bool $persistent whether to use peristent connection
|
||||
*
|
||||
* @return mixed false on error or a mysql connection resource on success
|
||||
*/
|
||||
private function _realConnect($server, $user, $password, $client_flags,
|
||||
$persistent = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if (empty($client_flags)) {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$link = @mysql_pconnect($server, $user, $password);
|
||||
} else {
|
||||
$link = @mysql_connect($server, $user, $password);
|
||||
}
|
||||
} else {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$link = @mysql_pconnect($server, $user, $password, $client_flags);
|
||||
} else {
|
||||
$link = @mysql_connect(
|
||||
$server, $user, $password, false, $client_flags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param mysqli $link mysqli object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return boolean false always false since mysql extention not support
|
||||
* for multi query executions
|
||||
*/
|
||||
public function realMultiQuery($link, $query)
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
public function connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? ''
|
||||
: ':' . (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: ':' . $server['socket'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? ''
|
||||
: ':' . (int)$cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? ''
|
||||
: ':' . $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
// always use CLIENT_LOCAL_FILES as defined in mysql_com.h
|
||||
// for the case where the client library was not compiled
|
||||
// with --enable-local-infile
|
||||
$client_flags |= 128;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if (defined('MYSQL_CLIENT_COMPRESS') && $cfg['Server']['compress']) {
|
||||
$client_flags |= MYSQL_CLIENT_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if (defined('MYSQL_CLIENT_SSL') && $cfg['Server']['ssl']) {
|
||||
$client_flags |= MYSQL_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$link = $this->_realConnect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, $password, empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
|
||||
// Retry with empty password if we're allowed to
|
||||
if (empty($link) && $cfg['Server']['nopassword'] && ! $is_controluser) {
|
||||
$link = $this->_realConnect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, '', empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!isset($server['host'])) {
|
||||
$link = $this->_realConnect($server_socket, $user, $password, null);
|
||||
} else {
|
||||
$link = $this->_realConnect(
|
||||
$server['host'] . $server_port . $server_socket,
|
||||
$user, $password, null
|
||||
);
|
||||
}
|
||||
}
|
||||
if (empty($link)) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling $GLOBALS['dbi']->connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'mysql-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // end if
|
||||
if (! $server) {
|
||||
$GLOBALS['dbi']->postConnect($link, $is_controluser);
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname name of db to select
|
||||
* @param resource $link mysql link resource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
public function selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_select_db($dbname, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to run
|
||||
* @param resource $link mysql link resource
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
public function realQuery($query, $link, $options)
|
||||
{
|
||||
if ($options == ($options | PMA_DatabaseInterface::QUERY_STORE)) {
|
||||
return mysql_query($query, $link);
|
||||
} elseif ($options == ($options | PMA_DatabaseInterface::QUERY_UNBUFFERED)) {
|
||||
return mysql_unbuffered_query($query, $link);
|
||||
} else {
|
||||
return mysql_query($query, $link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchArray($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchRow($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function dataSeek($result, $offset)
|
||||
{
|
||||
return mysql_data_seek($result, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function freeResult($result)
|
||||
{
|
||||
if (is_resource($result) && get_resource_type($result) === 'mysql result') {
|
||||
mysql_free_result($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
public function moreResults()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @return boo false
|
||||
*/
|
||||
public function nextResult()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
public function getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_get_host_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return int version of the MySQL protocol used
|
||||
*/
|
||||
public function getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_get_proto_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
public function getClientInfo()
|
||||
{
|
||||
return mysql_get_client_info();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
public function getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
|
||||
// Do not stop now. On the initial connection, we don't have a $link,
|
||||
// we don't have a $GLOBALS['userlink'], but we can catch the error code
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link && false !== $link) {
|
||||
$error_number = mysql_errno($link);
|
||||
$error_message = mysql_error($link);
|
||||
} else {
|
||||
$error_number = mysql_errno();
|
||||
$error_message = mysql_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after
|
||||
// the call to getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return $GLOBALS['dbi']->formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function numRows($result)
|
||||
{
|
||||
if (!is_bool($result)) {
|
||||
return mysql_num_rows($result);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link
|
||||
* or $GLOBALS['userlink']
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If the primary key is BIGINT we get an incorrect result
|
||||
// (sometimes negative, sometimes positive)
|
||||
// and in the present function we don't know if the PK is BIGINT
|
||||
// so better play safe and use LAST_INSERT_ID()
|
||||
//
|
||||
return $GLOBALS['dbi']->fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return mysql_affected_rows($link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*
|
||||
* @todo add missing keys like in mysqli_query (decimals)
|
||||
*/
|
||||
public function getFieldsMeta($result)
|
||||
{
|
||||
$fields = array();
|
||||
$num_fields = mysql_num_fields($result);
|
||||
for ($i = 0; $i < $num_fields; $i++) {
|
||||
$field = mysql_fetch_field($result, $i);
|
||||
$field->flags = mysql_field_flags($result, $i);
|
||||
$field->orgtable = mysql_field_table($result, $i);
|
||||
$field->orgname = mysql_field_name($result, $i);
|
||||
$fields[] = $field;
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
public function numFields($result)
|
||||
{
|
||||
return mysql_num_fields($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
public function fieldLen($result, $i)
|
||||
{
|
||||
return mysql_field_len($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
public function fieldName($result, $i)
|
||||
{
|
||||
return mysql_field_name($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
public function fieldFlags($result, $i)
|
||||
{
|
||||
return mysql_field_flags($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
public function storeResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
?>
|
||||
761
libraries/dbi/DBIMysqli.class.php
Normal file
761
libraries/dbi/DBIMysqli.class.php
Normal file
@ -0,0 +1,761 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the improved MySQL extension (MySQLi)
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQLi
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
require_once './libraries/dbi/DBIExtension.int.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (!defined('PMA_MYSQL_CLIENT_API')) {
|
||||
$client_api = explode('.', mysqli_get_client_info());
|
||||
define(
|
||||
'PMA_MYSQL_CLIENT_API',
|
||||
(int)sprintf(
|
||||
'%d%02d%02d',
|
||||
$client_api[0], $client_api[1], intval($client_api[2])
|
||||
)
|
||||
);
|
||||
unset($client_api);
|
||||
}
|
||||
|
||||
/**
|
||||
* some PHP versions are reporting extra messages like "No index used in query"
|
||||
*/
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
|
||||
/**
|
||||
* some older mysql client libs are missing these constants ...
|
||||
*/
|
||||
if (! defined('MYSQLI_BINARY_FLAG')) {
|
||||
define('MYSQLI_BINARY_FLAG', 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://bugs.php.net/36007
|
||||
*/
|
||||
if (! defined('MYSQLI_TYPE_NEWDECIMAL')) {
|
||||
define('MYSQLI_TYPE_NEWDECIMAL', 246);
|
||||
}
|
||||
if (! defined('MYSQLI_TYPE_BIT')) {
|
||||
define('MYSQLI_TYPE_BIT', 16);
|
||||
}
|
||||
|
||||
// for Drizzle
|
||||
if (! defined('MYSQLI_TYPE_VARCHAR')) {
|
||||
define('MYSQLI_TYPE_VARCHAR', 15);
|
||||
}
|
||||
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the improved MySQL extension (MySQLi)
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQLi
|
||||
*/
|
||||
class PMA_DBI_Mysqli implements PMA_DBI_Extension
|
||||
{
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param mysqli $link connection link
|
||||
* @param string $host mysql hostname
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param string $dbname database name
|
||||
* @param int $server_port server port
|
||||
* @param string $server_socket server socket
|
||||
* @param int $client_flags client flags of connection
|
||||
* @param bool $persistent whether to use peristent connection
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
private function _realConnect(
|
||||
$link, $host, $user, $password, $dbname, $server_port,
|
||||
$server_socket, $client_flags = null, $persistent = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
// mysqli persistent connections only on PHP 5.3+
|
||||
if (PMA_PHP_INT_VERSION >= 50300) {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$host = 'p:' . $host;
|
||||
}
|
||||
}
|
||||
if ($client_flags === null) {
|
||||
return @mysqli_real_connect(
|
||||
$link,
|
||||
$host,
|
||||
$user,
|
||||
$password,
|
||||
$dbname,
|
||||
$server_port,
|
||||
$server_socket
|
||||
);
|
||||
} else {
|
||||
return @mysqli_real_connect(
|
||||
$link,
|
||||
$host,
|
||||
$user,
|
||||
$password,
|
||||
$dbname,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
public function connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? false
|
||||
: (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: $server['socket'];
|
||||
$server['host'] = (empty($server['host']))
|
||||
? 'localhost'
|
||||
: $server['host'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? false
|
||||
: (int) $cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? null
|
||||
: $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
// NULL enables connection to the default socket
|
||||
|
||||
$link = mysqli_init();
|
||||
|
||||
mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true);
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if ($cfg['Server']['compress'] && defined('MYSQLI_CLIENT_COMPRESS')) {
|
||||
$client_flags |= MYSQLI_CLIENT_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if ($cfg['Server']['ssl'] && defined('MYSQLI_CLIENT_SSL')) {
|
||||
$client_flags |= MYSQLI_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$return_value = @$this->_realConnect(
|
||||
$link,
|
||||
$cfg['Server']['host'],
|
||||
$user,
|
||||
$password,
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($return_value == false
|
||||
&& isset($cfg['Server']['nopassword'])
|
||||
&& $cfg['Server']['nopassword']
|
||||
&& ! $is_controluser
|
||||
) {
|
||||
$return_value = @$this->_realConnect(
|
||||
$link,
|
||||
$cfg['Server']['host'],
|
||||
$user,
|
||||
'',
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$return_value = @$this->_realConnect(
|
||||
$link,
|
||||
$server['host'],
|
||||
$user,
|
||||
$password,
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket
|
||||
);
|
||||
}
|
||||
|
||||
if ($return_value == false) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__('Connection for controluser as defined in your configuration failed.'),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling $GLOBALS['dbi']->connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'mysql-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$GLOBALS['dbi']->postConnect($link, $is_controluser);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname database name to select
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
public function selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_select_db($link, $dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param mysqli $link mysqli object
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mysqli_result|bool
|
||||
*/
|
||||
public function realQuery($query, $link, $options)
|
||||
{
|
||||
if ($options == ($options | PMA_DatabaseInterface::QUERY_STORE)) {
|
||||
$method = MYSQLI_STORE_RESULT;
|
||||
} elseif ($options == ($options | PMA_DatabaseInterface::QUERY_UNBUFFERED)) {
|
||||
$method = MYSQLI_USE_RESULT;
|
||||
} else {
|
||||
$method = 0;
|
||||
}
|
||||
|
||||
return mysqli_query($link, $query, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param mysqli $link mysqli object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return mysqli_result collection | boolean(false)
|
||||
*/
|
||||
public function realMultiQuery($link, $query)
|
||||
{
|
||||
return mysqli_multi_query($link, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchArray($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchAssoc($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function fetchRow($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
public function dataSeek($result, $offset)
|
||||
{
|
||||
return mysqli_data_seek($result, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param mysqli_result $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function freeResult($result)
|
||||
{
|
||||
if ($result instanceof mysqli_result) {
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
public function moreResults($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_more_results($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
public function nextResult($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_next_result($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return mixed false when empty results / result set when not empty
|
||||
*/
|
||||
public function storeResult()
|
||||
{
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return mysqli_store_result($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
public function getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_get_host_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return integer version of the MySQL protocol used
|
||||
*/
|
||||
public function getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_get_proto_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
public function getClientInfo()
|
||||
{
|
||||
return mysqli_get_client_info();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
public function getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
// Do not stop now. We still can get the error code
|
||||
// with mysqli_connect_errno()
|
||||
}
|
||||
|
||||
if (null !== $link) {
|
||||
$error_number = mysqli_errno($link);
|
||||
$error_message = mysqli_error($link);
|
||||
} else {
|
||||
$error_number = mysqli_connect_errno();
|
||||
$error_message = mysqli_connect_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after
|
||||
// the call to getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return $GLOBALS['dbi']->formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function numRows($result)
|
||||
{
|
||||
// see the note for tryQuery();
|
||||
if (!is_bool($result)) {
|
||||
return @mysqli_num_rows($result);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link
|
||||
* or $GLOBALS['userlink']
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// When no controluser is defined, using mysqli_insert_id($link)
|
||||
// does not always return the last insert id due to a mixup with
|
||||
// the tracking mechanism, but this works:
|
||||
return $GLOBALS['dbi']->fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
// Curiously, this problem does not happen with the mysql extension but
|
||||
// there is another problem with BIGINT primary keys so insertId()
|
||||
// in the mysql extension also uses this logic.
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
public function affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return mysqli_affected_rows($link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
public function getFieldsMeta($result)
|
||||
{
|
||||
// Build an associative array for a type look up
|
||||
$typeAr = array();
|
||||
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_NEWDECIMAL] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_BIT] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_TINY] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_SHORT] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_LONG] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_FLOAT] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_DOUBLE] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_NULL] = 'null';
|
||||
$typeAr[MYSQLI_TYPE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[MYSQLI_TYPE_LONGLONG] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_INT24] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_DATE] = 'date';
|
||||
$typeAr[MYSQLI_TYPE_TIME] = 'time';
|
||||
$typeAr[MYSQLI_TYPE_DATETIME] = 'datetime';
|
||||
$typeAr[MYSQLI_TYPE_YEAR] = 'year';
|
||||
$typeAr[MYSQLI_TYPE_NEWDATE] = 'date';
|
||||
$typeAr[MYSQLI_TYPE_ENUM] = 'unknown';
|
||||
$typeAr[MYSQLI_TYPE_SET] = 'unknown';
|
||||
$typeAr[MYSQLI_TYPE_TINY_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_MEDIUM_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_LONG_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_VAR_STRING] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_STRING] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_VARCHAR] = 'string'; // for Drizzle
|
||||
// MySQL returns MYSQLI_TYPE_STRING for CHAR
|
||||
// and MYSQLI_TYPE_CHAR === MYSQLI_TYPE_TINY
|
||||
// so this would override TINYINT and mark all TINYINT as string
|
||||
// https://sourceforge.net/p/phpmyadmin/bugs/2205/
|
||||
//$typeAr[MYSQLI_TYPE_CHAR] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_GEOMETRY] = 'geometry';
|
||||
$typeAr[MYSQLI_TYPE_BIT] = 'bit';
|
||||
|
||||
$fields = mysqli_fetch_fields($result);
|
||||
|
||||
// this happens sometimes (seen under MySQL 4.0.25)
|
||||
if (!is_array($fields)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($fields as $k => $field) {
|
||||
$fields[$k]->_type = $field->type;
|
||||
$fields[$k]->type = $typeAr[$field->type];
|
||||
$fields[$k]->_flags = $field->flags;
|
||||
$fields[$k]->flags = $this->fieldFlags($result, $k);
|
||||
|
||||
// Enhance the field objects for mysql-extension compatibilty
|
||||
//$flags = explode(' ', $fields[$k]->flags);
|
||||
//array_unshift($flags, 'dummy');
|
||||
$fields[$k]->multiple_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_MULTIPLE_KEY_FLAG);
|
||||
$fields[$k]->primary_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_PRI_KEY_FLAG);
|
||||
$fields[$k]->unique_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_UNIQUE_KEY_FLAG);
|
||||
$fields[$k]->not_null
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_NOT_NULL_FLAG);
|
||||
$fields[$k]->unsigned
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_UNSIGNED_FLAG);
|
||||
$fields[$k]->zerofill
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_ZEROFILL_FLAG);
|
||||
$fields[$k]->numeric
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_NUM_FLAG);
|
||||
$fields[$k]->blob
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_BLOB_FLAG);
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
public function numFields($result)
|
||||
{
|
||||
return mysqli_num_fields($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
public function fieldLen($result, $i)
|
||||
{
|
||||
return mysqli_fetch_field_direct($result, $i)->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
public function fieldName($result, $i)
|
||||
{
|
||||
return mysqli_fetch_field_direct($result, $i)->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
public function fieldFlags($result, $i)
|
||||
{
|
||||
// This is missing from PHP 5.2.5, see http://bugs.php.net/bug.php?id=44846
|
||||
if (! defined('MYSQLI_ENUM_FLAG')) {
|
||||
define('MYSQLI_ENUM_FLAG', 256); // see MySQL source include/mysql_com.h
|
||||
}
|
||||
$f = mysqli_fetch_field_direct($result, $i);
|
||||
$type = $f->type;
|
||||
$charsetnr = $f->charsetnr;
|
||||
$f = $f->flags;
|
||||
$flags = '';
|
||||
if ($f & MYSQLI_UNIQUE_KEY_FLAG) {
|
||||
$flags .= 'unique ';
|
||||
}
|
||||
if ($f & MYSQLI_NUM_FLAG) {
|
||||
$flags .= 'num ';
|
||||
}
|
||||
if ($f & MYSQLI_PART_KEY_FLAG) {
|
||||
$flags .= 'part_key ';
|
||||
}
|
||||
if ($f & MYSQLI_SET_FLAG) {
|
||||
$flags .= 'set ';
|
||||
}
|
||||
if ($f & MYSQLI_TIMESTAMP_FLAG) {
|
||||
$flags .= 'timestamp ';
|
||||
}
|
||||
if ($f & MYSQLI_AUTO_INCREMENT_FLAG) {
|
||||
$flags .= 'auto_increment ';
|
||||
}
|
||||
if ($f & MYSQLI_ENUM_FLAG) {
|
||||
$flags .= 'enum ';
|
||||
}
|
||||
// See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
|
||||
// to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
|
||||
// but instead the charsetnr member of the MYSQL_FIELD
|
||||
// structure. Watch out: some types like DATE returns 63 in charsetnr
|
||||
// so we have to check also the type.
|
||||
// Unfortunately there is no equivalent in the mysql extension.
|
||||
if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB
|
||||
|| $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB
|
||||
|| $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING)
|
||||
&& 63 == $charsetnr
|
||||
) {
|
||||
$flags .= 'binary ';
|
||||
}
|
||||
if ($f & MYSQLI_ZEROFILL_FLAG) {
|
||||
$flags .= 'zerofill ';
|
||||
}
|
||||
if ($f & MYSQLI_UNSIGNED_FLAG) {
|
||||
$flags .= 'unsigned ';
|
||||
}
|
||||
if ($f & MYSQLI_BLOB_FLAG) {
|
||||
$flags .= 'blob ';
|
||||
}
|
||||
if ($f & MYSQLI_MULTIPLE_KEY_FLAG) {
|
||||
$flags .= 'multiple_key ';
|
||||
}
|
||||
if ($f & MYSQLI_UNIQUE_KEY_FLAG) {
|
||||
$flags .= 'unique_key ';
|
||||
}
|
||||
if ($f & MYSQLI_PRI_KEY_FLAG) {
|
||||
$flags .= 'primary_key ';
|
||||
}
|
||||
if ($f & MYSQLI_NOT_NULL_FLAG) {
|
||||
$flags .= 'not_null ';
|
||||
}
|
||||
return trim($flags);
|
||||
}
|
||||
}
|
||||
?>
|
||||
@ -1,667 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the Drizzle extension
|
||||
*
|
||||
* WARNING - EXPERIMENTAL, never use in production,
|
||||
* drizzle module segfaults often and when you least expect it to
|
||||
*
|
||||
* TODO: This file and drizzle-wrappers.lib.php should be devoid
|
||||
* of any segault related hacks.
|
||||
* TODO: Crashing versions of drizzle module and/or libdrizzle
|
||||
* should be blacklisted
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage Drizzle
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
require_once './libraries/dbi/drizzle-wrappers.lib.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (!defined('PMA_MYSQL_CLIENT_API')) {
|
||||
define('PMA_MYSQL_CLIENT_API', (int)drizzle_version());
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param PMA_Drizzle $drizzle connection handle
|
||||
* @param string $host Drizzle host
|
||||
* @param integer $port Drizzle port
|
||||
* @param string $uds server socket
|
||||
* @param string $user username
|
||||
* @param string $password password
|
||||
* @param string $db database name
|
||||
* @param integer $options connection options
|
||||
*
|
||||
* @return PMA_DrizzleCon
|
||||
*/
|
||||
function PMA_DBI_realConnect($drizzle, $host, $port, $uds, $user, $password,
|
||||
$db = null, $options = DRIZZLE_CON_NONE
|
||||
) {
|
||||
if ($uds) {
|
||||
$con = $drizzle->addUds($uds, $user, $password, $db, $options);
|
||||
} else {
|
||||
$con = $drizzle->addTcp($host, $port, $user, $password, $db, $options);
|
||||
}
|
||||
|
||||
return $con;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user drizzle user name
|
||||
* @param string $password drizzle user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect($user, $password, $is_controluser = false,
|
||||
$server = null, $auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? false
|
||||
: (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: $server['socket'];
|
||||
$server['host'] = (empty($server['host']))
|
||||
? 'localhost'
|
||||
: $server['host'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? false
|
||||
: (int) $cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? null
|
||||
: $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
if (strtolower($GLOBALS['cfg']['Server']['connect_type']) == 'tcp') {
|
||||
$GLOBALS['cfg']['Server']['socket'] = '';
|
||||
}
|
||||
|
||||
$drizzle = new PMA_Drizzle();
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if ($GLOBALS['cfg']['Server']['compress']) {
|
||||
$client_flags |= DRIZZLE_CAPABILITIES_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if ($GLOBALS['cfg']['Server']['ssl']) {
|
||||
$client_flags |= DRIZZLE_CAPABILITIES_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$link = @PMA_DBI_realConnect(
|
||||
$drizzle, $cfg['Server']['host'], $server_port, $server_socket, $user,
|
||||
$password, false, $client_flags
|
||||
);
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($link == false && isset($cfg['Server']['nopassword'])
|
||||
&& $cfg['Server']['nopassword'] && ! $is_controluser
|
||||
) {
|
||||
$link = @PMA_DBI_realConnect(
|
||||
$drizzle, $cfg['Server']['host'], $server_port, $server_socket,
|
||||
$user, null, false, $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$link = @PMA_DBI_realConnect(
|
||||
$drizzle, $server['host'], $server_port, $server_socket,
|
||||
$user, $password
|
||||
);
|
||||
}
|
||||
|
||||
if ($link == false) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling PMA_DBI_connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'drizzle-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
PMA_DBI_postConnect($link, $is_controluser);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname database name to select
|
||||
* @param PMA_DrizzleCom $link connection object
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_DBI_selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return $link->selectDb($dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return PMA_DrizzleResult
|
||||
*/
|
||||
function PMA_DBI_realQuery($query, $link, $options)
|
||||
{
|
||||
$buffer_mode = $options & PMA_DBI_QUERY_UNBUFFERED
|
||||
? PMA_Drizzle::BUFFER_ROW
|
||||
: PMA_Drizzle::BUFFER_RESULT;
|
||||
$res = $link->query($query, $buffer_mode);
|
||||
return $res;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchArray($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchAssoc($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchRow($result)
|
||||
{
|
||||
return $result->fetchRow(PMA_Drizzle::FETCH_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $offset offset to seek
|
||||
*
|
||||
* @return boolean true on success, false on failure
|
||||
*/
|
||||
function PMA_DBI_dataSeek($result, $offset)
|
||||
{
|
||||
return $result->seek($offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_DBI_freeResult($result)
|
||||
{
|
||||
if ($result instanceof PMA_DrizzleResult) {
|
||||
$result->free();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
function PMA_DBI_moreResults()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
function PMA_DBI_nextResult()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
function PMA_DBI_getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
$str = $link->port()
|
||||
? $link->host() . ':' . $link->port() . ' via TCP/IP'
|
||||
: 'Localhost via UNIX socket';
|
||||
return $str;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the Drizzle protocol used
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return int version of the Drizzle protocol used
|
||||
*/
|
||||
function PMA_DBI_getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return $link->protocolVersion();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string Drizzle client library version
|
||||
*/
|
||||
function PMA_DBI_getClientInfo()
|
||||
{
|
||||
return 'libdrizzle (Drizzle ' . drizzle_version() . ')';
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
function PMA_DBI_getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
// Do not stop now. We still can get the error code
|
||||
// with mysqli_connect_errno()
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link) {
|
||||
$error_number = drizzle_con_errno($link->getConnectionObject());
|
||||
$error_message = drizzle_con_error($link->getConnectionObject());
|
||||
} else {
|
||||
$error_number = drizzle_errno();
|
||||
$error_message = drizzle_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after the call to PMA_DBI_getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return PMA_DBI_formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_numRows($result)
|
||||
{
|
||||
// see the note for PMA_DBI_tryQuery();
|
||||
if (!is_bool($result)) {
|
||||
return @$result->numRows();
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link or $GLOBALS['userlink']
|
||||
*
|
||||
* @param PMA_DrizzleCon $link connection object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
// copied from mysql and mysqli
|
||||
|
||||
// When no controluser is defined, using mysqli_insert_id($link)
|
||||
// does not always return the last insert id due to a mixup with
|
||||
// the tracking mechanism, but this works:
|
||||
return PMA_DBI_fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
// Curiously, this problem does not happen with the mysql extension but
|
||||
// there is another problem with BIGINT primary keys so PMA_DBI_insertId()
|
||||
// in the mysql extension also uses this logic.
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param PMA_DrizzleResult $link connection object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return $link->affectedRows();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
function PMA_DBI_getFieldsMeta($result)
|
||||
{
|
||||
// Build an associative array for a type look up
|
||||
$typeAr = array();
|
||||
/*$typeAr[DRIZZLE_COLUMN_TYPE_DECIMAL] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDECIMAL] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_BIT] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TINY] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_SHORT] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_FLOAT] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DOUBLE] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NULL] = 'null';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONGLONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_INT24] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TIME] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DATETIME] = 'datetime';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_YEAR] = 'year';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_NEWDATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_ENUM] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_SET] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VIRTUAL] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_TINY_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_MEDIUM_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_LONG_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VAR_STRING] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_VARCHAR] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_STRING] = 'string';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_GEOMETRY] = 'geometry';*/
|
||||
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB] = 'blob';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATE] = 'date';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DATETIME] = 'datetime';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_DOUBLE] = 'real';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_ENUM] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_LONGLONG] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_MAX] = 'unknown';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_NULL] = 'null';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_TINY] = 'int';
|
||||
$typeAr[DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR] = 'string';
|
||||
|
||||
// array of DrizzleColumn
|
||||
$columns = $result->getColumns();
|
||||
// columns in a standarized format
|
||||
$std_columns = array();
|
||||
|
||||
foreach ($columns as $k => $column) {
|
||||
$c = new stdClass();
|
||||
$c->name = $column->name();
|
||||
$c->orgname = $column->origName();
|
||||
$c->table = $column->table();
|
||||
$c->orgtable = $column->origTable();
|
||||
$c->def = $column->defaultValue();
|
||||
$c->db = $column->db();
|
||||
$c->catalog = $column->catalog();
|
||||
// $column->maxSize() returns always 0 while size() seems
|
||||
// to return a correct value (drizzle extension v.0.5, API v.7)
|
||||
$c->max_length = $column->size();
|
||||
$c->decimals = $column->decimals();
|
||||
$c->charsetnr = $column->charset();
|
||||
$c->type = $typeAr[$column->typeDrizzle()];
|
||||
$c->_type = $column->type();
|
||||
$c->flags = PMA_DBI_fieldFlags($result, $k);
|
||||
$c->_flags = $column->flags();
|
||||
|
||||
$c->multiple_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY);
|
||||
$c->primary_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_PRI_KEY);
|
||||
$c->unique_key = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY);
|
||||
$c->not_null = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_NOT_NULL);
|
||||
$c->unsigned = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_UNSIGNED);
|
||||
$c->zerofill = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_ZEROFILL);
|
||||
$c->numeric = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_NUM);
|
||||
$c->blob = (int) (bool) ($c->_flags & DRIZZLE_COLUMN_FLAGS_BLOB);
|
||||
|
||||
$std_columns[] = $c;
|
||||
}
|
||||
|
||||
return $std_columns;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
function PMA_DBI_numFields($result)
|
||||
{
|
||||
return $result->numColumns();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
function PMA_DBI_fieldLen($result, $i)
|
||||
{
|
||||
$colums = $result->getColumns();
|
||||
return $colums[$i]->size();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
function PMA_DBI_fieldName($result, $i)
|
||||
{
|
||||
$colums = $result->getColumns();
|
||||
return $colums[$i]->name();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param PMA_DrizzleResult $result Drizzle result object
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
function PMA_DBI_fieldFlags($result, $i)
|
||||
{
|
||||
$columns = $result->getColumns();
|
||||
$f = $columns[$i];
|
||||
$type = $f->typeDrizzle();
|
||||
$charsetnr = $f->charset();
|
||||
$f = $f->flags();
|
||||
$flags = '';
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
|
||||
$flags .= 'unique ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_NUM) {
|
||||
$flags .= 'num ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_PART_KEY) {
|
||||
$flags .= 'part_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_SET) {
|
||||
$flags .= 'set ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_TIMESTAMP) {
|
||||
$flags .= 'timestamp ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_AUTO_INCREMENT) {
|
||||
$flags .= 'auto_increment ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_ENUM) {
|
||||
$flags .= 'enum ';
|
||||
}
|
||||
// See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
|
||||
// to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
|
||||
// but instead the charsetnr member of the MYSQL_FIELD
|
||||
// structure. Watch out: some types like DATE returns 63 in charsetnr
|
||||
// so we have to check also the type.
|
||||
// Unfortunately there is no equivalent in the mysql extension.
|
||||
if (($type == DRIZZLE_COLUMN_TYPE_DRIZZLE_BLOB
|
||||
|| $type == DRIZZLE_COLUMN_TYPE_DRIZZLE_VARCHAR)
|
||||
&& 63 == $charsetnr
|
||||
) {
|
||||
$flags .= 'binary ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_ZEROFILL) {
|
||||
$flags .= 'zerofill ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNSIGNED) {
|
||||
$flags .= 'unsigned ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_BLOB) {
|
||||
$flags .= 'blob ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_MULTIPLE_KEY) {
|
||||
$flags .= 'multiple_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_UNIQUE_KEY) {
|
||||
$flags .= 'unique_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_PRI_KEY) {
|
||||
$flags .= 'primary_key ';
|
||||
}
|
||||
if ($f & DRIZZLE_COLUMN_FLAGS_NOT_NULL) {
|
||||
$flags .= 'not_null ';
|
||||
}
|
||||
return trim($flags);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
function PMA_DBI_storeResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
?>
|
||||
@ -1,552 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the classic MySQL extension
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQL
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (! defined('PMA_MYSQL_CLIENT_API')) {
|
||||
$client_api = explode('.', mysql_get_client_info());
|
||||
define(
|
||||
'PMA_MYSQL_CLIENT_API',
|
||||
(int)sprintf(
|
||||
'%d%02d%02d',
|
||||
$client_api[0], $client_api[1], intval($client_api[2])
|
||||
)
|
||||
);
|
||||
unset($client_api);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param array $server host/port/socket
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param int $client_flags client flags of connection
|
||||
* @param bool $persistent whether to use peristent connection
|
||||
*
|
||||
* @return mixed false on error or a mysql connection resource on success
|
||||
*/
|
||||
function PMA_DBI_realConnect($server, $user, $password, $client_flags,
|
||||
$persistent = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if (empty($client_flags)) {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$link = @mysql_pconnect($server, $user, $password);
|
||||
} else {
|
||||
$link = @mysql_connect($server, $user, $password);
|
||||
}
|
||||
} else {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$link = @mysql_pconnect($server, $user, $password, $client_flags);
|
||||
} else {
|
||||
$link = @mysql_connect($server, $user, $password, false, $client_flags);
|
||||
}
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param mysqli $link mysqli object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return boolean false always false since mysql extention not support
|
||||
* for multi query executions
|
||||
*/
|
||||
function PMA_DBI_realMultiQuery($link, $query)
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? ''
|
||||
: ':' . (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: ':' . $server['socket'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? ''
|
||||
: ':' . (int)$cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? ''
|
||||
: ':' . $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
// always use CLIENT_LOCAL_FILES as defined in mysql_com.h
|
||||
// for the case where the client library was not compiled
|
||||
// with --enable-local-infile
|
||||
$client_flags |= 128;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if (defined('MYSQL_CLIENT_COMPRESS') && $cfg['Server']['compress']) {
|
||||
$client_flags |= MYSQL_CLIENT_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if (defined('MYSQL_CLIENT_SSL') && $cfg['Server']['ssl']) {
|
||||
$client_flags |= MYSQL_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$link = PMA_DBI_realConnect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, $password, empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
|
||||
// Retry with empty password if we're allowed to
|
||||
if (empty($link) && $cfg['Server']['nopassword'] && ! $is_controluser) {
|
||||
$link = PMA_DBI_realConnect(
|
||||
$cfg['Server']['host'] . $server_port . $server_socket,
|
||||
$user, '', empty($client_flags) ? null : $client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
if (!isset($server['host'])) {
|
||||
$link = PMA_DBI_realConnect($server_socket, $user, $password, null);
|
||||
} else {
|
||||
$link = PMA_DBI_realConnect(
|
||||
$server['host'] . $server_port . $server_socket,
|
||||
$user, $password, null
|
||||
);
|
||||
}
|
||||
}
|
||||
if (empty($link)) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__(
|
||||
'Connection for controluser as defined'
|
||||
. ' in your configuration failed.'
|
||||
),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling PMA_DBI_connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'mysql-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} // end if
|
||||
if (! $server) {
|
||||
PMA_DBI_postConnect($link, $is_controluser);
|
||||
}
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname name of db to select
|
||||
* @param resource $link mysql link resource
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_DBI_selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_select_db($dbname, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to run
|
||||
* @param resource $link mysql link resource
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
function PMA_DBI_realQuery($query, $link, $options)
|
||||
{
|
||||
if ($options == ($options | PMA_DBI_QUERY_STORE)) {
|
||||
return mysql_query($query, $link);
|
||||
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
|
||||
return mysql_unbuffered_query($query, $link);
|
||||
} else {
|
||||
return mysql_query($query, $link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param resource $result result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchArray($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchAssoc($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchRow($result)
|
||||
{
|
||||
return mysql_fetch_array($result, MYSQL_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
function PMA_DBI_dataSeek($result, $offset)
|
||||
{
|
||||
return mysql_data_seek($result, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_DBI_freeResult($result)
|
||||
{
|
||||
if (is_resource($result) && get_resource_type($result) === 'mysql result') {
|
||||
mysql_free_result($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @return bool false
|
||||
*/
|
||||
function PMA_DBI_moreResults()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @return boo false
|
||||
*/
|
||||
function PMA_DBI_nextResult()
|
||||
{
|
||||
// N.B.: PHP's 'mysql' extension does not support
|
||||
// multi_queries so this function will always
|
||||
// return false. Use the 'mysqli' extension, if
|
||||
// you need support for multi_queries.
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
function PMA_DBI_getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_get_host_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return int version of the MySQL protocol used
|
||||
*/
|
||||
function PMA_DBI_getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysql_get_proto_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
function PMA_DBI_getClientInfo()
|
||||
{
|
||||
return mysql_get_client_info();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
function PMA_DBI_getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
|
||||
// Do not stop now. On the initial connection, we don't have a $link,
|
||||
// we don't have a $GLOBALS['userlink'], but we can catch the error code
|
||||
// } else {
|
||||
// return false;
|
||||
}
|
||||
|
||||
if (null !== $link && false !== $link) {
|
||||
$error_number = mysql_errno($link);
|
||||
$error_message = mysql_error($link);
|
||||
} else {
|
||||
$error_number = mysql_errno();
|
||||
$error_message = mysql_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after the call to PMA_DBI_getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return PMA_DBI_formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_numRows($result)
|
||||
{
|
||||
if (!is_bool($result)) {
|
||||
return mysql_num_rows($result);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link or $GLOBALS['userlink']
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// If the primary key is BIGINT we get an incorrect result
|
||||
// (sometimes negative, sometimes positive)
|
||||
// and in the present function we don't know if the PK is BIGINT
|
||||
// so better play safe and use LAST_INSERT_ID()
|
||||
//
|
||||
return PMA_DBI_fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param resource $link the mysql object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return mysql_affected_rows($link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*
|
||||
* @todo add missing keys like in mysqli_query (decimals)
|
||||
*/
|
||||
function PMA_DBI_getFieldsMeta($result)
|
||||
{
|
||||
$fields = array();
|
||||
$num_fields = mysql_num_fields($result);
|
||||
for ($i = 0; $i < $num_fields; $i++) {
|
||||
$field = mysql_fetch_field($result, $i);
|
||||
$field->flags = mysql_field_flags($result, $i);
|
||||
$field->orgtable = mysql_field_table($result, $i);
|
||||
$field->orgname = mysql_field_name($result, $i);
|
||||
$fields[] = $field;
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
function PMA_DBI_numFields($result)
|
||||
{
|
||||
return mysql_num_fields($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
function PMA_DBI_fieldLen($result, $i)
|
||||
{
|
||||
return mysql_field_len($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
function PMA_DBI_fieldName($result, $i)
|
||||
{
|
||||
return mysql_field_name($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param resource $result MySQL result
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
function PMA_DBI_fieldFlags($result, $i)
|
||||
{
|
||||
return mysql_field_flags($result, $i);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return false
|
||||
*/
|
||||
function PMA_DBI_storeResult()
|
||||
{
|
||||
return false;
|
||||
}
|
||||
?>
|
||||
@ -1,748 +0,0 @@
|
||||
<?php
|
||||
/* vim: set expandtab sw=4 ts=4 sts=4: */
|
||||
/**
|
||||
* Interface to the improved MySQL extension (MySQLi)
|
||||
*
|
||||
* @package PhpMyAdmin-DBI
|
||||
* @subpackage MySQLi
|
||||
*/
|
||||
if (! defined('PHPMYADMIN')) {
|
||||
exit;
|
||||
}
|
||||
|
||||
require_once './libraries/logging.lib.php';
|
||||
|
||||
/**
|
||||
* MySQL client API
|
||||
*/
|
||||
if (!defined('PMA_MYSQL_CLIENT_API')) {
|
||||
$client_api = explode('.', mysqli_get_client_info());
|
||||
define(
|
||||
'PMA_MYSQL_CLIENT_API',
|
||||
(int)sprintf(
|
||||
'%d%02d%02d',
|
||||
$client_api[0], $client_api[1], intval($client_api[2])
|
||||
)
|
||||
);
|
||||
unset($client_api);
|
||||
}
|
||||
|
||||
/**
|
||||
* some PHP versions are reporting extra messages like "No index used in query"
|
||||
*/
|
||||
|
||||
mysqli_report(MYSQLI_REPORT_OFF);
|
||||
|
||||
/**
|
||||
* some older mysql client libs are missing these constants ...
|
||||
*/
|
||||
if (! defined('MYSQLI_BINARY_FLAG')) {
|
||||
define('MYSQLI_BINARY_FLAG', 128);
|
||||
}
|
||||
|
||||
/**
|
||||
* @see http://bugs.php.net/36007
|
||||
*/
|
||||
if (! defined('MYSQLI_TYPE_NEWDECIMAL')) {
|
||||
define('MYSQLI_TYPE_NEWDECIMAL', 246);
|
||||
}
|
||||
if (! defined('MYSQLI_TYPE_BIT')) {
|
||||
define('MYSQLI_TYPE_BIT', 16);
|
||||
}
|
||||
|
||||
// for Drizzle
|
||||
if (! defined('MYSQLI_TYPE_VARCHAR')) {
|
||||
define('MYSQLI_TYPE_VARCHAR', 15);
|
||||
}
|
||||
|
||||
/**
|
||||
* Helper function for connecting to the database server
|
||||
*
|
||||
* @param mysqli $link connection link
|
||||
* @param string $host mysql hostname
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param string $dbname database name
|
||||
* @param int $server_port server port
|
||||
* @param string $server_socket server socket
|
||||
* @param int $client_flags client flags of connection
|
||||
* @param bool $persistent whether to use peristent connection
|
||||
*
|
||||
* @return bool
|
||||
*/
|
||||
function PMA_DBI_realConnect(
|
||||
$link, $host, $user, $password, $dbname, $server_port,
|
||||
$server_socket, $client_flags = null, $persistent = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
// mysqli persistent connections only on PHP 5.3+
|
||||
if (PMA_PHP_INT_VERSION >= 50300) {
|
||||
if ($cfg['PersistentConnections'] || $persistent) {
|
||||
$host = 'p:' . $host;
|
||||
}
|
||||
}
|
||||
if ($client_flags === null) {
|
||||
return @mysqli_real_connect(
|
||||
$link,
|
||||
$host,
|
||||
$user,
|
||||
$password,
|
||||
$dbname,
|
||||
$server_port,
|
||||
$server_socket
|
||||
);
|
||||
} else {
|
||||
return @mysqli_real_connect(
|
||||
$link,
|
||||
$host,
|
||||
$user,
|
||||
$password,
|
||||
$dbname,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* connects to the database server
|
||||
*
|
||||
* @param string $user mysql user name
|
||||
* @param string $password mysql user password
|
||||
* @param bool $is_controluser whether this is a control user connection
|
||||
* @param array $server host/port/socket/persistent
|
||||
* @param bool $auxiliary_connection (when true, don't go back to login if
|
||||
* connection fails)
|
||||
*
|
||||
* @return mixed false on error or a mysqli object on success
|
||||
*/
|
||||
function PMA_DBI_connect(
|
||||
$user, $password, $is_controluser = false, $server = null,
|
||||
$auxiliary_connection = false
|
||||
) {
|
||||
global $cfg;
|
||||
|
||||
if ($server) {
|
||||
$server_port = (empty($server['port']))
|
||||
? false
|
||||
: (int)$server['port'];
|
||||
$server_socket = (empty($server['socket']))
|
||||
? ''
|
||||
: $server['socket'];
|
||||
$server['host'] = (empty($server['host']))
|
||||
? 'localhost'
|
||||
: $server['host'];
|
||||
} else {
|
||||
$server_port = (empty($cfg['Server']['port']))
|
||||
? false
|
||||
: (int) $cfg['Server']['port'];
|
||||
$server_socket = (empty($cfg['Server']['socket']))
|
||||
? null
|
||||
: $cfg['Server']['socket'];
|
||||
}
|
||||
|
||||
// NULL enables connection to the default socket
|
||||
|
||||
$link = mysqli_init();
|
||||
|
||||
mysqli_options($link, MYSQLI_OPT_LOCAL_INFILE, true);
|
||||
|
||||
$client_flags = 0;
|
||||
|
||||
/* Optionally compress connection */
|
||||
if ($cfg['Server']['compress'] && defined('MYSQLI_CLIENT_COMPRESS')) {
|
||||
$client_flags |= MYSQLI_CLIENT_COMPRESS;
|
||||
}
|
||||
|
||||
/* Optionally enable SSL */
|
||||
if ($cfg['Server']['ssl'] && defined('MYSQLI_CLIENT_SSL')) {
|
||||
$client_flags |= MYSQLI_CLIENT_SSL;
|
||||
}
|
||||
|
||||
if (! $server) {
|
||||
$return_value = @PMA_DBI_realConnect(
|
||||
$link,
|
||||
$cfg['Server']['host'],
|
||||
$user,
|
||||
$password,
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
// Retry with empty password if we're allowed to
|
||||
if ($return_value == false
|
||||
&& isset($cfg['Server']['nopassword']) && $cfg['Server']['nopassword']
|
||||
&& ! $is_controluser
|
||||
) {
|
||||
$return_value = @PMA_DBI_realConnect(
|
||||
$link,
|
||||
$cfg['Server']['host'],
|
||||
$user,
|
||||
'',
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket,
|
||||
$client_flags
|
||||
);
|
||||
}
|
||||
} else {
|
||||
$return_value = @PMA_DBI_realConnect(
|
||||
$link,
|
||||
$server['host'],
|
||||
$user,
|
||||
$password,
|
||||
false,
|
||||
$server_port,
|
||||
$server_socket
|
||||
);
|
||||
}
|
||||
|
||||
if ($return_value == false) {
|
||||
if ($is_controluser) {
|
||||
trigger_error(
|
||||
__('Connection for controluser as defined in your configuration failed.'),
|
||||
E_USER_WARNING
|
||||
);
|
||||
return false;
|
||||
}
|
||||
// we could be calling PMA_DBI_connect() to connect to another
|
||||
// server, for example in the Synchronize feature, so do not
|
||||
// go back to main login if it fails
|
||||
if (! $auxiliary_connection) {
|
||||
PMA_logUser($user, 'mysql-denied');
|
||||
global $auth_plugin;
|
||||
$auth_plugin->authFails();
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
PMA_DBI_postConnect($link, $is_controluser);
|
||||
}
|
||||
|
||||
return $link;
|
||||
}
|
||||
|
||||
/**
|
||||
* selects given database
|
||||
*
|
||||
* @param string $dbname database name to select
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return boolean
|
||||
*/
|
||||
function PMA_DBI_selectDb($dbname, $link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_select_db($link, $dbname);
|
||||
}
|
||||
|
||||
/**
|
||||
* runs a query and returns the result
|
||||
*
|
||||
* @param string $query query to execute
|
||||
* @param mysqli $link mysqli object
|
||||
* @param int $options query options
|
||||
*
|
||||
* @return mysqli_result|bool
|
||||
*/
|
||||
function PMA_DBI_realQuery($query, $link, $options)
|
||||
{
|
||||
if ($options == ($options | PMA_DBI_QUERY_STORE)) {
|
||||
$method = MYSQLI_STORE_RESULT;
|
||||
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
|
||||
$method = MYSQLI_USE_RESULT;
|
||||
} else {
|
||||
$method = 0;
|
||||
}
|
||||
|
||||
return mysqli_query($link, $query, $method);
|
||||
}
|
||||
|
||||
/**
|
||||
* Run the multi query and output the results
|
||||
*
|
||||
* @param mysqli $link mysqli object
|
||||
* @param string $query multi query statement to execute
|
||||
*
|
||||
* @return mysqli_result collection | boolean(false)
|
||||
*/
|
||||
function PMA_DBI_realMultiQuery($link, $query)
|
||||
{
|
||||
return mysqli_multi_query($link, $query);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative and numeric keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchArray($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_BOTH);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with associative keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchAssoc($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_ASSOC);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns array of rows with numeric keys from $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
function PMA_DBI_fetchRow($result)
|
||||
{
|
||||
return mysqli_fetch_array($result, MYSQLI_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
* Adjusts the result pointer to an arbitrary row in the result
|
||||
*
|
||||
* @param resource $result database result
|
||||
* @param integer $offset offset to seek
|
||||
*
|
||||
* @return bool true on success, false on failure
|
||||
*/
|
||||
function PMA_DBI_dataSeek($result, $offset)
|
||||
{
|
||||
return mysqli_data_seek($result, $offset);
|
||||
}
|
||||
|
||||
/**
|
||||
* Frees memory associated with the result
|
||||
*
|
||||
* @param mysqli_result $result database result
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
function PMA_DBI_freeResult($result)
|
||||
{
|
||||
if ($result instanceof mysqli_result) {
|
||||
mysqli_free_result($result);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if there are any more query results from a multi query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
function PMA_DBI_moreResults($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_more_results($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Prepare next result from multi_query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return bool true or false
|
||||
*/
|
||||
function PMA_DBI_nextResult($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_next_result($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Store the result returned from multi query
|
||||
*
|
||||
* @return mixed false when empty results / result set when not empty
|
||||
*/
|
||||
function PMA_DBI_storeResult()
|
||||
{
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
return mysqli_store_result($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns a string representing the type of connection used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string type of connection used
|
||||
*/
|
||||
function PMA_DBI_getHostInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_get_host_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the version of the MySQL protocol used
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return integer version of the MySQL protocol used
|
||||
*/
|
||||
function PMA_DBI_getProtoInfo($link = null)
|
||||
{
|
||||
if (null === $link) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return mysqli_get_proto_info($link);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns a string that represents the client library version
|
||||
*
|
||||
* @return string MySQL client library version
|
||||
*/
|
||||
function PMA_DBI_getClientInfo()
|
||||
{
|
||||
return mysqli_get_client_info();
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last error message or false if no errors occured
|
||||
*
|
||||
* @param resource $link mysql link
|
||||
*
|
||||
* @return string|bool $error or false
|
||||
*/
|
||||
function PMA_DBI_getError($link = null)
|
||||
{
|
||||
$GLOBALS['errno'] = 0;
|
||||
|
||||
/* Treat false same as null because of controllink */
|
||||
if ($link === false) {
|
||||
$link = null;
|
||||
}
|
||||
|
||||
if (null === $link && isset($GLOBALS['userlink'])) {
|
||||
$link =& $GLOBALS['userlink'];
|
||||
// Do not stop now. We still can get the error code
|
||||
// with mysqli_connect_errno()
|
||||
}
|
||||
|
||||
if (null !== $link) {
|
||||
$error_number = mysqli_errno($link);
|
||||
$error_message = mysqli_error($link);
|
||||
} else {
|
||||
$error_number = mysqli_connect_errno();
|
||||
$error_message = mysqli_connect_error();
|
||||
}
|
||||
if (0 == $error_number) {
|
||||
return false;
|
||||
}
|
||||
|
||||
// keep the error number for further check after the call to PMA_DBI_getError()
|
||||
$GLOBALS['errno'] = $error_number;
|
||||
|
||||
return PMA_DBI_formatError($error_number, $error_message);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows returned by last query
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_numRows($result)
|
||||
{
|
||||
// see the note for PMA_DBI_tryQuery();
|
||||
if (!is_bool($result)) {
|
||||
return @mysqli_num_rows($result);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns last inserted auto_increment id for given $link or $GLOBALS['userlink']
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_insertId($link = null)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
// When no controluser is defined, using mysqli_insert_id($link)
|
||||
// does not always return the last insert id due to a mixup with
|
||||
// the tracking mechanism, but this works:
|
||||
return PMA_DBI_fetchValue('SELECT LAST_INSERT_ID();', 0, 0, $link);
|
||||
// Curiously, this problem does not happen with the mysql extension but
|
||||
// there is another problem with BIGINT primary keys so PMA_DBI_insertId()
|
||||
// in the mysql extension also uses this logic.
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the number of rows affected by last query
|
||||
*
|
||||
* @param mysqli $link the mysqli object
|
||||
* @param bool $get_from_cache whether to retrieve from cache
|
||||
*
|
||||
* @return string|int
|
||||
*/
|
||||
function PMA_DBI_affectedRows($link = null, $get_from_cache = true)
|
||||
{
|
||||
if (empty($link)) {
|
||||
if (isset($GLOBALS['userlink'])) {
|
||||
$link = $GLOBALS['userlink'];
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if ($get_from_cache) {
|
||||
return $GLOBALS['cached_affected_rows'];
|
||||
} else {
|
||||
return mysqli_affected_rows($link);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* returns metainfo for fields in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return array meta info for fields in $result
|
||||
*/
|
||||
function PMA_DBI_getFieldsMeta($result)
|
||||
{
|
||||
// Build an associative array for a type look up
|
||||
$typeAr = array();
|
||||
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_NEWDECIMAL] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_BIT] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_TINY] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_SHORT] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_LONG] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_FLOAT] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_DOUBLE] = 'real';
|
||||
$typeAr[MYSQLI_TYPE_NULL] = 'null';
|
||||
$typeAr[MYSQLI_TYPE_TIMESTAMP] = 'timestamp';
|
||||
$typeAr[MYSQLI_TYPE_LONGLONG] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_INT24] = 'int';
|
||||
$typeAr[MYSQLI_TYPE_DATE] = 'date';
|
||||
$typeAr[MYSQLI_TYPE_TIME] = 'time';
|
||||
$typeAr[MYSQLI_TYPE_DATETIME] = 'datetime';
|
||||
$typeAr[MYSQLI_TYPE_YEAR] = 'year';
|
||||
$typeAr[MYSQLI_TYPE_NEWDATE] = 'date';
|
||||
$typeAr[MYSQLI_TYPE_ENUM] = 'unknown';
|
||||
$typeAr[MYSQLI_TYPE_SET] = 'unknown';
|
||||
$typeAr[MYSQLI_TYPE_TINY_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_MEDIUM_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_LONG_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_BLOB] = 'blob';
|
||||
$typeAr[MYSQLI_TYPE_VAR_STRING] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_STRING] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_VARCHAR] = 'string'; // for Drizzle
|
||||
// MySQL returns MYSQLI_TYPE_STRING for CHAR
|
||||
// and MYSQLI_TYPE_CHAR === MYSQLI_TYPE_TINY
|
||||
// so this would override TINYINT and mark all TINYINT as string
|
||||
// https://sourceforge.net/p/phpmyadmin/bugs/2205/
|
||||
//$typeAr[MYSQLI_TYPE_CHAR] = 'string';
|
||||
$typeAr[MYSQLI_TYPE_GEOMETRY] = 'geometry';
|
||||
$typeAr[MYSQLI_TYPE_BIT] = 'bit';
|
||||
|
||||
$fields = mysqli_fetch_fields($result);
|
||||
|
||||
// this happens sometimes (seen under MySQL 4.0.25)
|
||||
if (!is_array($fields)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
foreach ($fields as $k => $field) {
|
||||
$fields[$k]->_type = $field->type;
|
||||
$fields[$k]->type = $typeAr[$field->type];
|
||||
$fields[$k]->_flags = $field->flags;
|
||||
$fields[$k]->flags = PMA_DBI_fieldFlags($result, $k);
|
||||
|
||||
// Enhance the field objects for mysql-extension compatibilty
|
||||
//$flags = explode(' ', $fields[$k]->flags);
|
||||
//array_unshift($flags, 'dummy');
|
||||
$fields[$k]->multiple_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_MULTIPLE_KEY_FLAG);
|
||||
$fields[$k]->primary_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_PRI_KEY_FLAG);
|
||||
$fields[$k]->unique_key
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_UNIQUE_KEY_FLAG);
|
||||
$fields[$k]->not_null
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_NOT_NULL_FLAG);
|
||||
$fields[$k]->unsigned
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_UNSIGNED_FLAG);
|
||||
$fields[$k]->zerofill
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_ZEROFILL_FLAG);
|
||||
$fields[$k]->numeric
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_NUM_FLAG);
|
||||
$fields[$k]->blob
|
||||
= (int) (bool) ($fields[$k]->_flags & MYSQLI_BLOB_FLAG);
|
||||
}
|
||||
return $fields;
|
||||
}
|
||||
|
||||
/**
|
||||
* return number of fields in given $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
*
|
||||
* @return int field count
|
||||
*/
|
||||
function PMA_DBI_numFields($result)
|
||||
{
|
||||
return mysqli_num_fields($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* returns the length of the given field $i in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return int length of field
|
||||
*/
|
||||
function PMA_DBI_fieldLen($result, $i)
|
||||
{
|
||||
return mysqli_fetch_field_direct($result, $i)->length;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns name of $i. field in $result
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string name of $i. field in $result
|
||||
*/
|
||||
function PMA_DBI_fieldName($result, $i)
|
||||
{
|
||||
return mysqli_fetch_field_direct($result, $i)->name;
|
||||
}
|
||||
|
||||
/**
|
||||
* returns concatenated string of human readable field flags
|
||||
*
|
||||
* @param mysqli_result $result result set identifier
|
||||
* @param int $i field
|
||||
*
|
||||
* @return string field flags
|
||||
*/
|
||||
function PMA_DBI_fieldFlags($result, $i)
|
||||
{
|
||||
// This is missing from PHP 5.2.5, see http://bugs.php.net/bug.php?id=44846
|
||||
if (! defined('MYSQLI_ENUM_FLAG')) {
|
||||
define('MYSQLI_ENUM_FLAG', 256); // see MySQL source include/mysql_com.h
|
||||
}
|
||||
$f = mysqli_fetch_field_direct($result, $i);
|
||||
$type = $f->type;
|
||||
$charsetnr = $f->charsetnr;
|
||||
$f = $f->flags;
|
||||
$flags = '';
|
||||
if ($f & MYSQLI_UNIQUE_KEY_FLAG) {
|
||||
$flags .= 'unique ';
|
||||
}
|
||||
if ($f & MYSQLI_NUM_FLAG) {
|
||||
$flags .= 'num ';
|
||||
}
|
||||
if ($f & MYSQLI_PART_KEY_FLAG) {
|
||||
$flags .= 'part_key ';
|
||||
}
|
||||
if ($f & MYSQLI_SET_FLAG) {
|
||||
$flags .= 'set ';
|
||||
}
|
||||
if ($f & MYSQLI_TIMESTAMP_FLAG) {
|
||||
$flags .= 'timestamp ';
|
||||
}
|
||||
if ($f & MYSQLI_AUTO_INCREMENT_FLAG) {
|
||||
$flags .= 'auto_increment ';
|
||||
}
|
||||
if ($f & MYSQLI_ENUM_FLAG) {
|
||||
$flags .= 'enum ';
|
||||
}
|
||||
// See http://dev.mysql.com/doc/refman/6.0/en/c-api-datatypes.html:
|
||||
// to determine if a string is binary, we should not use MYSQLI_BINARY_FLAG
|
||||
// but instead the charsetnr member of the MYSQL_FIELD
|
||||
// structure. Watch out: some types like DATE returns 63 in charsetnr
|
||||
// so we have to check also the type.
|
||||
// Unfortunately there is no equivalent in the mysql extension.
|
||||
if (($type == MYSQLI_TYPE_TINY_BLOB || $type == MYSQLI_TYPE_BLOB
|
||||
|| $type == MYSQLI_TYPE_MEDIUM_BLOB || $type == MYSQLI_TYPE_LONG_BLOB
|
||||
|| $type == MYSQLI_TYPE_VAR_STRING || $type == MYSQLI_TYPE_STRING)
|
||||
&& 63 == $charsetnr
|
||||
) {
|
||||
$flags .= 'binary ';
|
||||
}
|
||||
if ($f & MYSQLI_ZEROFILL_FLAG) {
|
||||
$flags .= 'zerofill ';
|
||||
}
|
||||
if ($f & MYSQLI_UNSIGNED_FLAG) {
|
||||
$flags .= 'unsigned ';
|
||||
}
|
||||
if ($f & MYSQLI_BLOB_FLAG) {
|
||||
$flags .= 'blob ';
|
||||
}
|
||||
if ($f & MYSQLI_MULTIPLE_KEY_FLAG) {
|
||||
$flags .= 'multiple_key ';
|
||||
}
|
||||
if ($f & MYSQLI_UNIQUE_KEY_FLAG) {
|
||||
$flags .= 'unique_key ';
|
||||
}
|
||||
if ($f & MYSQLI_PRI_KEY_FLAG) {
|
||||
$flags .= 'primary_key ';
|
||||
}
|
||||
if ($f & MYSQLI_NOT_NULL_FLAG) {
|
||||
$flags .= 'not_null ';
|
||||
}
|
||||
return trim($flags);
|
||||
}
|
||||
|
||||
?>
|
||||
@ -159,7 +159,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
SHOW STATUS
|
||||
WHERE Variable_name LIKE \'Innodb\\_buffer\\_pool\\_%\'
|
||||
OR Variable_name = \'Innodb_page_size\';';
|
||||
$status = PMA_DBI_fetchResult($sql, 0, 1);
|
||||
$status = $GLOBALS['dbi']->fetchResult($sql, 0, 1);
|
||||
|
||||
$output = '<table class="data" id="table_innodb_bufferpool_usage">' . "\n"
|
||||
. ' <caption class="tblHeaders">' . "\n"
|
||||
@ -322,7 +322,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
{
|
||||
return '<pre id="pre_innodb_status">' . "\n"
|
||||
. htmlspecialchars(
|
||||
PMA_DBI_fetchValue('SHOW INNODB STATUS;', 0, 'Status')
|
||||
$GLOBALS['dbi']->fetchValue('SHOW INNODB STATUS;', 0, 'Status')
|
||||
) . "\n"
|
||||
. '</pre>' . "\n";
|
||||
}
|
||||
@ -366,7 +366,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
*/
|
||||
function getInnodbPluginVersion()
|
||||
{
|
||||
return PMA_DBI_fetchValue('SELECT @@innodb_version;');
|
||||
return $GLOBALS['dbi']->fetchValue('SELECT @@innodb_version;');
|
||||
}
|
||||
|
||||
/**
|
||||
@ -380,7 +380,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
*/
|
||||
function getInnodbFileFormat()
|
||||
{
|
||||
return PMA_DBI_fetchValue(
|
||||
return $GLOBALS['dbi']->fetchValue(
|
||||
"SHOW GLOBAL VARIABLES LIKE 'innodb_file_format';", 0, 1
|
||||
);
|
||||
}
|
||||
@ -396,7 +396,7 @@ class PMA_StorageEngine_innodb extends PMA_StorageEngine
|
||||
*/
|
||||
function supportsFilePerTable()
|
||||
{
|
||||
$innodb_file_per_table = PMA_DBI_fetchValue(
|
||||
$innodb_file_per_table = $GLOBALS['dbi']->fetchValue(
|
||||
"SHOW GLOBAL VARIABLES LIKE 'innodb_file_per_table';", 0, 1
|
||||
);
|
||||
if ($innodb_file_per_table == 'ON') {
|
||||
|
||||
@ -155,7 +155,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
|
||||
$import_run_buffer['sql']
|
||||
);
|
||||
} else {
|
||||
$result = PMA_DBI_tryQuery($import_run_buffer['sql']);
|
||||
$result = $GLOBALS['dbi']->tryQuery($import_run_buffer['sql']);
|
||||
}
|
||||
|
||||
$msg = '# ';
|
||||
@ -165,7 +165,7 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
|
||||
}
|
||||
$my_die[] = array(
|
||||
'sql' => $import_run_buffer['full'],
|
||||
'error' => PMA_DBI_getError()
|
||||
'error' => $GLOBALS['dbi']->getError()
|
||||
);
|
||||
|
||||
$msg .= __('Error');
|
||||
@ -175,8 +175,8 @@ function PMA_importRunQuery($sql = '', $full = '', $controluser = false,
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
$a_num_rows = (int)@PMA_DBI_numRows($result);
|
||||
$a_aff_rows = (int)@PMA_DBI_affectedRows();
|
||||
$a_num_rows = (int)@$GLOBALS['dbi']->numRows($result);
|
||||
$a_aff_rows = (int)@$GLOBALS['dbi']->affectedRows();
|
||||
if ($a_num_rows > 0) {
|
||||
$msg .= __('Rows'). ': ' . $a_num_rows;
|
||||
$last_query_with_results = $import_run_buffer['sql'];
|
||||
|
||||
@ -82,8 +82,10 @@ function PMA_analyzeWhereClauses(
|
||||
. PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table)
|
||||
. ' WHERE ' . $where_clause . ';';
|
||||
$result[$key_id] = PMA_DBI_query($local_query, null, PMA_DBI_QUERY_STORE);
|
||||
$rows[$key_id] = PMA_DBI_fetchAssoc($result[$key_id]);
|
||||
$result[$key_id] = $GLOBALS['dbi']->query(
|
||||
$local_query, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$rows[$key_id] = $GLOBALS['dbi']->fetchAssoc($result[$key_id]);
|
||||
|
||||
$where_clauses[$key_id] = str_replace('\\', '\\\\', $where_clause);
|
||||
$has_unique_condition = PMA_showEmptyResultMessageOrSetUniqueCondition(
|
||||
@ -126,7 +128,7 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id,
|
||||
* exit if we want the message to be displayed
|
||||
*/
|
||||
} else {// end if (no row returned)
|
||||
$meta = PMA_DBI_getFieldsMeta($result[$key_id]);
|
||||
$meta = $GLOBALS['dbi']->getFieldsMeta($result[$key_id]);
|
||||
|
||||
list($unique_condition, $tmp_clause_is_unique)
|
||||
= PMA_Util::getUniqueCondition(
|
||||
@ -151,11 +153,11 @@ function PMA_showEmptyResultMessageOrSetUniqueCondition($rows, $key_id,
|
||||
*/
|
||||
function PMA_loadFirstRow($table, $db)
|
||||
{
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SELECT * FROM ' . PMA_Util::backquote($db)
|
||||
. '.' . PMA_Util::backquote($table) . ' LIMIT 1;',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$rows = array_fill(0, $GLOBALS['cfg']['InsertRows'], false);
|
||||
return array($result, $rows);
|
||||
@ -1786,9 +1788,9 @@ function PMA_setSessionForEditNext($one_where_clause)
|
||||
. '.' . PMA_Util::backquote($GLOBALS['table']) . ' WHERE '
|
||||
. str_replace('` =', '` >', $one_where_clause) . ' LIMIT 1;';
|
||||
|
||||
$res = PMA_DBI_query($local_query);
|
||||
$row = PMA_DBI_fetchRow($res);
|
||||
$meta = PMA_DBI_getFieldsMeta($res);
|
||||
$res = $GLOBALS['dbi']->query($local_query);
|
||||
$row = $GLOBALS['dbi']->fetchRow($res);
|
||||
$meta = $GLOBALS['dbi']->getFieldsMeta($res);
|
||||
// must find a unique condition based on unique key,
|
||||
// not a combination of all fields
|
||||
list($unique_condition, $clause_is_unique)
|
||||
@ -1913,20 +1915,20 @@ function PMA_executeSqlQuery($url_params, $query)
|
||||
continue;
|
||||
}
|
||||
if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) {
|
||||
$result = PMA_DBI_tryQuery($single_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($single_query);
|
||||
} else {
|
||||
$result = PMA_DBI_query($single_query);
|
||||
$result = $GLOBALS['dbi']->query($single_query);
|
||||
}
|
||||
if (! $result) {
|
||||
$error_messages[] = PMA_Message::sanitize(PMA_DBI_getError());
|
||||
$error_messages[] = PMA_Message::sanitize($GLOBALS['dbi']->getError());
|
||||
} else {
|
||||
// The next line contains a real assignment, it's not a typo
|
||||
if ($tmp = @PMA_DBI_affectedRows()) {
|
||||
if ($tmp = @$GLOBALS['dbi']->affectedRows()) {
|
||||
$total_affected_rows += $tmp;
|
||||
}
|
||||
unset($tmp);
|
||||
|
||||
$insert_id = PMA_DBI_insertId();
|
||||
$insert_id = $GLOBALS['dbi']->insertId();
|
||||
if ($insert_id != 0) {
|
||||
// insert_id is id of FIRST record inserted in one insert, so if we
|
||||
// inserted multiple rows, we had to increment this
|
||||
@ -1938,7 +1940,7 @@ function PMA_executeSqlQuery($url_params, $query)
|
||||
$last_message->addParam($insert_id);
|
||||
$last_messages[] = $last_message;
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
$warning_messages = PMA_getWarningMessages();
|
||||
}
|
||||
@ -1960,7 +1962,7 @@ function PMA_executeSqlQuery($url_params, $query)
|
||||
function PMA_getWarningMessages()
|
||||
{
|
||||
$warning_essages = array();
|
||||
foreach (PMA_DBI_getWarnings() as $warning) {
|
||||
foreach ($GLOBALS['dbi']->getWarnings() as $warning) {
|
||||
$warning_essages[] = PMA_Message::sanitize(
|
||||
$warning['Level'] . ': #' . $warning['Code'] . ' ' . $warning['Message']
|
||||
);
|
||||
@ -1993,11 +1995,13 @@ function PMA_getDisplayValueForForeignTableColumn($where_comparison,
|
||||
. '.' . PMA_Util::backquote($map[$relation_field]['foreign_table'])
|
||||
. ' WHERE ' . PMA_Util::backquote($map[$relation_field]['foreign_field'])
|
||||
. $where_comparison;
|
||||
$dispresult = PMA_DBI_tryQuery($dispsql, null, PMA_DBI_QUERY_STORE);
|
||||
if ($dispresult && PMA_DBI_numRows($dispresult) > 0) {
|
||||
list($dispval) = PMA_DBI_fetchRow($dispresult, 0);
|
||||
$dispresult = $GLOBALS['dbi']->tryQuery(
|
||||
$dispsql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if ($dispresult && $GLOBALS['dbi']->numRows($dispresult) > 0) {
|
||||
list($dispval) = $GLOBALS['dbi']->fetchRow($dispresult, 0);
|
||||
}
|
||||
@PMA_DBI_freeResult($dispresult);
|
||||
@$GLOBALS['dbi']->freeResult($dispresult);
|
||||
return $dispval;
|
||||
}
|
||||
return '';
|
||||
@ -2133,7 +2137,7 @@ function PMA_getCurrentValueAsAnArrayForMultipleEdit($multi_edit_colummns,
|
||||
return $current_value;
|
||||
} elseif ('UUID' === $multi_edit_funcs[$key]) {
|
||||
/* This way user will know what UUID new row has */
|
||||
$uuid = PMA_DBI_fetchValue('SELECT UUID()');
|
||||
$uuid = $GLOBALS['dbi']->fetchValue('SELECT UUID()');
|
||||
return "'" . $uuid . "'";
|
||||
} elseif ((in_array($multi_edit_funcs[$key], $gis_from_text_functions)
|
||||
&& substr($current_value, 0, 3) == "'''")
|
||||
@ -2257,7 +2261,7 @@ function PMA_getCurrentValueForDifferentTypes($possibly_uploaded_val, $key,
|
||||
&& $using_key && isset($multi_edit_columns_type)
|
||||
&& is_array($multi_edit_columns_type) && isset($where_clause)
|
||||
) {
|
||||
$protected_row = PMA_DBI_fetchSingleRow(
|
||||
$protected_row = $GLOBALS['dbi']->fetchSingleRow(
|
||||
'SELECT * FROM ' . PMA_Util::backquote($table)
|
||||
. ' WHERE ' . $where_clause . ';'
|
||||
);
|
||||
@ -2360,8 +2364,8 @@ function PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData(
|
||||
. PMA_Util::backquote($table)
|
||||
. ' WHERE ' . $_REQUEST['where_clause'][0];
|
||||
|
||||
if (PMA_DBI_fetchValue($sql_for_real_value) !== false) {
|
||||
$extra_data['truncatableFieldValue'] = PMA_DBI_fetchValue($sql_for_real_value);
|
||||
if ($GLOBALS['dbi']->fetchValue($sql_for_real_value) !== false) {
|
||||
$extra_data['truncatableFieldValue'] = $GLOBALS['dbi']->fetchValue($sql_for_real_value);
|
||||
} else {
|
||||
$extra_data['isNeedToRecheck'] = false;
|
||||
}
|
||||
|
||||
@ -90,18 +90,18 @@ if (! empty($submit_mult)
|
||||
break;
|
||||
case 'primary':
|
||||
// Gets table primary key
|
||||
PMA_DBI_selectDb($db);
|
||||
$result = PMA_DBI_query(
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW KEYS FROM ' . PMA_Util::backquote($table) . ';'
|
||||
);
|
||||
$primary = '';
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
// Backups the list of primary keys
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$primary .= $row['Column_name'] . ', ';
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
if (empty($primary)) {
|
||||
// no primary key, so we can safely create new
|
||||
unset($submit_mult);
|
||||
@ -147,7 +147,7 @@ if (! empty($submit_mult)
|
||||
}
|
||||
} // end if
|
||||
|
||||
$views = PMA_DBI_getVirtualTables($db);
|
||||
$views = $GLOBALS['dbi']->getVirtualTables($db);
|
||||
|
||||
/**
|
||||
* Displays the confirmation form if required
|
||||
@ -351,7 +351,7 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
echo '</span>';
|
||||
echo '<span class="checkbox">';
|
||||
echo '<input type="checkbox" name="fk_check" value="1" id="fkc_checkbox"';
|
||||
$default_fk_check_value = PMA_DBI_fetchValue('SHOW VARIABLES LIKE \'foreign_key_checks\';', 0, 1) == 'ON';
|
||||
$default_fk_check_value = $GLOBALS['dbi']->fetchValue('SHOW VARIABLES LIKE \'foreign_key_checks\';', 0, 1) == 'ON';
|
||||
if ($default_fk_check_value) {
|
||||
echo ' checked="checked"';
|
||||
}
|
||||
@ -397,18 +397,18 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
|
||||
if ($query_type == 'primary_fld') {
|
||||
// Gets table primary key
|
||||
PMA_DBI_selectDb($db);
|
||||
$result = PMA_DBI_query(
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW KEYS FROM ' . PMA_Util::backquote($table) . ';'
|
||||
);
|
||||
$primary = '';
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
// Backups the list of primary keys
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$primary .= $row['Column_name'] . ', ';
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
$rebuild_database_list = false;
|
||||
@ -557,9 +557,9 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
if ($run_parts) {
|
||||
$sql_query .= $a_query . ';' . "\n";
|
||||
if ($query_type != 'drop_db') {
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
}
|
||||
$result = PMA_DBI_query($a_query);
|
||||
$result = $GLOBALS['dbi']->query($a_query);
|
||||
|
||||
if ($query_type == 'drop_db') {
|
||||
PMA_clearTransformations($selected[$i]);
|
||||
@ -573,7 +573,7 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
} // end for
|
||||
|
||||
if ($query_type == 'drop_tbl') {
|
||||
$default_fk_check_value = PMA_DBI_fetchValue('SHOW VARIABLES LIKE \'foreign_key_checks\';', 0, 1) == 'ON';
|
||||
$default_fk_check_value = $GLOBALS['dbi']->fetchValue('SHOW VARIABLES LIKE \'foreign_key_checks\';', 0, 1) == 'ON';
|
||||
if (!empty($sql_query)) {
|
||||
$sql_query .= ';';
|
||||
} elseif (!empty($sql_query_views)) {
|
||||
@ -585,26 +585,26 @@ if (!empty($submit_mult) && !empty($what)) {
|
||||
if ($use_sql) {
|
||||
include './sql.php';
|
||||
} elseif (!$run_parts) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
// for disabling foreign key checks while dropping tables
|
||||
if (! isset($_REQUEST['fk_check']) && $query_type == 'drop_tbl') {
|
||||
PMA_DBI_query('SET FOREIGN_KEY_CHECKS = 0;');
|
||||
$GLOBALS['dbi']->query('SET FOREIGN_KEY_CHECKS = 0;');
|
||||
}
|
||||
$result = PMA_DBI_tryQuery($sql_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($sql_query);
|
||||
if (! isset($_REQUEST['fk_check'])
|
||||
&& $query_type == 'drop_tbl'
|
||||
&& $default_fk_check_value
|
||||
) {
|
||||
PMA_DBI_query('SET FOREIGN_KEY_CHECKS = 1;');
|
||||
$GLOBALS['dbi']->query('SET FOREIGN_KEY_CHECKS = 1;');
|
||||
}
|
||||
if ($result && !empty($sql_query_views)) {
|
||||
$sql_query .= ' ' . $sql_query_views . ';';
|
||||
$result = PMA_DBI_tryQuery($sql_query_views);
|
||||
$result = $GLOBALS['dbi']->tryQuery($sql_query_views);
|
||||
unset($sql_query_views);
|
||||
}
|
||||
|
||||
if (! $result) {
|
||||
$message = PMA_Message::error(PMA_DBI_getError());
|
||||
$message = PMA_Message::error($GLOBALS['dbi']->getError());
|
||||
}
|
||||
}
|
||||
if ($rebuild_database_list) {
|
||||
|
||||
@ -19,17 +19,17 @@ if (! PMA_Util::cacheExists('mysql_charsets', true)) {
|
||||
$sql = PMA_DRIZZLE
|
||||
? 'SELECT * FROM data_dictionary.CHARACTER_SETS'
|
||||
: 'SELECT * FROM information_schema.CHARACTER_SETS';
|
||||
$res = PMA_DBI_query($sql);
|
||||
$res = $GLOBALS['dbi']->query($sql);
|
||||
|
||||
$mysql_charsets = array();
|
||||
while ($row = PMA_DBI_fetchAssoc($res)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
|
||||
$mysql_charsets[] = $row['CHARACTER_SET_NAME'];
|
||||
// never used
|
||||
//$mysql_charsets_maxlen[$row['Charset']] = $row['Maxlen'];
|
||||
$mysql_charsets_descriptions[$row['CHARACTER_SET_NAME']]
|
||||
= $row['DESCRIPTION'];
|
||||
}
|
||||
PMA_DBI_freeResult($res);
|
||||
$GLOBALS['dbi']->freeResult($res);
|
||||
|
||||
sort($mysql_charsets, SORT_STRING);
|
||||
|
||||
@ -40,8 +40,8 @@ if (! PMA_Util::cacheExists('mysql_charsets', true)) {
|
||||
$sql = PMA_DRIZZLE
|
||||
? 'SELECT * FROM data_dictionary.COLLATIONS'
|
||||
: 'SELECT * FROM information_schema.COLLATIONS';
|
||||
$res = PMA_DBI_query($sql);
|
||||
while ($row = PMA_DBI_fetchAssoc($res)) {
|
||||
$res = $GLOBALS['dbi']->query($sql);
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($res)) {
|
||||
if (! is_array($mysql_collations[$row['CHARACTER_SET_NAME']])) {
|
||||
$mysql_collations[$row['CHARACTER_SET_NAME']]
|
||||
= array($row['COLLATION_NAME']);
|
||||
@ -60,7 +60,7 @@ if (! PMA_Util::cacheExists('mysql_charsets', true)) {
|
||||
= !empty($mysql_charsets_available[$row['CHARACTER_SET_NAME']])
|
||||
|| !empty($mysql_collations_available[$row['COLLATION_NAME']]);
|
||||
}
|
||||
PMA_DBI_freeResult($res);
|
||||
$GLOBALS['dbi']->freeResult($res);
|
||||
unset($res, $row);
|
||||
|
||||
if (PMA_DRIZZLE
|
||||
@ -186,7 +186,7 @@ function PMA_generateCharsetQueryPart($collation)
|
||||
*/
|
||||
function PMA_getDbCollation($db)
|
||||
{
|
||||
if (PMA_isSystemSchema($db)) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($db)) {
|
||||
// We don't have to check the collation of the virtual
|
||||
// information_schema database: We know it!
|
||||
return 'utf8_general_ci';
|
||||
@ -201,14 +201,14 @@ function PMA_getDbCollation($db)
|
||||
: 'SELECT DEFAULT_COLLATION_NAME FROM information_schema.SCHEMATA'
|
||||
. ' WHERE SCHEMA_NAME = \'' . PMA_Util::sqlAddSlashes($db)
|
||||
. '\' LIMIT 1';
|
||||
return PMA_DBI_fetchValue($sql);
|
||||
return $GLOBALS['dbi']->fetchValue($sql);
|
||||
} else {
|
||||
PMA_DBI_selectDb($db);
|
||||
$return = PMA_DBI_fetchValue(
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$return = $GLOBALS['dbi']->fetchValue(
|
||||
'SHOW VARIABLES LIKE \'collation_database\'', 0, 1
|
||||
);
|
||||
if ($db !== $GLOBALS['db']) {
|
||||
PMA_DBI_selectDb($GLOBALS['db']);
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
}
|
||||
return $return;
|
||||
}
|
||||
@ -221,7 +221,7 @@ function PMA_getDbCollation($db)
|
||||
*/
|
||||
function PMA_getServerCollation()
|
||||
{
|
||||
return PMA_DBI_fetchValue(
|
||||
return $GLOBALS['dbi']->fetchValue(
|
||||
'SHOW VARIABLES LIKE \'collation_server\'', 0, 1
|
||||
);
|
||||
}
|
||||
|
||||
@ -160,7 +160,7 @@ class PMA_NavigationTree
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
|
||||
$query .= "WHERE `SCHEMA_NAME` < '%s' ";
|
||||
$query .= "ORDER BY `SCHEMA_NAME` ASC";
|
||||
$retval = PMA_DBI_fetchValue(
|
||||
$retval = $GLOBALS['dbi']->fetchValue(
|
||||
sprintf(
|
||||
$query,
|
||||
(int)$GLOBALS['cfg']['MaxNavigationItems'],
|
||||
|
||||
@ -365,7 +365,7 @@ class Node
|
||||
$query .= $this->_getWhereClause($searchClause);
|
||||
$query .= "ORDER BY `SCHEMA_NAME` ASC ";
|
||||
$query .= "LIMIT $pos, {$GLOBALS['cfg']['MaxNavigationItems']}";
|
||||
return PMA_DBI_fetchResult($query);
|
||||
return $GLOBALS['dbi']->fetchResult($query);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -395,7 +395,7 @@ class Node
|
||||
$query = "SELECT COUNT(*) ";
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`SCHEMATA` ";
|
||||
$query .= $this->_getWhereClause($searchClause);
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$query = "SHOW DATABASES ";
|
||||
if (! empty($searchClause)) {
|
||||
@ -405,7 +405,7 @@ class Node
|
||||
);
|
||||
$query .= "%' ";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
return $retval;
|
||||
}
|
||||
|
||||
@ -64,7 +64,7 @@ class Node_Column extends Node
|
||||
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
|
||||
$query .= "AND `TABLE_NAME`='$table' ";
|
||||
$query .= "AND `COLUMN_NAME`='$column' ";
|
||||
return PMA_DBI_fetchValue($query);
|
||||
return $GLOBALS['dbi']->fetchValue($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -67,7 +67,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$query = "SHOW FULL TABLES FROM ";
|
||||
$query .= PMA_Util::backquote($db);
|
||||
@ -81,7 +81,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
case 'views':
|
||||
@ -98,7 +98,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$query = "SHOW FULL TABLES FROM ";
|
||||
$query .= PMA_Util::backquote($db);
|
||||
@ -112,7 +112,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
case 'procedures':
|
||||
@ -129,7 +129,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::sqlAddSlashes($db);
|
||||
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' ";
|
||||
@ -140,7 +140,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
case 'functions':
|
||||
@ -157,7 +157,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::sqlAddSlashes($db);
|
||||
$query = "SHOW FUNCTION STATUS WHERE `Db`='$db' ";
|
||||
@ -168,7 +168,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
case 'events':
|
||||
@ -184,7 +184,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$query = "SHOW EVENTS FROM $db ";
|
||||
@ -195,7 +195,7 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$retval = PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = $GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -237,7 +237,7 @@ class Node_Database extends Node
|
||||
}
|
||||
$query .= "ORDER BY `TABLE_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$query = " SHOW FULL TABLES FROM ";
|
||||
$query .= PMA_Util::backquote($db);
|
||||
@ -251,10 +251,10 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
@ -280,7 +280,7 @@ class Node_Database extends Node
|
||||
}
|
||||
$query .= "ORDER BY `TABLE_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$query = "SHOW FULL TABLES FROM ";
|
||||
$query .= PMA_Util::backquote($db);
|
||||
@ -294,10 +294,10 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr[0];
|
||||
$count++;
|
||||
@ -323,7 +323,7 @@ class Node_Database extends Node
|
||||
}
|
||||
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$db = PMA_Util::sqlAddSlashes($db);
|
||||
$query = "SHOW PROCEDURE STATUS WHERE `Db`='$db' ";
|
||||
@ -334,10 +334,10 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
@ -363,7 +363,7 @@ class Node_Database extends Node
|
||||
}
|
||||
$query .= "ORDER BY `ROUTINE_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$db = PMA_Util::sqlAddSlashes($db);
|
||||
$query = "SHOW FUNCTION STATUS WHERE `Db`='$db' ";
|
||||
@ -374,10 +374,10 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
@ -402,7 +402,7 @@ class Node_Database extends Node
|
||||
}
|
||||
$query .= "ORDER BY `EVENT_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$query = "SHOW EVENTS FROM $db ";
|
||||
@ -413,10 +413,10 @@ class Node_Database extends Node
|
||||
);
|
||||
$query .= "%'";
|
||||
}
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Name'];
|
||||
$count++;
|
||||
|
||||
@ -59,7 +59,7 @@ class Node_Event extends Node
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`EVENTS` ";
|
||||
$query .= "WHERE `EVENT_SCHEMA`='$db' ";
|
||||
$query .= "AND `EVENT_NAME`='$event' ";
|
||||
return PMA_DBI_fetchValue($query);
|
||||
return $GLOBALS['dbi']->fetchValue($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ class Node_Function extends Node
|
||||
$query .= "WHERE `ROUTINE_SCHEMA`='$db' ";
|
||||
$query .= "AND `ROUTINE_NAME`='$routine' ";
|
||||
$query .= "AND `ROUTINE_TYPE`='FUNCTION' ";
|
||||
return PMA_DBI_fetchValue($query);
|
||||
return $GLOBALS['dbi']->fetchValue($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -60,7 +60,7 @@ class Node_Procedure extends Node
|
||||
$query .= "WHERE `ROUTINE_SCHEMA`='$db' ";
|
||||
$query .= "AND `ROUTINE_NAME`='$routine' ";
|
||||
$query .= "AND `ROUTINE_TYPE`='PROCEDURE' ";
|
||||
return PMA_DBI_fetchValue($query);
|
||||
return $GLOBALS['dbi']->fetchValue($query);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -64,19 +64,19 @@ class Node_Table extends Node
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`COLUMNS` ";
|
||||
$query .= "WHERE `TABLE_NAME`='$table' ";
|
||||
$query .= "AND `TABLE_SCHEMA`='$db'";
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::backquote($table);
|
||||
$query = "SHOW COLUMNS FROM $table FROM $db";
|
||||
$retval = (int)PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = (int)$GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
case 'indexes':
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::backquote($table);
|
||||
$query = "SHOW INDEXES FROM $table FROM $db";
|
||||
$retval = (int)PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = (int)$GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
break;
|
||||
case 'triggers':
|
||||
if (! $GLOBALS['cfg']['Servers'][$GLOBALS['server']]['DisableIS']) {
|
||||
@ -86,12 +86,12 @@ class Node_Table extends Node
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`TRIGGERS` ";
|
||||
$query .= "WHERE `EVENT_OBJECT_SCHEMA`='$db' ";
|
||||
$query .= "AND `EVENT_OBJECT_TABLE`='$table'";
|
||||
$retval = (int)PMA_DBI_fetchValue($query);
|
||||
$retval = (int)$GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::sqlAddSlashes($table);
|
||||
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
|
||||
$retval = (int)PMA_DBI_numRows(PMA_DBI_tryQuery($query));
|
||||
$retval = (int)$GLOBALS['dbi']->numRows($GLOBALS['dbi']->tryQuery($query));
|
||||
}
|
||||
break;
|
||||
default:
|
||||
@ -128,15 +128,15 @@ class Node_Table extends Node
|
||||
$query .= "AND `TABLE_SCHEMA`='$db' ";
|
||||
$query .= "ORDER BY `COLUMN_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::backquote($table);
|
||||
$query = "SHOW COLUMNS FROM $table FROM $db";
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Field'];
|
||||
$count++;
|
||||
@ -150,10 +150,10 @@ class Node_Table extends Node
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::backquote($table);
|
||||
$query = "SHOW INDEXES FROM $table FROM $db";
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if (! in_array($arr['Key_name'], $retval)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Key_name'];
|
||||
@ -174,15 +174,15 @@ class Node_Table extends Node
|
||||
$query .= "AND `EVENT_OBJECT_TABLE`='$table' ";
|
||||
$query .= "ORDER BY `TRIGGER_NAME` ASC ";
|
||||
$query .= "LIMIT " . intval($pos) . ", $maxItems";
|
||||
$retval = PMA_DBI_fetchResult($query);
|
||||
$retval = $GLOBALS['dbi']->fetchResult($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$table = PMA_Util::sqlAddSlashes($table);
|
||||
$query = "SHOW TRIGGERS FROM $db WHERE `Table` = '$table'";
|
||||
$handle = PMA_DBI_tryQuery($query);
|
||||
$handle = $GLOBALS['dbi']->tryQuery($query);
|
||||
if ($handle !== false) {
|
||||
$count = 0;
|
||||
while ($arr = PMA_DBI_fetchArray($handle)) {
|
||||
while ($arr = $GLOBALS['dbi']->fetchArray($handle)) {
|
||||
if ($pos <= 0 && $count < $maxItems) {
|
||||
$retval[] = $arr['Trigger'];
|
||||
$count++;
|
||||
@ -214,12 +214,12 @@ class Node_Table extends Node
|
||||
$query .= "FROM `INFORMATION_SCHEMA`.`TABLES` ";
|
||||
$query .= "WHERE `TABLE_SCHEMA`='$db' ";
|
||||
$query .= "AND `TABLE_NAME`='$table' ";
|
||||
$retval = PMA_DBI_fetchValue($query);
|
||||
$retval = $GLOBALS['dbi']->fetchValue($query);
|
||||
} else {
|
||||
$db = PMA_Util::backquote($db);
|
||||
$query = "SHOW TABLE STATUS FROM $db ";
|
||||
$query .= "WHERE Name = '$table'";
|
||||
$arr = PMA_DBI_fetchAssoc(PMA_DBI_tryQuery($query));
|
||||
$arr = $GLOBALS['dbi']->fetchAssoc($GLOBALS['dbi']->tryQuery($query));
|
||||
$retval = $arr['Comment'];
|
||||
}
|
||||
return $retval;
|
||||
|
||||
@ -294,29 +294,29 @@ function PMA_getHtmlForExportRelationalSchemaView($url_query)
|
||||
*/
|
||||
function PMA_runProcedureAndFunctionDefinitions($db)
|
||||
{
|
||||
$procedure_names = PMA_DBI_getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
$procedure_names = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
if ($procedure_names) {
|
||||
foreach ($procedure_names as $procedure_name) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$tmp_query = PMA_DBI_getDefinition(
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$tmp_query = $GLOBALS['dbi']->getDefinition(
|
||||
$db, 'PROCEDURE', $procedure_name
|
||||
);
|
||||
// collect for later display
|
||||
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
PMA_DBI_query($tmp_query);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->query($tmp_query);
|
||||
}
|
||||
}
|
||||
|
||||
$function_names = PMA_DBI_getProceduresOrFunctions($db, 'FUNCTION');
|
||||
$function_names = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'FUNCTION');
|
||||
if ($function_names) {
|
||||
foreach ($function_names as $function_name) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$tmp_query = PMA_DBI_getDefinition($db, 'FUNCTION', $function_name);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$tmp_query = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $function_name);
|
||||
// collect for later display
|
||||
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
PMA_DBI_query($tmp_query);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->query($tmp_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -330,7 +330,7 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
|
||||
{
|
||||
// lower_case_table_names=1 `DB` becomes `db`
|
||||
if (! PMA_DRIZZLE) {
|
||||
$lower_case_table_names = PMA_DBI_fetchValue(
|
||||
$lower_case_table_names = $GLOBALS['dbi']->fetchValue(
|
||||
'SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1
|
||||
);
|
||||
if ($lower_case_table_names === '1') {
|
||||
@ -347,10 +347,10 @@ function PMA_getSqlQueryAndCreateDbBeforeCopy()
|
||||
$local_query .= ';';
|
||||
$sql_query = $local_query;
|
||||
// save the original db name because Tracker.class.php which
|
||||
// may be called under PMA_DBI_query() changes $GLOBALS['db']
|
||||
// may be called under $GLOBALS['dbi']->query() changes $GLOBALS['db']
|
||||
// for some statements, one of which being CREATE DATABASE
|
||||
$original_db = $GLOBALS['db'];
|
||||
PMA_DBI_query($local_query);
|
||||
$GLOBALS['dbi']->query($local_query);
|
||||
$GLOBALS['db'] = $original_db;
|
||||
|
||||
// rebuild the database list because PMA_Table::moveCopy
|
||||
@ -382,7 +382,7 @@ function PMA_getSqlConstraintsQueryForFullDb(
|
||||
$db, $each_table, "\n", '', false, false
|
||||
);
|
||||
if ($move && ! empty($sql_drop_foreign_keys)) {
|
||||
PMA_DBI_query($sql_drop_foreign_keys);
|
||||
$GLOBALS['dbi']->query($sql_drop_foreign_keys);
|
||||
}
|
||||
// keep the constraint we just dropped
|
||||
if (! empty($sql_constraints)) {
|
||||
@ -415,8 +415,8 @@ function PMA_getViewsAndCreateSqlViewStandIn(
|
||||
$sql_view_standin = $export_sql_plugin->getTableDefStandIn(
|
||||
$db, $each_table, "\n"
|
||||
);
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
PMA_DBI_query($sql_view_standin);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->query($sql_view_standin);
|
||||
$GLOBALS['sql_query'] .= "\n" . $sql_view_standin;
|
||||
}
|
||||
}
|
||||
@ -462,7 +462,7 @@ function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db)
|
||||
// keep the triggers from the original db+table
|
||||
// (third param is empty because delimiters are only intended
|
||||
// for importing via the mysql client or our Import feature)
|
||||
$triggers = PMA_DBI_getTriggers($db, $each_table, '');
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $each_table, '');
|
||||
|
||||
if (! PMA_Table::moveCopy(
|
||||
$db, $each_table, $_REQUEST['newname'], $each_table,
|
||||
@ -476,9 +476,9 @@ function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db)
|
||||
}
|
||||
// apply the triggers to the destination db+table
|
||||
if ($triggers) {
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
foreach ($triggers as $trigger) {
|
||||
PMA_DBI_query($trigger['create']);
|
||||
$GLOBALS['dbi']->query($trigger['create']);
|
||||
$GLOBALS['sql_query'] .= "\n" . $trigger['create'] . ';';
|
||||
}
|
||||
}
|
||||
@ -511,18 +511,18 @@ function PMA_getSqlQueryForCopyTable($tables_full, $sql_query, $move, $db)
|
||||
*/
|
||||
function PMA_runEventDefinitionsForDb($db)
|
||||
{
|
||||
$event_names = PMA_DBI_fetchResult(
|
||||
$event_names = $GLOBALS['dbi']->fetchResult(
|
||||
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE EVENT_SCHEMA= \''
|
||||
. PMA_Util::sqlAddSlashes($db, true) . '\';'
|
||||
);
|
||||
if ($event_names) {
|
||||
foreach ($event_names as $event_name) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$tmp_query = PMA_DBI_getDefinition($db, 'EVENT', $event_name);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
$tmp_query = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event_name);
|
||||
// collect for later display
|
||||
$GLOBALS['sql_query'] .= "\n" . $tmp_query;
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
PMA_DBI_query($tmp_query);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->query($tmp_query);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -571,9 +571,9 @@ function PMA_handleTheViews($views, $move, $db)
|
||||
*/
|
||||
function PMA_createAllAccumulatedConstraints()
|
||||
{
|
||||
PMA_DBI_selectDb($_REQUEST['newname']);
|
||||
$GLOBALS['dbi']->selectDb($_REQUEST['newname']);
|
||||
foreach ($GLOBALS['sql_constraints_query_full_db'] as $one_query) {
|
||||
PMA_DBI_query($one_query);
|
||||
$GLOBALS['dbi']->query($one_query);
|
||||
// and prepare to display them
|
||||
$GLOBALS['sql_query'] .= "\n" . $one_query;
|
||||
}
|
||||
@ -1424,7 +1424,7 @@ function PMA_getQueryAndResultForReorderingTable()
|
||||
$sql_query .= ' DESC';
|
||||
}
|
||||
$sql_query .= ';';
|
||||
$result = PMA_DBI_query($sql_query);
|
||||
$result = $GLOBALS['dbi']->query($sql_query);
|
||||
|
||||
return array($sql_query, $result);
|
||||
}
|
||||
@ -1573,7 +1573,7 @@ function PMA_setGlobalVariablesForEngine($tbl_storage_engine)
|
||||
function PMA_getWarningMessagesArray()
|
||||
{
|
||||
$warning_messages = array();
|
||||
foreach (PMA_DBI_getWarnings() as $warning) {
|
||||
foreach ($GLOBALS['dbi']->getWarnings() as $warning) {
|
||||
// In MariaDB 5.1.44, when altering a table from Maria to MyISAM
|
||||
// and if TRANSACTIONAL was set, the system reports an error;
|
||||
// I discussed with a Maria developer and he agrees that this
|
||||
@ -1604,7 +1604,7 @@ function PMA_getQueryAndResultForPartition()
|
||||
. $_REQUEST['partition_operation']
|
||||
. ' PARTITION '
|
||||
. $_REQUEST['partition_name'] . ';';
|
||||
$result = PMA_DBI_query($sql_query);
|
||||
$result = $GLOBALS['dbi']->query($sql_query);
|
||||
|
||||
return array($sql_query, $result);
|
||||
}
|
||||
|
||||
@ -68,7 +68,7 @@ class AuthenticationConfig extends AuthenticationPlugin
|
||||
*/
|
||||
public function authFails()
|
||||
{
|
||||
$conn_error = PMA_DBI_getError();
|
||||
$conn_error = $GLOBALS['dbi']->getError();
|
||||
if (! $conn_error) {
|
||||
$conn_error = __('Cannot connect: invalid settings.');
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
*
|
||||
* this function DOES NOT check authentication - it just checks/provides
|
||||
* authentication credentials required to connect to the MySQL server
|
||||
* usually with PMA_DBI_connect()
|
||||
* usually with $GLOBALS['dbi']->connect()
|
||||
*
|
||||
* it returns false if something is missing - which usually leads to
|
||||
* auth() which displays login form
|
||||
@ -590,7 +590,7 @@ class AuthenticationCookie extends AuthenticationPlugin
|
||||
__('No activity within %s seconds; please log in again'),
|
||||
$GLOBALS['cfg']['LoginCookieValidity']
|
||||
);
|
||||
} elseif (PMA_DBI_getError()) {
|
||||
} elseif ($GLOBALS['dbi']->getError()) {
|
||||
$conn_error = '#' . $GLOBALS['errno'] . ' '
|
||||
. __('Cannot log in to the MySQL server');
|
||||
} else {
|
||||
|
||||
@ -225,7 +225,7 @@ class AuthenticationHttp extends AuthenticationPlugin
|
||||
*/
|
||||
public function authFails()
|
||||
{
|
||||
$error = PMA_DBI_getError();
|
||||
$error = $GLOBALS['dbi']->getError();
|
||||
if ($error && $GLOBALS['errno'] != 1045) {
|
||||
PMA_fatalError($error);
|
||||
} else {
|
||||
|
||||
@ -256,9 +256,9 @@ class AuthenticationSignon extends AuthenticationPlugin
|
||||
__('No activity within %s seconds; please log in again'),
|
||||
$GLOBALS['cfg']['LoginCookieValidity']
|
||||
);
|
||||
} elseif (PMA_DBI_getError()) {
|
||||
} elseif ($GLOBALS['dbi']->getError()) {
|
||||
$_SESSION['PMA_single_signon_error_message'] = PMA_sanitize(
|
||||
PMA_DBI_getError()
|
||||
$GLOBALS['dbi']->getError()
|
||||
);
|
||||
} else {
|
||||
$_SESSION['PMA_single_signon_error_message'] = __(
|
||||
|
||||
@ -244,7 +244,7 @@ class ExportCodegen extends ExportPlugin
|
||||
{
|
||||
$lines = array();
|
||||
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
sprintf(
|
||||
'DESC %s.%s', PMA_Util::backquote($db),
|
||||
PMA_Util::backquote($table)
|
||||
@ -252,10 +252,10 @@ class ExportCodegen extends ExportPlugin
|
||||
);
|
||||
if ($result) {
|
||||
$tableProperties = array();
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$tableProperties[] = new TableProperty($row);
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
$lines[] = 'using System;';
|
||||
$lines[] = 'using System.Collections;';
|
||||
$lines[] = 'using System.Collections.Generic;';
|
||||
@ -336,14 +336,14 @@ class ExportCodegen extends ExportPlugin
|
||||
$lines[] = ' <class '
|
||||
. 'name="' . ExportCodegen::cgMakeIdentifier($table) . '" '
|
||||
. 'table="' . ExportCodegen::cgMakeIdentifier($table) . '">';
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
sprintf(
|
||||
"DESC %s.%s", PMA_Util::backquote($db),
|
||||
PMA_Util::backquote($table)
|
||||
)
|
||||
);
|
||||
if ($result) {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$tableProperty = new TableProperty($row);
|
||||
if ($tableProperty->isPK()) {
|
||||
$lines[] = $tableProperty->formatXml(
|
||||
@ -365,7 +365,7 @@ class ExportCodegen extends ExportPlugin
|
||||
);
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
$lines[] = ' </class>';
|
||||
$lines[] = '</hibernate-mapping>';
|
||||
|
||||
@ -246,21 +246,23 @@ class ExportCsv extends ExportPlugin
|
||||
global $what, $csv_terminated, $csv_separator, $csv_enclosed, $csv_escaped;
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['csv_columns'])) {
|
||||
$schema_insert = '';
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
if ($csv_enclosed == '') {
|
||||
$schema_insert .= stripslashes(PMA_DBI_fieldName($result, $i));
|
||||
$schema_insert .= stripslashes($GLOBALS['dbi']->fieldName($result, $i));
|
||||
} else {
|
||||
$schema_insert .= $csv_enclosed
|
||||
. str_replace(
|
||||
$csv_enclosed,
|
||||
$csv_escaped . $csv_enclosed,
|
||||
stripslashes(PMA_DBI_fieldName($result, $i))
|
||||
stripslashes($GLOBALS['dbi']->fieldName($result, $i))
|
||||
)
|
||||
. $csv_enclosed;
|
||||
}
|
||||
@ -273,7 +275,7 @@ class ExportCsv extends ExportPlugin
|
||||
} // end if
|
||||
|
||||
// Format the data
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$schema_insert = '';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (! isset($row[$j]) || is_null($row[$j])) {
|
||||
@ -336,7 +338,7 @@ class ExportCsv extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -212,8 +212,10 @@ class ExportHtmlword extends ExportPlugin
|
||||
}
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS['htmlword_columns'])) {
|
||||
@ -221,7 +223,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
$schema_insert .= '<td class="print"><strong>'
|
||||
. htmlspecialchars(
|
||||
stripslashes(PMA_DBI_fieldName($result, $i))
|
||||
stripslashes($GLOBALS['dbi']->fieldName($result, $i))
|
||||
)
|
||||
. '</strong></td>';
|
||||
} // end for
|
||||
@ -232,7 +234,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
} // end if
|
||||
|
||||
// Format the data
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$schema_insert = '<tr class="print-category">';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (! isset($row[$j]) || is_null($row[$j])) {
|
||||
@ -251,7 +253,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
if (! PMA_exportOutputHandler('</table>')) {
|
||||
return false;
|
||||
}
|
||||
@ -290,14 +292,14 @@ class ExportHtmlword extends ExportPlugin
|
||||
* Get the unique keys in the view
|
||||
*/
|
||||
$unique_keys = array();
|
||||
$keys = PMA_DBI_getTableIndexes($db, $view);
|
||||
$keys = $GLOBALS['dbi']->getTableIndexes($db, $view);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] == 0) {
|
||||
$unique_keys[] = $key['Column_name'];
|
||||
}
|
||||
}
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $view);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$schema_insert .= $this->formatOneColumnDefinition(
|
||||
$column,
|
||||
@ -353,7 +355,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
if ($do_relation && ! empty($cfgRelation['relation'])) {
|
||||
@ -418,12 +420,12 @@ class ExportHtmlword extends ExportPlugin
|
||||
}
|
||||
$schema_insert .= '</tr>';
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
/**
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$unique_keys = array();
|
||||
$keys = PMA_DBI_getTableIndexes($db, $table);
|
||||
$keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] == 0) {
|
||||
$unique_keys[] = $key['Column_name'];
|
||||
@ -486,7 +488,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
$dump .= '<td class="print"><strong>' . __('Definition') . '</strong></td>';
|
||||
$dump .= '</tr>';
|
||||
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
|
||||
foreach ($triggers as $trigger) {
|
||||
$dump .= '<tr class="print-category">';
|
||||
@ -557,7 +559,7 @@ class ExportHtmlword extends ExportPlugin
|
||||
break;
|
||||
case 'triggers':
|
||||
$dump = '';
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
if ($triggers) {
|
||||
$dump .= '<h2>'
|
||||
. __('Triggers') . ' ' . htmlspecialchars($table)
|
||||
|
||||
@ -158,20 +158,22 @@ class ExportJson extends ExportPlugin
|
||||
*/
|
||||
public function exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$columns_cnt = PMA_DBI_numFields($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$columns_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
// Get field information
|
||||
$fields_meta = PMA_DBI_getFieldsMeta($result);
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$columns[$i] = stripslashes(PMA_DBI_fieldName($result, $i));
|
||||
$columns[$i] = stripslashes($GLOBALS['dbi']->fieldName($result, $i));
|
||||
}
|
||||
unset($i);
|
||||
|
||||
$buffer = '';
|
||||
$record_cnt = 0;
|
||||
while ($record = PMA_DBI_fetchRow($result)) {
|
||||
while ($record = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
|
||||
$record_cnt++;
|
||||
|
||||
@ -214,7 +216,7 @@ class ExportJson extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -290,11 +290,13 @@ class ExportLatex extends ExportPlugin
|
||||
*/
|
||||
public function exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
$result = PMA_DBI_tryQuery($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
|
||||
$columns_cnt = PMA_DBI_numFields($result);
|
||||
$columns_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$columns[$i] = PMA_DBI_fieldName($result, $i);
|
||||
$columns[$i] = $GLOBALS['dbi']->fieldName($result, $i);
|
||||
}
|
||||
unset($i);
|
||||
|
||||
@ -370,7 +372,7 @@ class ExportLatex extends ExportPlugin
|
||||
}
|
||||
|
||||
// print the whole table
|
||||
while ($record = PMA_DBI_fetchAssoc($result)) {
|
||||
while ($record = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
$buffer = '';
|
||||
// print each row
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
@ -403,7 +405,7 @@ class ExportLatex extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
return true;
|
||||
} // end getTableLaTeX
|
||||
|
||||
@ -452,7 +454,7 @@ class ExportLatex extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$unique_keys = array();
|
||||
$keys = PMA_DBI_getTableIndexes($db, $table);
|
||||
$keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] == 0) {
|
||||
$unique_keys[] = $key['Column_name'];
|
||||
@ -462,7 +464,7 @@ class ExportLatex extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
if ($do_relation && ! empty($cfgRelation['relation'])) {
|
||||
@ -563,7 +565,7 @@ class ExportLatex extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
$fields = PMA_DBI_getColumns($db, $table);
|
||||
$fields = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
foreach ($fields as $row) {
|
||||
$extracted_columnspec
|
||||
= PMA_Util::extractColumnSpec(
|
||||
|
||||
@ -202,7 +202,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
) {
|
||||
switch($export_mode) {
|
||||
case 'create_table':
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
$columns = array_values($columns);
|
||||
$row_cnt = count($columns);
|
||||
|
||||
@ -300,7 +300,7 @@ class ExportMediawiki extends ExportPlugin
|
||||
// Add the table headers
|
||||
if ($GLOBALS['mediawiki_headers']) {
|
||||
// Get column names
|
||||
$column_names = PMA_DBI_getColumnNames($db, $table);
|
||||
$column_names = $GLOBALS['dbi']->getColumnNames($db, $table);
|
||||
|
||||
// Add column names as table headers
|
||||
if ( ! is_null($column_names) ) {
|
||||
@ -315,10 +315,12 @@ class ExportMediawiki extends ExportPlugin
|
||||
}
|
||||
|
||||
// Get the table data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$output .= "|-" . $this->_exportCRLF();
|
||||
|
||||
// Use '|' for separating table columns
|
||||
|
||||
@ -226,12 +226,14 @@ class ExportOds extends ExportPlugin
|
||||
global $what;
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$fields_meta = PMA_DBI_getFieldsMeta($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$field_flags = array();
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
$field_flags[$j] = PMA_DBI_fieldFlags($result, $j);
|
||||
$field_flags[$j] = $GLOBALS['dbi']->fieldFlags($result, $j);
|
||||
}
|
||||
|
||||
$GLOBALS['ods_buffer'] .=
|
||||
@ -245,7 +247,7 @@ class ExportOds extends ExportPlugin
|
||||
'<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars(
|
||||
stripslashes(PMA_DBI_fieldName($result, $i))
|
||||
stripslashes($GLOBALS['dbi']->fieldName($result, $i))
|
||||
)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
@ -254,7 +256,7 @@ class ExportOds extends ExportPlugin
|
||||
} // end if
|
||||
|
||||
// Format the data
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$GLOBALS['ods_buffer'] .= '<table:table-row>';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (! isset($row[$j]) || is_null($row[$j])) {
|
||||
@ -324,7 +326,7 @@ class ExportOds extends ExportPlugin
|
||||
} // end for
|
||||
$GLOBALS['ods_buffer'] .= '</table:table-row>';
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
$GLOBALS['ods_buffer'] .= '</table:table>';
|
||||
|
||||
|
||||
@ -244,12 +244,14 @@ class ExportOdt extends ExportPlugin
|
||||
global $what;
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$fields_meta = PMA_DBI_getFieldsMeta($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$field_flags = array();
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
$field_flags[$j] = PMA_DBI_fieldFlags($result, $j);
|
||||
$field_flags[$j] = $GLOBALS['dbi']->fieldFlags($result, $j);
|
||||
}
|
||||
|
||||
$GLOBALS['odt_buffer'] .=
|
||||
@ -270,7 +272,7 @@ class ExportOdt extends ExportPlugin
|
||||
'<table:table-cell office:value-type="string">'
|
||||
. '<text:p>'
|
||||
. htmlspecialchars(
|
||||
stripslashes(PMA_DBI_fieldName($result, $i))
|
||||
stripslashes($GLOBALS['dbi']->fieldName($result, $i))
|
||||
)
|
||||
. '</text:p>'
|
||||
. '</table:table-cell>';
|
||||
@ -279,7 +281,7 @@ class ExportOdt extends ExportPlugin
|
||||
} // end if
|
||||
|
||||
// Format the data
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (! isset($row[$j]) || is_null($row[$j])) {
|
||||
@ -319,7 +321,7 @@ class ExportOdt extends ExportPlugin
|
||||
} // end for
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
$GLOBALS['odt_buffer'] .= '</table:table>';
|
||||
|
||||
@ -340,7 +342,7 @@ class ExportOdt extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
/**
|
||||
* Displays the table structure
|
||||
@ -368,7 +370,7 @@ class ExportOdt extends ExportPlugin
|
||||
. '</table:table-cell>'
|
||||
. '</table:table-row>';
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $view);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column);
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
@ -416,7 +418,7 @@ class ExportOdt extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
if ($do_relation && ! empty($cfgRelation['relation'])) {
|
||||
@ -483,7 +485,7 @@ class ExportOdt extends ExportPlugin
|
||||
}
|
||||
$GLOBALS['odt_buffer'] .= '</table:table-row>';
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
$field_name = $column['Field'];
|
||||
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column);
|
||||
@ -569,7 +571,7 @@ class ExportOdt extends ExportPlugin
|
||||
. '</table:table-cell>'
|
||||
. '</table:table-row>';
|
||||
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
|
||||
foreach ($triggers as $trigger) {
|
||||
$GLOBALS['odt_buffer'] .= '<table:table-row>';
|
||||
@ -647,7 +649,7 @@ class ExportOdt extends ExportPlugin
|
||||
);
|
||||
break;
|
||||
case 'triggers':
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
if ($triggers) {
|
||||
$GLOBALS['odt_buffer'] .=
|
||||
'<text:h text:outline-level="2" text:style-name="Heading_2"'
|
||||
|
||||
@ -163,11 +163,13 @@ class ExportPhparray extends ExportPlugin
|
||||
*/
|
||||
public function exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
|
||||
$columns_cnt = PMA_DBI_numFields($result);
|
||||
$columns_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$columns[$i] = stripslashes(PMA_DBI_fieldName($result, $i));
|
||||
$columns[$i] = stripslashes($GLOBALS['dbi']->fieldName($result, $i));
|
||||
}
|
||||
unset($i);
|
||||
|
||||
@ -197,7 +199,7 @@ class ExportPhparray extends ExportPlugin
|
||||
. PMA_Util::backquote($table) . $crlf;
|
||||
$buffer .= '$' . $tablefixed . ' = array(';
|
||||
|
||||
while ($record = PMA_DBI_fetchRow($result)) {
|
||||
while ($record = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$record_cnt++;
|
||||
|
||||
if ($record_cnt == 1) {
|
||||
@ -220,7 +222,7 @@ class ExportPhparray extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@ -149,7 +149,7 @@ class ExportSql extends ExportPlugin
|
||||
$generalOptions->addProperty($leaf);
|
||||
|
||||
// compatibility maximization
|
||||
$compats = PMA_DBI_getCompatibilities();
|
||||
$compats = $GLOBALS['dbi']->getCompatibilities();
|
||||
if (count($compats) > 0) {
|
||||
$values = array();
|
||||
foreach ($compats as $val) {
|
||||
@ -444,8 +444,8 @@ class ExportSql extends ExportPlugin
|
||||
$text = '';
|
||||
$delimiter = '$$';
|
||||
|
||||
$procedure_names = PMA_DBI_getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
$function_names = PMA_DBI_getProceduresOrFunctions($db, 'FUNCTION');
|
||||
$procedure_names = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
$function_names = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'FUNCTION');
|
||||
|
||||
if ($procedure_names || $function_names) {
|
||||
$text .= $crlf
|
||||
@ -464,7 +464,7 @@ class ExportSql extends ExportPlugin
|
||||
. PMA_Util::backquote($procedure_name)
|
||||
. $delimiter . $crlf;
|
||||
}
|
||||
$text .= PMA_DBI_getDefinition($db, 'PROCEDURE', $procedure_name)
|
||||
$text .= $GLOBALS['dbi']->getDefinition($db, 'PROCEDURE', $procedure_name)
|
||||
. $delimiter . $crlf . $crlf;
|
||||
}
|
||||
}
|
||||
@ -481,7 +481,7 @@ class ExportSql extends ExportPlugin
|
||||
. PMA_Util::backquote($function_name)
|
||||
. $delimiter . $crlf;
|
||||
}
|
||||
$text .= PMA_DBI_getDefinition($db, 'FUNCTION', $function_name)
|
||||
$text .= $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $function_name)
|
||||
. $delimiter . $crlf . $crlf;
|
||||
}
|
||||
}
|
||||
@ -569,7 +569,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
/* Restore timezone */
|
||||
if (isset($GLOBALS['sql_utc_time']) && $GLOBALS['sql_utc_time']) {
|
||||
PMA_DBI_query('SET time_zone = "' . $GLOBALS['old_tz'] . '"');
|
||||
$GLOBALS['dbi']->query('SET time_zone = "' . $GLOBALS['old_tz'] . '"');
|
||||
}
|
||||
|
||||
return PMA_exportOutputHandler($foot);
|
||||
@ -591,7 +591,7 @@ class ExportSql extends ExportPlugin
|
||||
if ($tmp_compat == 'NONE') {
|
||||
$tmp_compat = '';
|
||||
}
|
||||
PMA_DBI_tryQuery('SET SQL_MODE="' . $tmp_compat . '"');
|
||||
$GLOBALS['dbi']->tryQuery('SET SQL_MODE="' . $tmp_compat . '"');
|
||||
unset($tmp_compat);
|
||||
}
|
||||
$head = $this->_exportComment('phpMyAdmin SQL Dump')
|
||||
@ -648,8 +648,8 @@ class ExportSql extends ExportPlugin
|
||||
/* Change timezone if we should export timestamps in UTC */
|
||||
if (isset($GLOBALS['sql_utc_time']) && $GLOBALS['sql_utc_time']) {
|
||||
$head .= 'SET time_zone = "+00:00";' . $crlf;
|
||||
$GLOBALS['old_tz'] = PMA_DBI_fetchValue('SELECT @@session.time_zone');
|
||||
PMA_DBI_query('SET time_zone = "+00:00"');
|
||||
$GLOBALS['old_tz'] = $GLOBALS['dbi']->fetchValue('SELECT @@session.time_zone');
|
||||
$GLOBALS['dbi']->query('SET time_zone = "+00:00"');
|
||||
}
|
||||
|
||||
$head .= $this->_possibleCRLF();
|
||||
@ -791,7 +791,7 @@ class ExportSql extends ExportPlugin
|
||||
$delimiter = '$$';
|
||||
|
||||
if (PMA_MYSQL_INT_VERSION > 50100) {
|
||||
$event_names = PMA_DBI_fetchResult(
|
||||
$event_names = $GLOBALS['dbi']->fetchResult(
|
||||
'SELECT EVENT_NAME FROM information_schema.EVENTS WHERE'
|
||||
. ' EVENT_SCHEMA= \''
|
||||
. PMA_Util::sqlAddSlashes($db, true)
|
||||
@ -816,7 +816,7 @@ class ExportSql extends ExportPlugin
|
||||
. PMA_Util::backquote($event_name)
|
||||
. $delimiter . $crlf;
|
||||
}
|
||||
$text .= PMA_DBI_getDefinition($db, 'EVENT', $event_name)
|
||||
$text .= $GLOBALS['dbi']->getDefinition($db, 'EVENT', $event_name)
|
||||
. $delimiter . $crlf . $crlf;
|
||||
}
|
||||
|
||||
@ -857,7 +857,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
$create_query .= PMA_Util::backquote($view) . ' (' . $crlf;
|
||||
$tmp = array();
|
||||
$columns = PMA_DBI_getColumnsFull($db, $view);
|
||||
$columns = $GLOBALS['dbi']->getColumnsFull($db, $view);
|
||||
foreach ($columns as $column_name => $definition) {
|
||||
$tmp[] = PMA_Util::backquote($column_name) . ' ' .
|
||||
$definition['Type'] . $crlf;
|
||||
@ -903,16 +903,17 @@ class ExportSql extends ExportPlugin
|
||||
$compat = 'NONE';
|
||||
}
|
||||
|
||||
// need to use PMA_DBI_QUERY_STORE with PMA_DBI_numRows() in mysqli
|
||||
$result = PMA_DBI_query(
|
||||
// need to use PMA_DatabaseInterface::QUERY_STORE
|
||||
// with $GLOBALS['dbi']->numRows() in mysqli
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLE STATUS FROM ' . PMA_Util::backquote($db)
|
||||
. ' LIKE \'' . PMA_Util::sqlAddSlashes($table, true) . '\'',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if ($result != false) {
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
$tmpres = PMA_DBI_fetchAssoc($result);
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
$tmpres = $GLOBALS['dbi']->fetchAssoc($result);
|
||||
if (PMA_DRIZZLE && $show_dates) {
|
||||
// Drizzle doesn't give Create_time and Update_time in
|
||||
// SHOW TABLE STATUS, add it
|
||||
@ -924,7 +925,7 @@ class ExportSql extends ExportPlugin
|
||||
. PMA_Util::sqlAddSlashes($db) . "'
|
||||
AND TABLE_NAME = '"
|
||||
. PMA_Util::sqlAddSlashes($table) . "'";
|
||||
$tmpres = array_merge(PMA_DBI_fetchSingleRow($sql), $tmpres);
|
||||
$tmpres = array_merge($GLOBALS['dbi']->fetchSingleRow($sql), $tmpres);
|
||||
}
|
||||
// Here we optionally add the AUTO_INCREMENT next value,
|
||||
// but starting with MySQL 5.0.24, the clause is already included
|
||||
@ -977,7 +978,7 @@ class ExportSql extends ExportPlugin
|
||||
$new_crlf = $this->_exportComment() . $crlf;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
$schema_create .= $new_crlf;
|
||||
@ -994,9 +995,9 @@ class ExportSql extends ExportPlugin
|
||||
// Drizzle always quotes names
|
||||
if (! PMA_DRIZZLE) {
|
||||
if ($sql_backquotes) {
|
||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||
$GLOBALS['dbi']->query('SET SQL_QUOTE_SHOW_CREATE = 1');
|
||||
} else {
|
||||
PMA_DBI_query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||
$GLOBALS['dbi']->query('SET SQL_QUOTE_SHOW_CREATE = 0');
|
||||
}
|
||||
}
|
||||
|
||||
@ -1004,23 +1005,23 @@ class ExportSql extends ExportPlugin
|
||||
// because SHOW CREATE TABLE returns only one row, and we free the
|
||||
// results below. Nonetheless, we got 2 user reports about this
|
||||
// (see bug 1562533) so I removed the unbuffered mode.
|
||||
// $result = PMA_DBI_query('SHOW CREATE TABLE ' . backquote($db)
|
||||
// . '.' . backquote($table), null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
// $result = $GLOBALS['dbi']->query('SHOW CREATE TABLE ' . backquote($db)
|
||||
// . '.' . backquote($table), null, PMA_DatabaseInterface::QUERY_UNBUFFERED);
|
||||
//
|
||||
// Note: SHOW CREATE TABLE, at least in MySQL 5.1.23, does not
|
||||
// produce a displayable result for the default value of a BIT
|
||||
// column, nor does the mysqldump command. See MySQL bug 35796
|
||||
$result = PMA_DBI_tryQuery(
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table)
|
||||
);
|
||||
// an error can happen, for example the table is crashed
|
||||
$tmp_error = PMA_DBI_getError();
|
||||
$tmp_error = $GLOBALS['dbi']->getError();
|
||||
if ($tmp_error) {
|
||||
return $this->_exportComment(__('in use') . '(' . $tmp_error . ')');
|
||||
}
|
||||
|
||||
if ($result != false && ($row = PMA_DBI_fetchRow($result))) {
|
||||
if ($result != false && ($row = $GLOBALS['dbi']->fetchRow($result))) {
|
||||
$create_query = $row[1];
|
||||
unset($row);
|
||||
|
||||
@ -1295,7 +1296,7 @@ class ExportSql extends ExportPlugin
|
||||
|
||||
$schema_create .= ($compat != 'MSSQL') ? $auto_increment : '';
|
||||
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
return $schema_create . ($add_semicolon ? ';' . $crlf : '');
|
||||
} // end of the 'getTableDef()' function
|
||||
|
||||
@ -1460,7 +1461,7 @@ class ExportSql extends ExportPlugin
|
||||
break;
|
||||
case 'triggers':
|
||||
$dump = '';
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
if ($triggers) {
|
||||
$dump .= $this->_possibleCRLF()
|
||||
. $this->_exportComment()
|
||||
@ -1557,9 +1558,11 @@ class ExportSql extends ExportPlugin
|
||||
// are used, we did not get the true column name in case of aliases)
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
|
||||
|
||||
$result = PMA_DBI_tryQuery($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
// a possible error: the table has crashed
|
||||
$tmp_error = PMA_DBI_getError();
|
||||
$tmp_error = $GLOBALS['dbi']->getError();
|
||||
if ($tmp_error) {
|
||||
return PMA_exportOutputHandler(
|
||||
$this->_exportComment(
|
||||
@ -1569,13 +1572,13 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
|
||||
if ($result != false) {
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
// Get field information
|
||||
$fields_meta = PMA_DBI_getFieldsMeta($result);
|
||||
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
|
||||
$field_flags = array();
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
$field_flags[$j] = PMA_DBI_fieldFlags($result, $j);
|
||||
$field_flags[$j] = $GLOBALS['dbi']->fieldFlags($result, $j);
|
||||
}
|
||||
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
@ -1697,7 +1700,7 @@ class ExportSql extends ExportPlugin
|
||||
$separator = ';';
|
||||
}
|
||||
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
if ($current_row == 0) {
|
||||
$head = $this->_possibleCRLF()
|
||||
. $this->_exportComment()
|
||||
@ -1869,7 +1872,7 @@ class ExportSql extends ExportPlugin
|
||||
}
|
||||
}
|
||||
} // end if ($result != false)
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
return true;
|
||||
} // end of the 'exportData()' function
|
||||
|
||||
@ -188,8 +188,10 @@ class ExportTexytext extends ExportPlugin
|
||||
}
|
||||
|
||||
// Gets the data from the database
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$fields_cnt = PMA_DBI_numFields($result);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$fields_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
|
||||
// If required, get fields name at the first line
|
||||
if (isset($GLOBALS[$what . '_columns'])) {
|
||||
@ -197,7 +199,7 @@ class ExportTexytext extends ExportPlugin
|
||||
for ($i = 0; $i < $fields_cnt; $i++) {
|
||||
$text_output .= '|'
|
||||
. htmlspecialchars(
|
||||
stripslashes(PMA_DBI_fieldName($result, $i))
|
||||
stripslashes($GLOBALS['dbi']->fieldName($result, $i))
|
||||
);
|
||||
} // end for
|
||||
$text_output .= "\n|------\n";
|
||||
@ -207,7 +209,7 @@ class ExportTexytext extends ExportPlugin
|
||||
} // end if
|
||||
|
||||
// Format the data
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$text_output = '';
|
||||
for ($j = 0; $j < $fields_cnt; $j++) {
|
||||
if (! isset($row[$j]) || is_null($row[$j])) {
|
||||
@ -227,7 +229,7 @@ class ExportTexytext extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -249,7 +251,7 @@ class ExportTexytext extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$unique_keys = array();
|
||||
$keys = PMA_DBI_getTableIndexes($db, $view);
|
||||
$keys = $GLOBALS['dbi']->getTableIndexes($db, $view);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] == 0) {
|
||||
$unique_keys[] = $key['Column_name'];
|
||||
@ -259,7 +261,7 @@ class ExportTexytext extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
/**
|
||||
* Displays the table structure
|
||||
@ -272,7 +274,7 @@ class ExportTexytext extends ExportPlugin
|
||||
. '|' . __('Default')
|
||||
. "\n|------\n";
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $view);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $view);
|
||||
foreach ($columns as $column) {
|
||||
$text_output .= $this->formatOneColumnDefinition($column, $unique_keys);
|
||||
$text_output .= "\n";
|
||||
@ -323,7 +325,7 @@ class ExportTexytext extends ExportPlugin
|
||||
* Get the unique keys in the table
|
||||
*/
|
||||
$unique_keys = array();
|
||||
$keys = PMA_DBI_getTableIndexes($db, $table);
|
||||
$keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
|
||||
foreach ($keys as $key) {
|
||||
if ($key['Non_unique'] == 0) {
|
||||
$unique_keys[] = $key['Column_name'];
|
||||
@ -333,7 +335,7 @@ class ExportTexytext extends ExportPlugin
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
// Check if we can use Relations
|
||||
if ($do_relation && ! empty($cfgRelation['relation'])) {
|
||||
@ -383,7 +385,7 @@ class ExportTexytext extends ExportPlugin
|
||||
}
|
||||
$text_output .= "\n|------\n";
|
||||
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
foreach ($columns as $column) {
|
||||
$text_output .= $this->formatOneColumnDefinition($column, $unique_keys);
|
||||
$field_name = $column['Field'];
|
||||
@ -437,7 +439,7 @@ class ExportTexytext extends ExportPlugin
|
||||
$dump .= '|' . __('Definition');
|
||||
$dump .= "\n|------\n";
|
||||
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
|
||||
foreach ($triggers as $trigger) {
|
||||
$dump .= '|' . $trigger['name'];
|
||||
@ -501,7 +503,7 @@ class ExportTexytext extends ExportPlugin
|
||||
break;
|
||||
case 'triggers':
|
||||
$dump = '';
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
if ($triggers) {
|
||||
$dump .= '== ' . __('Triggers') . ' ' .$table . "\n\n";
|
||||
$dump .= $this->getTriggers($db, $table);
|
||||
|
||||
@ -207,7 +207,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
if ($export_struct) {
|
||||
if (PMA_DRIZZLE) {
|
||||
$result = PMA_DBI_fetchResult(
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT
|
||||
'utf8' AS DEFAULT_CHARACTER_SET_NAME,
|
||||
DEFAULT_COLLATION_NAME
|
||||
@ -216,7 +216,7 @@ class ExportXml extends ExportPlugin
|
||||
. PMA_Util::sqlAddSlashes($db) . "'"
|
||||
);
|
||||
} else {
|
||||
$result = PMA_DBI_fetchResult(
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
'SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`'
|
||||
. ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`'
|
||||
. ' = \''.PMA_Util::sqlAddSlashes($db).'\' LIMIT 1'
|
||||
@ -239,7 +239,7 @@ class ExportXml extends ExportPlugin
|
||||
|
||||
foreach ($tables as $table) {
|
||||
// Export tables and views
|
||||
$result = PMA_DBI_fetchResult(
|
||||
$result = $GLOBALS['dbi']->fetchResult(
|
||||
'SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.'
|
||||
. PMA_Util::backquote($table),
|
||||
0
|
||||
@ -275,7 +275,7 @@ class ExportXml extends ExportPlugin
|
||||
&& $GLOBALS['xml_export_triggers']
|
||||
) {
|
||||
// Export triggers
|
||||
$triggers = PMA_DBI_getTriggers($db, $table);
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
if ($triggers) {
|
||||
foreach ($triggers as $trigger) {
|
||||
$code = $trigger['create'];
|
||||
@ -301,14 +301,14 @@ class ExportXml extends ExportPlugin
|
||||
&& $GLOBALS['xml_export_functions']
|
||||
) {
|
||||
// Export functions
|
||||
$functions = PMA_DBI_getProceduresOrFunctions($db, 'FUNCTION');
|
||||
$functions = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'FUNCTION');
|
||||
if ($functions) {
|
||||
foreach ($functions as $function) {
|
||||
$head .= ' <pma:function name="'
|
||||
. $function . '">' . $crlf;
|
||||
|
||||
// Do some formatting
|
||||
$sql = PMA_DBI_getDefinition($db, 'FUNCTION', $function);
|
||||
$sql = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $function);
|
||||
$sql = rtrim($sql);
|
||||
$sql = " " . htmlspecialchars($sql);
|
||||
$sql = str_replace("\n", "\n ", $sql);
|
||||
@ -326,14 +326,14 @@ class ExportXml extends ExportPlugin
|
||||
&& $GLOBALS['xml_export_procedures']
|
||||
) {
|
||||
// Export procedures
|
||||
$procedures = PMA_DBI_getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
$procedures = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'PROCEDURE');
|
||||
if ($procedures) {
|
||||
foreach ($procedures as $procedure) {
|
||||
$head .= ' <pma:procedure name="'
|
||||
. $procedure . '">' . $crlf;
|
||||
|
||||
// Do some formatting
|
||||
$sql = PMA_DBI_getDefinition($db, 'PROCEDURE', $procedure);
|
||||
$sql = $GLOBALS['dbi']->getDefinition($db, 'PROCEDURE', $procedure);
|
||||
$sql = rtrim($sql);
|
||||
$sql = " " . htmlspecialchars($sql);
|
||||
$sql = str_replace("\n", "\n ", $sql);
|
||||
@ -445,12 +445,14 @@ class ExportXml extends ExportPlugin
|
||||
if (isset($GLOBALS['xml_export_contents'])
|
||||
&& $GLOBALS['xml_export_contents']
|
||||
) {
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
|
||||
$columns_cnt = PMA_DBI_numFields($result);
|
||||
$columns_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
$columns = array();
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$columns[$i] = stripslashes(PMA_DBI_fieldName($result, $i));
|
||||
$columns[$i] = stripslashes($GLOBALS['dbi']->fieldName($result, $i));
|
||||
}
|
||||
unset($i);
|
||||
|
||||
@ -459,7 +461,7 @@ class ExportXml extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
|
||||
while ($record = PMA_DBI_fetchRow($result)) {
|
||||
while ($record = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$buffer = ' <table name="'
|
||||
. htmlspecialchars($table) . '">' . $crlf;
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
@ -479,7 +481,7 @@ class ExportXml extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
||||
@ -156,17 +156,19 @@ class ExportYaml extends ExportPlugin
|
||||
*/
|
||||
public function exportData($db, $table, $crlf, $error_url, $sql_query)
|
||||
{
|
||||
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql_query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
|
||||
$columns_cnt = PMA_DBI_numFields($result);
|
||||
$columns_cnt = $GLOBALS['dbi']->numFields($result);
|
||||
for ($i = 0; $i < $columns_cnt; $i++) {
|
||||
$columns[$i] = stripslashes(PMA_DBI_fieldName($result, $i));
|
||||
$columns[$i] = stripslashes($GLOBALS['dbi']->fieldName($result, $i));
|
||||
}
|
||||
unset($i);
|
||||
|
||||
$buffer = '';
|
||||
$record_cnt = 0;
|
||||
while ($record = PMA_DBI_fetchRow($result)) {
|
||||
while ($record = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$record_cnt++;
|
||||
|
||||
// Output table name as comment if this is the first record of the table
|
||||
@ -206,7 +208,7 @@ class ExportYaml extends ExportPlugin
|
||||
return false;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
return true;
|
||||
} // end getTableYAML
|
||||
|
||||
@ -178,7 +178,7 @@ class PMA_ExportPdf extends PMA_PDF
|
||||
$tmpheight = array();
|
||||
$maxpage = $this->page;
|
||||
|
||||
while ($data = PMA_DBI_fetchRow($this->results)) {
|
||||
while ($data = $GLOBALS['dbi']->fetchRow($this->results)) {
|
||||
$this->page = $currpage;
|
||||
// write the horizontal borders
|
||||
$this->Line($l, $h, $fullwidth+$l, $h);
|
||||
@ -277,9 +277,11 @@ class PMA_ExportPdf extends PMA_PDF
|
||||
/**
|
||||
* Pass 1 for column widths
|
||||
*/
|
||||
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$this->numFields = PMA_DBI_numFields($this->results);
|
||||
$this->fields = PMA_DBI_getFieldsMeta($this->results);
|
||||
$this->results = $GLOBALS['dbi']->query(
|
||||
$query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED
|
||||
);
|
||||
$this->numFields = $GLOBALS['dbi']->numFields($this->results);
|
||||
$this->fields = $GLOBALS['dbi']->getFieldsMeta($this->results);
|
||||
|
||||
// sColWidth = starting col width (an average size width)
|
||||
$availableWidth = $this->w - $this->lMargin - $this->rMargin;
|
||||
@ -345,7 +347,7 @@ class PMA_ExportPdf extends PMA_PDF
|
||||
/**
|
||||
* @todo force here a LIMIT to avoid reading all rows
|
||||
*/
|
||||
while ($row = PMA_DBI_fetchRow($this->results)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($this->results)) {
|
||||
foreach ($colFits as $key => $val) {
|
||||
$stringWidth = $this->getstringwidth($row[$key]) + 6 ;
|
||||
if ($adjustingMode && ($stringWidth > $this->sColWidth)) {
|
||||
@ -391,16 +393,16 @@ class PMA_ExportPdf extends PMA_PDF
|
||||
|
||||
ksort($this->tablewidths);
|
||||
|
||||
PMA_DBI_freeResult($this->results);
|
||||
$GLOBALS['dbi']->freeResult($this->results);
|
||||
|
||||
// Pass 2
|
||||
|
||||
$this->results = PMA_DBI_query($query, null, PMA_DBI_QUERY_UNBUFFERED);
|
||||
$this->results = $GLOBALS['dbi']->query($query, null, PMA_DatabaseInterface::QUERY_UNBUFFERED);
|
||||
$this->setY($this->tMargin);
|
||||
$this->AddPage();
|
||||
$this->SetFont(PMA_PDF_FONT, '', 9);
|
||||
$this->morepagestable($this->FontSizePt);
|
||||
PMA_DBI_freeResult($this->results);
|
||||
$GLOBALS['dbi']->freeResult($this->results);
|
||||
|
||||
} // end of mysqlReport function
|
||||
|
||||
|
||||
@ -186,7 +186,7 @@ class ImportCsv extends AbstractImportCsv
|
||||
}
|
||||
$sql_template .= ' INTO ' . PMA_Util::backquote($table);
|
||||
|
||||
$tmp_fields = PMA_DBI_getColumns($db, $table);
|
||||
$tmp_fields = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
|
||||
if (empty($csv_columns)) {
|
||||
$fields = $tmp_fields;
|
||||
@ -503,7 +503,7 @@ class ImportCsv extends AbstractImportCsv
|
||||
}
|
||||
|
||||
if (strlen($db)) {
|
||||
$result = PMA_DBI_fetchResult('SHOW TABLES');
|
||||
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
|
||||
$tbl_name = 'TABLE '.(count($result) + 1);
|
||||
} else {
|
||||
$tbl_name = 'TBL_NAME';
|
||||
|
||||
@ -46,14 +46,14 @@ class ImportLdi extends AbstractImportCsv
|
||||
if ($GLOBALS['cfg']['Import']['ldi_local_option'] == 'auto') {
|
||||
$GLOBALS['cfg']['Import']['ldi_local_option'] = false;
|
||||
|
||||
$result = PMA_DBI_tryQuery('SHOW VARIABLES LIKE \'local\\_infile\';');
|
||||
if ($result != false && PMA_DBI_numRows($result) > 0) {
|
||||
$tmp = PMA_DBI_fetchRow($result);
|
||||
$result = $GLOBALS['dbi']->tryQuery('SHOW VARIABLES LIKE \'local\\_infile\';');
|
||||
if ($result != false && $GLOBALS['dbi']->numRows($result) > 0) {
|
||||
$tmp = $GLOBALS['dbi']->fetchRow($result);
|
||||
if ($tmp[1] == 'ON') {
|
||||
$GLOBALS['cfg']['Import']['ldi_local_option'] = true;
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
unset($result);
|
||||
}
|
||||
|
||||
|
||||
@ -358,7 +358,7 @@ class ImportMediawiki extends ImportPlugin
|
||||
private function _setTableName(&$table_name)
|
||||
{
|
||||
if (empty($table_name)) {
|
||||
$result = PMA_DBI_fetchResult('SHOW TABLES');
|
||||
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
|
||||
// todo check if the name below already exists
|
||||
$table_name = 'TABLE '.(count($result) + 1);
|
||||
}
|
||||
|
||||
@ -276,7 +276,7 @@ class ImportShp extends ImportPlugin
|
||||
|
||||
// Set table name based on the number of tables
|
||||
if (strlen($db)) {
|
||||
$result = PMA_DBI_fetchResult('SHOW TABLES');
|
||||
$result = $GLOBALS['dbi']->fetchResult('SHOW TABLES');
|
||||
$table_name = 'TABLE '.(count($result) + 1);
|
||||
} else {
|
||||
$table_name = 'TBL_NAME';
|
||||
|
||||
@ -49,7 +49,7 @@ class ImportSql extends ImportPlugin
|
||||
$importPluginProperties->setExtension('sql');
|
||||
$importPluginProperties->setOptionsText(__('Options'));
|
||||
|
||||
$compats = PMA_DBI_getCompatibilities();
|
||||
$compats = $GLOBALS['dbi']->getCompatibilities();
|
||||
if (count($compats) > 0) {
|
||||
$values = array();
|
||||
foreach ($compats as $val) {
|
||||
@ -152,7 +152,7 @@ class ImportSql extends ImportPlugin
|
||||
$sql_modes[] = 'NO_AUTO_VALUE_ON_ZERO';
|
||||
}
|
||||
if (count($sql_modes) > 0) {
|
||||
PMA_DBI_tryQuery('SET SQL_MODE="' . implode(',', $sql_modes) . '"');
|
||||
$GLOBALS['dbi']->tryQuery('SET SQL_MODE="' . implode(',', $sql_modes) . '"');
|
||||
}
|
||||
unset($sql_modes);
|
||||
|
||||
|
||||
@ -27,9 +27,9 @@ function get_tables_info()
|
||||
$GLOBALS['PMD']['OWNER'] = array();
|
||||
$GLOBALS['PMD']['TABLE_NAME_SMALL'] = array();
|
||||
|
||||
$tables = PMA_DBI_getTablesFull($GLOBALS['db']);
|
||||
$tables = $GLOBALS['dbi']->getTablesFull($GLOBALS['db']);
|
||||
// seems to be needed later
|
||||
PMA_DBI_selectDb($GLOBALS['db']);
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$i = 0;
|
||||
foreach ($tables as $one_table) {
|
||||
$GLOBALS['PMD']['TABLE_NAME'][$i]
|
||||
@ -73,22 +73,22 @@ function get_tables_info()
|
||||
*/
|
||||
function get_columns_info()
|
||||
{
|
||||
PMA_DBI_selectDb($GLOBALS['db']);
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$tab_column = array();
|
||||
for ($i = 0, $cnt = count($GLOBALS['PMD']["TABLE_NAME"]); $i < $cnt; $i++) {
|
||||
$fields_rs = PMA_DBI_query(
|
||||
PMA_DBI_getColumnsSql(
|
||||
$fields_rs = $GLOBALS['dbi']->query(
|
||||
$GLOBALS['dbi']->getColumnsSql(
|
||||
$GLOBALS['db'],
|
||||
$GLOBALS['PMD']["TABLE_NAME_SMALL"][$i],
|
||||
null,
|
||||
true
|
||||
),
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
$tbl_name_i = $GLOBALS['PMD']['TABLE_NAME'][$i];
|
||||
$j = 0;
|
||||
while ($row = PMA_DBI_fetchAssoc($fields_rs)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($fields_rs)) {
|
||||
$tab_column[$tbl_name_i]['COLUMN_ID'][$j] = $j;
|
||||
$tab_column[$tbl_name_i]['COLUMN_NAME'][$j] = $row['Field'];
|
||||
$tab_column[$tbl_name_i]['TYPE'][$j] = $row['Type'];
|
||||
@ -106,15 +106,15 @@ function get_columns_info()
|
||||
*/
|
||||
function get_script_contr()
|
||||
{
|
||||
PMA_DBI_selectDb($GLOBALS['db']);
|
||||
$GLOBALS['dbi']->selectDb($GLOBALS['db']);
|
||||
$con["C_NAME"] = array();
|
||||
$i = 0;
|
||||
$alltab_rs = PMA_DBI_query(
|
||||
$alltab_rs = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLES FROM ' . PMA_Util::backquote($GLOBALS['db']),
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
while ($val = @PMA_DBI_fetchRow($alltab_rs)) {
|
||||
while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) {
|
||||
$row = PMA_getForeigners($GLOBALS['db'], $val[0], '', 'internal');
|
||||
//echo "<br> internal ".$GLOBALS['db']." - ".$val[0]." - ";
|
||||
//print_r($row);
|
||||
@ -254,8 +254,12 @@ function get_tab_pos()
|
||||
`h` AS `H`
|
||||
FROM " . PMA_Util::backquote($cfgRelation['db'])
|
||||
. "." . PMA_Util::backquote($cfgRelation['designer_coords']);
|
||||
$tab_pos = PMA_DBI_fetchResult(
|
||||
$query, 'name', null, $GLOBALS['controllink'], PMA_DBI_QUERY_STORE
|
||||
$tab_pos = $GLOBALS['dbi']->fetchResult(
|
||||
$query,
|
||||
'name',
|
||||
null,
|
||||
$GLOBALS['controllink'],
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
return count($tab_pos) ? $tab_pos : null;
|
||||
}
|
||||
|
||||
@ -30,14 +30,14 @@ function PMA_queryAsControlUser($sql, $show_error = true, $options = 0)
|
||||
$cache_affected_rows = false;
|
||||
|
||||
if ($show_error) {
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
$sql,
|
||||
$GLOBALS['controllink'],
|
||||
$options,
|
||||
$cache_affected_rows
|
||||
);
|
||||
} else {
|
||||
$result = @PMA_DBI_tryQuery(
|
||||
$result = @$GLOBALS['dbi']->tryQuery(
|
||||
$sql,
|
||||
$GLOBALS['controllink'],
|
||||
$options,
|
||||
@ -365,7 +365,7 @@ function PMA_checkRelationsParam()
|
||||
|
||||
if ($GLOBALS['server'] == 0
|
||||
|| empty($GLOBALS['cfg']['Server']['pmadb'])
|
||||
|| ! PMA_DBI_selectDb($GLOBALS['cfg']['Server']['pmadb'], $GLOBALS['controllink'])
|
||||
|| ! $GLOBALS['dbi']->selectDb($GLOBALS['cfg']['Server']['pmadb'], $GLOBALS['controllink'])
|
||||
) {
|
||||
// No server selected -> no bookmark table
|
||||
// we return the array with the falses in it,
|
||||
@ -387,7 +387,9 @@ function PMA_checkRelationsParam()
|
||||
. PMA_Util::backquote(
|
||||
$GLOBALS['cfg']['Server']['pmadb']
|
||||
);
|
||||
$tab_rs = PMA_queryAsControlUser($tab_query, false, PMA_DBI_QUERY_STORE);
|
||||
$tab_rs = PMA_queryAsControlUser(
|
||||
$tab_query, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if (! $tab_rs) {
|
||||
// query failed ... ?
|
||||
@ -395,7 +397,7 @@ function PMA_checkRelationsParam()
|
||||
return $cfgRelation;
|
||||
}
|
||||
|
||||
while ($curr_table = @PMA_DBI_fetchRow($tab_rs)) {
|
||||
while ($curr_table = @$GLOBALS['dbi']->fetchRow($tab_rs)) {
|
||||
if ($curr_table[0] == $GLOBALS['cfg']['Server']['bookmarktable']) {
|
||||
$cfgRelation['bookmark'] = $curr_table[0];
|
||||
} elseif ($curr_table[0] == $GLOBALS['cfg']['Server']['relation']) {
|
||||
@ -422,7 +424,7 @@ function PMA_checkRelationsParam()
|
||||
$cfgRelation['userconfig'] = $curr_table[0];
|
||||
}
|
||||
} // end while
|
||||
PMA_DBI_freeResult($tab_rs);
|
||||
$GLOBALS['dbi']->freeResult($tab_rs);
|
||||
|
||||
if (isset($cfgRelation['relation'])) {
|
||||
$cfgRelation['relwork'] = true;
|
||||
@ -515,7 +517,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
|
||||
$rel_query .= ' AND `master_field` = '
|
||||
. '\'' . PMA_Util::sqlAddSlashes($column) . '\'';
|
||||
}
|
||||
$foreign = PMA_DBI_fetchResult(
|
||||
$foreign = $GLOBALS['dbi']->fetchResult(
|
||||
$rel_query, 'master_field', null, $GLOBALS['controllink']
|
||||
);
|
||||
}
|
||||
@ -524,7 +526,7 @@ function PMA_getForeigners($db, $table, $column = '', $source = 'both')
|
||||
|
||||
$show_create_table_query = 'SHOW CREATE TABLE '
|
||||
. PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table);
|
||||
$show_create_table = PMA_DBI_fetchValue($show_create_table_query, 0, 1);
|
||||
$show_create_table = $GLOBALS['dbi']->fetchValue($show_create_table_query, 0, 1);
|
||||
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
|
||||
|
||||
foreach ($analyzed_sql[0]['foreign_keys'] as $one_key) {
|
||||
@ -621,7 +623,7 @@ function PMA_getDisplayField($db, $table)
|
||||
WHERE `db_name` = \'' . PMA_Util::sqlAddSlashes($db) . '\'
|
||||
AND `table_name` = \'' . PMA_Util::sqlAddSlashes($table) . '\'';
|
||||
|
||||
$row = PMA_DBI_fetchSingleRow(
|
||||
$row = $GLOBALS['dbi']->fetchSingleRow(
|
||||
$disp_query, 'ASSOC', $GLOBALS['controllink']
|
||||
);
|
||||
if (isset($row['display_field'])) {
|
||||
@ -664,7 +666,7 @@ function PMA_getComments($db, $table = '')
|
||||
|
||||
if ($table != '') {
|
||||
// MySQL native column comments
|
||||
$columns = PMA_DBI_getColumns($db, $table, null, true);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table, null, true);
|
||||
if ($columns) {
|
||||
foreach ($columns as $column) {
|
||||
if (! empty($column['Comment'])) {
|
||||
@ -702,13 +704,15 @@ function PMA_getDbComment($db)
|
||||
WHERE db_name = '" . PMA_Util::sqlAddSlashes($db) . "'
|
||||
AND table_name = ''
|
||||
AND column_name = '(db_comment)'";
|
||||
$com_rs = PMA_queryAsControlUser($com_qry, true, PMA_DBI_QUERY_STORE);
|
||||
$com_rs = PMA_queryAsControlUser(
|
||||
$com_qry, true, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if ($com_rs && PMA_DBI_numRows($com_rs) > 0) {
|
||||
$row = PMA_DBI_fetchAssoc($com_rs);
|
||||
if ($com_rs && $GLOBALS['dbi']->numRows($com_rs) > 0) {
|
||||
$row = $GLOBALS['dbi']->fetchAssoc($com_rs);
|
||||
$comment = $row['comment'];
|
||||
}
|
||||
PMA_DBI_freeResult($com_rs);
|
||||
$GLOBALS['dbi']->freeResult($com_rs);
|
||||
}
|
||||
|
||||
return $comment;
|
||||
@ -733,14 +737,16 @@ function PMA_getDbComments()
|
||||
FROM " . PMA_Util::backquote($cfgRelation['db'])
|
||||
. "." . PMA_Util::backquote($cfgRelation['column_info']) . "
|
||||
WHERE `column_name` = '(db_comment)'";
|
||||
$com_rs = PMA_queryAsControlUser($com_qry, true, PMA_DBI_QUERY_STORE);
|
||||
$com_rs = PMA_queryAsControlUser(
|
||||
$com_qry, true, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if ($com_rs && PMA_DBI_numRows($com_rs) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($com_rs)) {
|
||||
if ($com_rs && $GLOBALS['dbi']->numRows($com_rs) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($com_rs)) {
|
||||
$comments[$row['db_name']] = $row['comment'];
|
||||
}
|
||||
}
|
||||
PMA_DBI_freeResult($com_rs);
|
||||
$GLOBALS['dbi']->freeResult($com_rs);
|
||||
}
|
||||
|
||||
return $comments;
|
||||
@ -884,7 +890,7 @@ function PMA_getHistory($username)
|
||||
WHERE `username` = \'' . PMA_Util::sqlAddSlashes($username) . '\'
|
||||
ORDER BY `id` DESC';
|
||||
|
||||
return PMA_DBI_fetchResult($hist_query, null, null, $GLOBALS['controllink']);
|
||||
return $GLOBALS['dbi']->fetchResult($hist_query, null, null, $GLOBALS['controllink']);
|
||||
} // end of 'PMA_getHistory()' function
|
||||
|
||||
/**
|
||||
@ -918,7 +924,7 @@ function PMA_purgeHistory($username)
|
||||
ORDER BY `timevalue` DESC
|
||||
LIMIT ' . $GLOBALS['cfg']['QueryHistoryMax'] . ', 1';
|
||||
|
||||
if ($max_time = PMA_DBI_fetchValue($search_query, 0, 0, $GLOBALS['controllink'])) {
|
||||
if ($max_time = $GLOBALS['dbi']->fetchValue($search_query, 0, 0, $GLOBALS['controllink'])) {
|
||||
PMA_queryAsControlUser(
|
||||
'DELETE FROM '
|
||||
. PMA_Util::backquote($cfgRelation['db']) . '.'
|
||||
@ -1136,31 +1142,31 @@ function PMA_getForeignData(
|
||||
$f_query_limit = isset($foreign_limit) ? $foreign_limit : '';
|
||||
|
||||
if (!empty($foreign_filter)) {
|
||||
$res = PMA_DBI_query(
|
||||
$res = $GLOBALS['dbi']->query(
|
||||
'SELECT COUNT(*)' . $f_query_from . $f_query_filter
|
||||
);
|
||||
if ($res) {
|
||||
$the_total = PMA_DBI_fetchValue($res);
|
||||
@PMA_DBI_freeResult($res);
|
||||
$the_total = $GLOBALS['dbi']->fetchValue($res);
|
||||
@$GLOBALS['dbi']->freeResult($res);
|
||||
} else {
|
||||
$the_total = 0;
|
||||
}
|
||||
}
|
||||
|
||||
$disp = PMA_DBI_query(
|
||||
$disp = $GLOBALS['dbi']->query(
|
||||
$f_query_main . $f_query_from . $f_query_filter
|
||||
. $f_query_order . $f_query_limit
|
||||
);
|
||||
if ($disp && PMA_DBI_numRows($disp) > 0) {
|
||||
if ($disp && $GLOBALS['dbi']->numRows($disp) > 0) {
|
||||
// If a resultset has been created, pre-cache it in the $disp_row
|
||||
// array. This helps us from not needing to use mysql_data_seek by
|
||||
// accessing a pre-cached PHP array. Usually those resultsets are
|
||||
// not that big, so a performance hit should not be expected.
|
||||
$disp_row = array();
|
||||
while ($single_disp_row = @PMA_DBI_fetchAssoc($disp)) {
|
||||
while ($single_disp_row = @$GLOBALS['dbi']->fetchAssoc($disp)) {
|
||||
$disp_row[] = $single_disp_row;
|
||||
}
|
||||
@PMA_DBI_freeResult($disp);
|
||||
@$GLOBALS['dbi']->freeResult($disp);
|
||||
}
|
||||
} else {
|
||||
$disp_row = null;
|
||||
@ -1216,8 +1222,8 @@ function PMA_getRelatives($all_tables, $master)
|
||||
. ' AND ' . $to . '_db = \'' . PMA_Util::sqlAddSlashes($GLOBALS['db']) . '\''
|
||||
. ' AND ' . $from . '_table IN ' . $in_know
|
||||
. ' AND ' . $to . '_table IN ' . $in_left;
|
||||
$relations = @PMA_DBI_query($rel_query, $GLOBALS['controllink']);
|
||||
while ($row = PMA_DBI_fetchAssoc($relations)) {
|
||||
$relations = @$GLOBALS['dbi']->query($rel_query, $GLOBALS['controllink']);
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($relations)) {
|
||||
$found_table = $row[$to . '_table'];
|
||||
if (isset($remaining_tables[$found_table])) {
|
||||
$fromclause
|
||||
@ -1426,7 +1432,7 @@ function PMA_REL_createPage($newpage, $cfgRelation, $db)
|
||||
. PMA_Util::sqlAddSlashes($newpage) . '\')';
|
||||
PMA_queryAsControlUser($ins_query, false);
|
||||
|
||||
return PMA_DBI_insertId(
|
||||
return $GLOBALS['dbi']->insertId(
|
||||
isset($GLOBALS['controllink']) ? $GLOBALS['controllink'] : ''
|
||||
);
|
||||
}
|
||||
|
||||
@ -13,12 +13,12 @@ if (! defined('PHPMYADMIN')) {
|
||||
/**
|
||||
* get master replication from server
|
||||
*/
|
||||
$server_master_replication = PMA_DBI_fetchResult('SHOW MASTER STATUS');
|
||||
$server_master_replication = $GLOBALS['dbi']->fetchResult('SHOW MASTER STATUS');
|
||||
|
||||
/**
|
||||
* get slave replication from server
|
||||
*/
|
||||
$server_slave_replication = PMA_DBI_fetchResult('SHOW SLAVE STATUS');
|
||||
$server_slave_replication = $GLOBALS['dbi']->fetchResult('SHOW SLAVE STATUS');
|
||||
|
||||
/**
|
||||
* replication types
|
||||
@ -185,7 +185,7 @@ function PMA_extractDbOrTable($string, $what = 'db')
|
||||
* SQL_THREAD and IO_THREAD
|
||||
* @param mixed $link mysql link
|
||||
*
|
||||
* @return mixed output of PMA_DBI_tryQuery
|
||||
* @return mixed output of DatabaseInterface::tryQuery
|
||||
*/
|
||||
function PMA_Replication_Slave_control($action, $control = null, $link = null)
|
||||
{
|
||||
@ -199,7 +199,7 @@ function PMA_Replication_Slave_control($action, $control = null, $link = null)
|
||||
return -1;
|
||||
}
|
||||
|
||||
return PMA_DBI_tryQuery($action . " SLAVE " . $control . ";", $link);
|
||||
return $GLOBALS['dbi']->tryQuery($action . " SLAVE " . $control . ";", $link);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -224,7 +224,7 @@ function PMA_Replication_Slave_changeMaster($user, $password, $host, $port,
|
||||
PMA_Replication_Slave_control("STOP", null, $link);
|
||||
}
|
||||
|
||||
$out = PMA_DBI_tryQuery(
|
||||
$out = $GLOBALS['dbi']->tryQuery(
|
||||
'CHANGE MASTER TO ' .
|
||||
'MASTER_HOST=\'' . $host . '\',' .
|
||||
'MASTER_PORT=' . ($port * 1) . ',' .
|
||||
@ -262,7 +262,7 @@ function PMA_Replication_connectToMaster(
|
||||
|
||||
// 5th parameter set to true means that it's an auxiliary connection
|
||||
// and we must not go back to login page if it fails
|
||||
return PMA_DBI_connect($user, $password, false, $server, true);
|
||||
return $GLOBALS['dbi']->connect($user, $password, false, $server, true);
|
||||
}
|
||||
/**
|
||||
* Fetches position and file of current binary log on master
|
||||
@ -274,7 +274,7 @@ function PMA_Replication_connectToMaster(
|
||||
*/
|
||||
function PMA_Replication_Slave_binLogMaster($link = null)
|
||||
{
|
||||
$data = PMA_DBI_fetchResult('SHOW MASTER STATUS', null, null, $link);
|
||||
$data = $GLOBALS['dbi']->fetchResult('SHOW MASTER STATUS', null, null, $link);
|
||||
$output = array();
|
||||
|
||||
if (! empty($data)) {
|
||||
@ -295,7 +295,7 @@ function PMA_Replication_Slave_binLogMaster($link = null)
|
||||
function PMA_Replication_Master_getReplicatedDbs($link = null)
|
||||
{
|
||||
// let's find out, which databases are replicated
|
||||
$data = PMA_DBI_fetchResult('SHOW MASTER STATUS', null, null, $link);
|
||||
$data = $GLOBALS['dbi']->fetchResult('SHOW MASTER STATUS', null, null, $link);
|
||||
|
||||
$do_db = array();
|
||||
$ignore_db = array();
|
||||
@ -307,9 +307,9 @@ function PMA_Replication_Master_getReplicatedDbs($link = null)
|
||||
$ignore_db = explode(',', $data[0]['Binlog_Ignore_DB']);
|
||||
}
|
||||
|
||||
$tmp_alldbs = PMA_DBI_query('SHOW DATABASES;', $link);
|
||||
while ($tmp_row = PMA_DBI_fetchRow($tmp_alldbs)) {
|
||||
if (PMA_isSystemSchema($tmp_row[0])) {
|
||||
$tmp_alldbs = $GLOBALS['dbi']->query('SHOW DATABASES;', $link);
|
||||
while ($tmp_row = $GLOBALS['dbi']->fetchRow($tmp_alldbs)) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($tmp_row[0])) {
|
||||
continue;
|
||||
}
|
||||
if (count($do_db) == 0) {
|
||||
|
||||
@ -19,7 +19,7 @@ function PMA_replication_db_multibox()
|
||||
$multi_values .= '<select name="db_select[]" size="6" multiple="multiple" id="db_select">';
|
||||
|
||||
foreach ($GLOBALS['pma']->databases as $current_db) {
|
||||
if (PMA_isSystemSchema($current_db)) {
|
||||
if ($GLOBALS['dbi']->isSystemSchema($current_db)) {
|
||||
continue;
|
||||
}
|
||||
if (! empty($selectall) || (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $current_db . '|'))) {
|
||||
@ -103,7 +103,7 @@ function PMA_replication_print_status_table($type, $hidden = false, $title = tru
|
||||
// [ERROR] Error reading packet from server: Misconfigured master - server id was not set ( server_errno=1236)
|
||||
// [ERROR] Got fatal error 1236: 'Misconfigured master - server id was not set' from master when reading data from binary log
|
||||
//
|
||||
//$server_id = PMA_DBI_fetchValue("SHOW VARIABLES LIKE 'server_id'", 0, 1);
|
||||
//$server_id = $GLOBALS['dbi']->fetchValue("SHOW VARIABLES LIKE 'server_id'", 0, 1);
|
||||
|
||||
echo '<div id="replication_' . $type . '_section" style="' . ($hidden ? 'display: none;' : '') . '"> ';
|
||||
|
||||
@ -184,7 +184,7 @@ function PMA_replication_print_slaves_table($hidden = false)
|
||||
{
|
||||
|
||||
// Fetch data
|
||||
$data = PMA_DBI_fetchResult('SHOW SLAVE HOSTS', null, null);
|
||||
$data = $GLOBALS['dbi']->fetchResult('SHOW SLAVE HOSTS', null, null);
|
||||
|
||||
echo ' <br />';
|
||||
echo ' <div id="replication_slaves_section" style="' . ($hidden ? 'display: none;' : '') . '"> ';
|
||||
@ -223,7 +223,7 @@ function PMA_replication_print_slaves_table($hidden = false)
|
||||
|
||||
function PMA_replication_get_username_hostname_length()
|
||||
{
|
||||
$fields_info = PMA_DBI_getColumns('mysql', 'user');
|
||||
$fields_info = $GLOBALS['dbi']->getColumns('mysql', 'user');
|
||||
$username_length = 16;
|
||||
$hostname_length = 41;
|
||||
foreach ($fields_info as $val) {
|
||||
@ -294,7 +294,7 @@ function PMA_replication_gui_master_addslaveuser()
|
||||
. '</label>'
|
||||
. '<span class="options">'
|
||||
. ' <select name="pred_hostname" id="select_pred_hostname" title="' . __('Host') . '"';
|
||||
$_current_user = PMA_DBI_fetchValue('SELECT USER();');
|
||||
$_current_user = $GLOBALS['dbi']->fetchValue('SELECT USER();');
|
||||
if (! empty($_current_user)) {
|
||||
$thishost = str_replace("'", '', substr($_current_user, (strrpos($_current_user, '@') + 1)));
|
||||
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
|
||||
|
||||
@ -67,7 +67,7 @@ function PMA_EVN_main()
|
||||
$where = "EVENT_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "'";
|
||||
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` "
|
||||
. "WHERE $where ORDER BY `EVENT_NAME` ASC;";
|
||||
$items = PMA_DBI_fetchResult($query);
|
||||
$items = $GLOBALS['dbi']->fetchResult($query);
|
||||
echo PMA_RTE_getList('event', $items);
|
||||
/**
|
||||
* Display a link for adding a new event, if
|
||||
@ -97,33 +97,33 @@ function PMA_EVN_handleEditor()
|
||||
// Execute the created query
|
||||
if (! empty($_REQUEST['editor_process_edit'])) {
|
||||
// Backup the old trigger, in case something goes wrong
|
||||
$create_item = PMA_DBI_getDefinition(
|
||||
$create_item = $GLOBALS['dbi']->getDefinition(
|
||||
$db,
|
||||
'EVENT',
|
||||
$_REQUEST['item_original_name']
|
||||
);
|
||||
$drop_item = "DROP EVENT "
|
||||
. PMA_Util::backquote($_REQUEST['item_original_name']) . ";\n";
|
||||
$result = PMA_DBI_tryQuery($drop_item);
|
||||
$result = $GLOBALS['dbi']->tryQuery($drop_item);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($drop_item)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$result = PMA_DBI_tryQuery($item_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($item_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($item_query)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
// We dropped the old item, but were unable to create
|
||||
// the new one. Try to restore the backup query
|
||||
$result = PMA_DBI_tryQuery($create_item);
|
||||
$result = $GLOBALS['dbi']->tryQuery($create_item);
|
||||
if (! $result) {
|
||||
// OMG, this is really bad! We dropped the query,
|
||||
// failed to create a new one
|
||||
@ -137,7 +137,7 @@ function PMA_EVN_handleEditor()
|
||||
. __('The backed up query was:')
|
||||
. "\"" . htmlspecialchars($create_item) . "\""
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
}
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
@ -151,14 +151,14 @@ function PMA_EVN_handleEditor()
|
||||
}
|
||||
} else {
|
||||
// 'Add a new item' mode
|
||||
$result = PMA_DBI_tryQuery($item_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($item_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($item_query)
|
||||
)
|
||||
. '<br /><br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
__('Event %1$s has been created.')
|
||||
@ -190,7 +190,7 @@ function PMA_EVN_handleEditor()
|
||||
. PMA_Util::sqlAddSlashes($_REQUEST['item_name']) . "'";
|
||||
$query = "SELECT " . $columns
|
||||
. " FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE " . $where. ";";
|
||||
$event = PMA_DBI_fetchSingleRow($query);
|
||||
$event = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
$response->addJSON(
|
||||
'name',
|
||||
htmlspecialchars(strtoupper($_REQUEST['item_name']))
|
||||
@ -322,7 +322,7 @@ function PMA_EVN_getDataFromName($name)
|
||||
$where = "EVENT_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "' "
|
||||
. "AND EVENT_NAME='" . PMA_Util::sqlAddSlashes($name) . "'";
|
||||
$query = "SELECT $columns FROM `INFORMATION_SCHEMA`.`EVENTS` WHERE $where;";
|
||||
$item = PMA_DBI_fetchSingleRow($query);
|
||||
$item = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
if (! $item) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@ -66,7 +66,7 @@ function PMA_EVN_handleExport()
|
||||
|
||||
if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
|
||||
$item_name = $_GET['item_name'];
|
||||
$export_data = PMA_DBI_getDefinition($db, 'EVENT', $item_name);
|
||||
$export_data = $GLOBALS['dbi']->getDefinition($db, 'EVENT', $item_name);
|
||||
PMA_RTE_handleExport($item_name, $export_data);
|
||||
}
|
||||
} // end PMA_EVN_handleExport()
|
||||
@ -86,7 +86,7 @@ function PMA_RTN_handleExport()
|
||||
&& ! empty($_GET['item_type'])
|
||||
) {
|
||||
if ($_GET['item_type'] == 'FUNCTION' || $_GET['item_type'] == 'PROCEDURE') {
|
||||
$export_data = PMA_DBI_getDefinition(
|
||||
$export_data = $GLOBALS['dbi']->getDefinition(
|
||||
$db,
|
||||
$_GET['item_type'],
|
||||
$_GET['item_name']
|
||||
@ -108,7 +108,7 @@ function PMA_TRI_handleExport()
|
||||
|
||||
if (! empty($_GET['export_item']) && ! empty($_GET['item_name'])) {
|
||||
$item_name = $_GET['item_name'];
|
||||
$triggers = PMA_DBI_getTriggers($db, $table, '');
|
||||
$triggers = $GLOBALS['dbi']->getTriggers($db, $table, '');
|
||||
$export_data = false;
|
||||
foreach ($triggers as $trigger) {
|
||||
if ($trigger['name'] === $item_name) {
|
||||
|
||||
@ -80,7 +80,7 @@ function PMA_EVN_getFooterLinks()
|
||||
* a form for toggling the state of the event scheduler
|
||||
*/
|
||||
// Init options for the event scheduler toggle functionality
|
||||
$es_state = PMA_DBI_fetchValue(
|
||||
$es_state = $GLOBALS['dbi']->fetchValue(
|
||||
"SHOW GLOBAL VARIABLES LIKE 'event_scheduler'",
|
||||
0,
|
||||
1
|
||||
|
||||
@ -22,7 +22,7 @@ if ($GLOBALS['is_ajax_request'] != true) {
|
||||
/**
|
||||
* Displays the header and tabs
|
||||
*/
|
||||
if (! empty($table) && in_array($table, PMA_DBI_getTables($db))) {
|
||||
if (! empty($table) && in_array($table, $GLOBALS['dbi']->getTables($db))) {
|
||||
include_once './libraries/tbl_common.inc.php';
|
||||
} else {
|
||||
$table = '';
|
||||
@ -36,7 +36,7 @@ if ($GLOBALS['is_ajax_request'] != true) {
|
||||
* create the missing $url_query variable
|
||||
*/
|
||||
if (strlen($db)) {
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
if (! isset($url_query)) {
|
||||
$url_query = PMA_generate_common_url($db, $table);
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ function PMA_RTN_main()
|
||||
$columns = "`SPECIFIC_NAME`, `ROUTINE_NAME`, `ROUTINE_TYPE`, ";
|
||||
$columns .= "`DTD_IDENTIFIER`, `ROUTINE_DEFINITION`";
|
||||
$where = "ROUTINE_SCHEMA='" . PMA_Util::sqlAddSlashes($db) . "'";
|
||||
$items = PMA_DBI_fetchResult(
|
||||
$items = $GLOBALS['dbi']->fetchResult(
|
||||
"SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES` WHERE $where;"
|
||||
);
|
||||
echo PMA_RTE_getList('routine', $items);
|
||||
@ -283,34 +283,34 @@ function PMA_RTN_handleEditor()
|
||||
);
|
||||
} else {
|
||||
// Backup the old routine, in case something goes wrong
|
||||
$create_routine = PMA_DBI_getDefinition(
|
||||
$create_routine = $GLOBALS['dbi']->getDefinition(
|
||||
$db, $_REQUEST['item_original_type'],
|
||||
$_REQUEST['item_original_name']
|
||||
);
|
||||
$drop_routine = "DROP {$_REQUEST['item_original_type']} "
|
||||
. PMA_Util::backquote($_REQUEST['item_original_name'])
|
||||
. ";\n";
|
||||
$result = PMA_DBI_tryQuery($drop_routine);
|
||||
$result = $GLOBALS['dbi']->tryQuery($drop_routine);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($drop_routine)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$result = PMA_DBI_tryQuery($routine_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($routine_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($routine_query)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
// We dropped the old routine,
|
||||
// but were unable to create the new one
|
||||
// Try to restore the backup query
|
||||
$result = PMA_DBI_tryQuery($create_routine);
|
||||
$result = $GLOBALS['dbi']->tryQuery($create_routine);
|
||||
if (! $result) {
|
||||
// OMG, this is really bad! We dropped the query,
|
||||
// failed to create a new one
|
||||
@ -325,7 +325,7 @@ function PMA_RTN_handleEditor()
|
||||
. __('The backed up query was:')
|
||||
. "\"" . htmlspecialchars($create_routine) . "\""
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
}
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
@ -340,14 +340,14 @@ function PMA_RTN_handleEditor()
|
||||
}
|
||||
} else {
|
||||
// 'Add a new routine' mode
|
||||
$result = PMA_DBI_tryQuery($routine_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($routine_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($routine_query)
|
||||
)
|
||||
. '<br /><br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
__('Routine %1$s has been created.')
|
||||
@ -385,7 +385,7 @@ function PMA_RTN_handleEditor()
|
||||
. PMA_Util::sqlAddSlashes($_REQUEST['item_name']) . "'"
|
||||
. "AND ROUTINE_TYPE='"
|
||||
. PMA_Util::sqlAddSlashes($_REQUEST['item_type']) . "'";
|
||||
$routine = PMA_DBI_fetchSingleRow(
|
||||
$routine = $GLOBALS['dbi']->fetchSingleRow(
|
||||
"SELECT $columns FROM `INFORMATION_SCHEMA`.`ROUTINES`"
|
||||
. " WHERE $where;"
|
||||
);
|
||||
@ -618,7 +618,7 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
|
||||
. "AND ROUTINE_TYPE='" . PMA_Util::sqlAddSlashes($type) . "'";
|
||||
$query = "SELECT $fields FROM INFORMATION_SCHEMA.ROUTINES WHERE $where;";
|
||||
|
||||
$routine = PMA_DBI_fetchSingleRow($query);
|
||||
$routine = $GLOBALS['dbi']->fetchSingleRow($query);
|
||||
|
||||
if (! $routine) {
|
||||
return false;
|
||||
@ -628,7 +628,7 @@ function PMA_RTN_getDataFromName($name, $type, $all = true)
|
||||
$retval['item_name'] = $routine['SPECIFIC_NAME'];
|
||||
$retval['item_type'] = $routine['ROUTINE_TYPE'];
|
||||
$parsed_query = PMA_SQP_parse(
|
||||
PMA_DBI_getDefinition(
|
||||
$GLOBALS['dbi']->getDefinition(
|
||||
$db,
|
||||
$routine['ROUTINE_TYPE'],
|
||||
$routine['SPECIFIC_NAME']
|
||||
@ -1349,7 +1349,7 @@ function PMA_RTN_handleExecute()
|
||||
$affected = 0;
|
||||
|
||||
// Execute query
|
||||
if (! PMA_DBI_tryMultiQuery($multiple_query)) {
|
||||
if (! $GLOBALS['dbi']->tryMultiQuery($multiple_query)) {
|
||||
$outcome = false;
|
||||
}
|
||||
|
||||
@ -1376,13 +1376,13 @@ function PMA_RTN_handleExecute()
|
||||
|
||||
do {
|
||||
|
||||
$result = PMA_DBI_storeResult();
|
||||
$num_rows = PMA_DBI_numRows($result);
|
||||
$result = $GLOBALS['dbi']->storeResult();
|
||||
$num_rows = $GLOBALS['dbi']->numRows($result);
|
||||
|
||||
if (($result !== false) && ($num_rows > 0)) {
|
||||
|
||||
$output .= "<table><tr>";
|
||||
foreach (PMA_DBI_getFieldsMeta($result) as $key => $field) {
|
||||
foreach ($GLOBALS['dbi']->getFieldsMeta($result) as $key => $field) {
|
||||
$output .= "<th>";
|
||||
$output .= htmlspecialchars($field->name);
|
||||
$output .= "</th>";
|
||||
@ -1391,7 +1391,7 @@ function PMA_RTN_handleExecute()
|
||||
|
||||
$color_class = 'odd';
|
||||
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
$output .= "<tr>";
|
||||
foreach ($row as $key => $value) {
|
||||
if ($value === null) {
|
||||
@ -1412,15 +1412,15 @@ function PMA_RTN_handleExecute()
|
||||
|
||||
}
|
||||
|
||||
if (! PMA_DBI_moreResults()) {
|
||||
if (! $GLOBALS['dbi']->moreResults()) {
|
||||
break;
|
||||
}
|
||||
|
||||
$output .= "<br/>";
|
||||
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
|
||||
} while (PMA_DBI_nextResult());
|
||||
} while ($GLOBALS['dbi']->nextResult());
|
||||
|
||||
$output .= "</fieldset>";
|
||||
|
||||
@ -1456,7 +1456,7 @@ function PMA_RTN_handleExecute()
|
||||
htmlspecialchars($multiple_query)
|
||||
)
|
||||
. '<br /><br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null)
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null)
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@ -44,7 +44,7 @@ function PMA_TRI_main()
|
||||
/**
|
||||
* Display a list of available triggers
|
||||
*/
|
||||
$items = PMA_DBI_getTriggers($db, $table);
|
||||
$items = $GLOBALS['dbi']->getTriggers($db, $table);
|
||||
echo PMA_RTE_getList('trigger', $items);
|
||||
/**
|
||||
* Display a link for adding a new trigger,
|
||||
@ -76,26 +76,26 @@ function PMA_TRI_handleEditor()
|
||||
$trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']);
|
||||
$create_item = $trigger['create'];
|
||||
$drop_item = $trigger['drop'] . ';';
|
||||
$result = PMA_DBI_tryQuery($drop_item);
|
||||
$result = $GLOBALS['dbi']->tryQuery($drop_item);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($drop_item)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$result = PMA_DBI_tryQuery($item_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($item_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($item_query)
|
||||
)
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
// We dropped the old item, but were unable to create the
|
||||
// new one. Try to restore the backup query.
|
||||
$result = PMA_DBI_tryQuery($create_item);
|
||||
$result = $GLOBALS['dbi']->tryQuery($create_item);
|
||||
if (! $result) {
|
||||
// OMG, this is really bad! We dropped the query,
|
||||
// failed to create a new one
|
||||
@ -109,7 +109,7 @@ function PMA_TRI_handleEditor()
|
||||
. __('The backed up query was:')
|
||||
. "\"" . htmlspecialchars($create_item) . "\""
|
||||
. '<br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
}
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
@ -123,14 +123,14 @@ function PMA_TRI_handleEditor()
|
||||
}
|
||||
} else {
|
||||
// 'Add a new item' mode
|
||||
$result = PMA_DBI_tryQuery($item_query);
|
||||
$result = $GLOBALS['dbi']->tryQuery($item_query);
|
||||
if (! $result) {
|
||||
$errors[] = sprintf(
|
||||
__('The following query has failed: "%s"'),
|
||||
htmlspecialchars($item_query)
|
||||
)
|
||||
. '<br /><br />'
|
||||
. __('MySQL said: ') . PMA_DBI_getError(null);
|
||||
. __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
|
||||
} else {
|
||||
$message = PMA_Message::success(
|
||||
__('Trigger %1$s has been created.')
|
||||
@ -156,7 +156,7 @@ function PMA_TRI_handleEditor()
|
||||
if ($GLOBALS['is_ajax_request']) {
|
||||
$response = PMA_Response::getInstance();
|
||||
if ($message->isSuccess()) {
|
||||
$items = PMA_DBI_getTriggers($db, $table, '');
|
||||
$items = $GLOBALS['dbi']->getTriggers($db, $table, '');
|
||||
$trigger = false;
|
||||
foreach ($items as $value) {
|
||||
if ($value['name'] == $_REQUEST['item_name']) {
|
||||
@ -280,7 +280,7 @@ function PMA_TRI_getDataFromName($name)
|
||||
global $db, $table, $_REQUEST;
|
||||
|
||||
$temp = array();
|
||||
$items = PMA_DBI_getTriggers($db, $table, '');
|
||||
$items = $GLOBALS['dbi']->getTriggers($db, $table, '');
|
||||
foreach ($items as $value) {
|
||||
if ($value['name'] == $name) {
|
||||
$temp = $value;
|
||||
@ -334,7 +334,7 @@ function PMA_TRI_getEditorForm($mode, $item)
|
||||
$query = "SELECT `TABLE_NAME` FROM `INFORMATION_SCHEMA`.`TABLES` ";
|
||||
$query .= "WHERE `TABLE_SCHEMA`='" . PMA_Util::sqlAddSlashes($db) . "' ";
|
||||
$query .= "AND `TABLE_TYPE`='BASE TABLE'";
|
||||
$tables = PMA_DBI_fetchResult($query);
|
||||
$tables = $GLOBALS['dbi']->fetchResult($query);
|
||||
|
||||
// Create the output
|
||||
$retval = "";
|
||||
@ -467,7 +467,7 @@ function PMA_TRI_getQueryFromRequest()
|
||||
}
|
||||
$query .= 'ON ';
|
||||
if (! empty($_REQUEST['item_table'])
|
||||
&& in_array($_REQUEST['item_table'], PMA_DBI_getTables($db))
|
||||
&& in_array($_REQUEST['item_table'], $GLOBALS['dbi']->getTables($db))
|
||||
) {
|
||||
$query .= PMA_Util::backquote($_REQUEST['item_table']);
|
||||
} else {
|
||||
|
||||
@ -229,8 +229,10 @@ class Table_Stats
|
||||
|
||||
$this->tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
|
||||
$result = PMA_DBI_tryQuery($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$dia->dieSchema(
|
||||
$pageNumber, "DIA",
|
||||
sprintf(__('The %s table doesn\'t exist!'), $tableName)
|
||||
@ -251,7 +253,7 @@ class Table_Stats
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$this->fields[] = $row[0];
|
||||
}
|
||||
}
|
||||
@ -263,8 +265,10 @@ class Table_Stats
|
||||
. ' AND table_name = \''
|
||||
. PMA_Util::sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$dia->dieSchema(
|
||||
$pageNumber,
|
||||
"DIA",
|
||||
@ -274,7 +278,7 @@ class Table_Stats
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetchRow($result);
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
/*
|
||||
@ -284,13 +288,13 @@ class Table_Stats
|
||||
/*
|
||||
* index
|
||||
*/
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$this->primary[] = $row['Column_name'];
|
||||
}
|
||||
|
||||
@ -418,8 +418,10 @@ class Table_Stats
|
||||
|
||||
$this->_tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
|
||||
$result = PMA_DBI_tryQuery($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$eps->dieSchema(
|
||||
$pageNumber, "EPS",
|
||||
sprintf(__('The %s table doesn\'t exist!'), $tableName)
|
||||
@ -441,7 +443,7 @@ class Table_Stats
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$this->fields[] = $row[0];
|
||||
}
|
||||
}
|
||||
@ -465,9 +467,11 @@ class Table_Stats
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$eps->dieSchema(
|
||||
$pageNumber, "EPS",
|
||||
sprintf(
|
||||
@ -476,18 +480,18 @@ class Table_Stats
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetchRow($result);
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
// displayfield
|
||||
$this->displayfield = PMA_getDisplayField($db, $tableName);
|
||||
// index
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$this->primary[] = $row['Column_name'];
|
||||
}
|
||||
|
||||
@ -199,11 +199,13 @@ class PMA_Export_Relation_Schema
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
|
||||
$tab_rs = PMA_queryAsControlUser($tab_sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $tab_rs || ! PMA_DBI_numRows($tab_rs) > 0) {
|
||||
$tab_rs = PMA_queryAsControlUser(
|
||||
$tab_sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $tab_rs || ! $GLOBALS['dbi']->numRows($tab_rs) > 0) {
|
||||
$this->dieSchema('', __('This page does not contain any tables!'));
|
||||
}
|
||||
while ($curr_table = @PMA_DBI_fetchAssoc($tab_rs)) {
|
||||
while ($curr_table = @$GLOBALS['dbi']->fetchAssoc($tab_rs)) {
|
||||
$alltables[] = PMA_Util::sqlAddSlashes($curr_table['table_name']);
|
||||
}
|
||||
return $alltables;
|
||||
|
||||
@ -215,7 +215,7 @@ class PMA_Schema_PDF extends PMA_PDF
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND page_nr = \'' . $pdf_page_number . '\'';
|
||||
$test_rs = PMA_queryAsControlUser($test_query);
|
||||
$pages = @PMA_DBI_fetchAssoc($test_rs);
|
||||
$pages = @$GLOBALS['dbi']->fetchAssoc($test_rs);
|
||||
$this->SetFont($this->_ff, 'B', 14);
|
||||
$this->Cell(0, 6, ucfirst($pages['page_descr']), 'B', 1, 'C');
|
||||
$this->SetFont($this->_ff, '');
|
||||
@ -405,8 +405,10 @@ class Table_Stats
|
||||
|
||||
$this->_tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
|
||||
$result = PMA_DBI_tryQuery($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$pdf->Error(sprintf(__('The %s table doesn\'t exist!'), $tableName));
|
||||
}
|
||||
// load fields
|
||||
@ -422,7 +424,7 @@ class Table_Stats
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$this->fields[] = $row[0];
|
||||
}
|
||||
}
|
||||
@ -443,8 +445,10 @@ class Table_Stats
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$pdf->Error(
|
||||
sprintf(
|
||||
__('Please configure the coordinates for table %s'),
|
||||
@ -452,7 +456,7 @@ class Table_Stats
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetchRow($result);
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
/*
|
||||
@ -462,12 +466,12 @@ class Table_Stats
|
||||
/*
|
||||
* index
|
||||
*/
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';',
|
||||
null, PMA_DBI_QUERY_STORE
|
||||
null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$this->primary[] = $row['Column_name'];
|
||||
}
|
||||
@ -1151,7 +1155,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
. ' WHERE page_nr = ' . $pageNumber;
|
||||
$_name_rs = PMA_queryAsControlUser($_name_sql);
|
||||
if ($_name_rs) {
|
||||
$_name_row = PMA_DBI_fetchRow($_name_rs);
|
||||
$_name_row = $GLOBALS['dbi']->fetchRow($_name_rs);
|
||||
$filename = $_name_row[0] . '.pdf';
|
||||
}
|
||||
if (empty($filename)) {
|
||||
@ -1189,7 +1193,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
'L', 0, $pdf->PMA_links['doc'][$table]['-']
|
||||
);
|
||||
// $pdf->Ln(1);
|
||||
$fields = PMA_DBI_getColumns($GLOBALS['db'], $table);
|
||||
$fields = $GLOBALS['dbi']->getColumns($GLOBALS['db'], $table);
|
||||
foreach ($fields as $row) {
|
||||
$pdf->SetX(20);
|
||||
$field_name = $row['Field'];
|
||||
@ -1261,7 +1265,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
/**
|
||||
* Gets table keys and retains them
|
||||
*/
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW KEYS FROM ' . PMA_Util::backquote($table) . ';'
|
||||
);
|
||||
$primary = '';
|
||||
@ -1271,7 +1275,7 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
$indexes_data = array();
|
||||
$pk_array = array(); // will be use to emphasis prim. keys in the table
|
||||
// view
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
// Backups the list of primary keys
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$primary .= $row['Column_name'] . ', ';
|
||||
@ -1301,13 +1305,13 @@ class PMA_Pdf_Relation_Schema extends PMA_Export_Relation_Schema
|
||||
}
|
||||
} // end while
|
||||
if ($result) {
|
||||
PMA_DBI_freeResult($result);
|
||||
$GLOBALS['dbi']->freeResult($result);
|
||||
}
|
||||
|
||||
/**
|
||||
* Gets fields properties
|
||||
*/
|
||||
$columns = PMA_DBI_getColumns($db, $table);
|
||||
$columns = $GLOBALS['dbi']->getColumns($db, $table);
|
||||
// Check if we can use Relations
|
||||
if (!empty($cfgRelation['relation'])) {
|
||||
// Find which tables are related with the current one and write it in
|
||||
|
||||
@ -384,8 +384,10 @@ class Table_Stats
|
||||
|
||||
$this->_tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
|
||||
$result = PMA_DBI_tryQuery($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$svg->dieSchema(
|
||||
$pageNumber,
|
||||
"SVG",
|
||||
@ -409,7 +411,7 @@ class Table_Stats
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$this->fields[] = $row[0];
|
||||
}
|
||||
}
|
||||
@ -433,9 +435,11 @@ class Table_Stats
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$svg->dieSchema(
|
||||
$pageNumber,
|
||||
"SVG",
|
||||
@ -445,19 +449,19 @@ class Table_Stats
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetchRow($result);
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
// displayfield
|
||||
$this->displayfield = PMA_getDisplayField($db, $tableName);
|
||||
// index
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$this->primary[] = $row['Column_name'];
|
||||
}
|
||||
|
||||
@ -182,10 +182,10 @@ class PMA_User_Schema
|
||||
. PMA_Util::backquote($cfgRelation['pdf_pages'])
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\'';
|
||||
$page_rs = PMA_queryAsControlUser(
|
||||
$page_query, false, PMA_DBI_QUERY_STORE
|
||||
$page_query, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if ($page_rs && PMA_DBI_numRows($page_rs) > 0) {
|
||||
if ($page_rs && $GLOBALS['dbi']->numRows($page_rs) > 0) {
|
||||
?>
|
||||
<form method="get" action="schema_edit.php" name="frm_select_page">
|
||||
<fieldset>
|
||||
@ -197,7 +197,7 @@ class PMA_User_Schema
|
||||
<select name="chpage" id="chpage" class="autosubmit">
|
||||
<option value="0"><?php echo __('Select page'); ?></option>
|
||||
<?php
|
||||
while ($curr_page = PMA_DBI_fetchAssoc($page_rs)) {
|
||||
while ($curr_page = $GLOBALS['dbi']->fetchAssoc($page_rs)) {
|
||||
echo "\n" . ' '
|
||||
. '<option value="' . $curr_page['page_nr'] . '"';
|
||||
if (isset($this->chosenPage)
|
||||
@ -245,12 +245,12 @@ class PMA_User_Schema
|
||||
* We will need an array of all tables in this db
|
||||
*/
|
||||
$selectboxall = array('--');
|
||||
$alltab_rs = PMA_DBI_query(
|
||||
$alltab_rs = $GLOBALS['dbi']->query(
|
||||
'SHOW TABLES FROM ' . PMA_Util::backquote($db) . ';',
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
while ($val = @PMA_DBI_fetchRow($alltab_rs)) {
|
||||
while ($val = @$GLOBALS['dbi']->fetchRow($alltab_rs)) {
|
||||
$selectboxall[] = $val[0];
|
||||
}
|
||||
|
||||
@ -271,7 +271,7 @@ class PMA_User_Schema
|
||||
. PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
|
||||
$page_rs = PMA_queryAsControlUser($page_query, false);
|
||||
$array_sh_page = array();
|
||||
while ($temp_sh_page = @PMA_DBI_fetchAssoc($page_rs)) {
|
||||
while ($temp_sh_page = @$GLOBALS['dbi']->fetchAssoc($page_rs)) {
|
||||
$array_sh_page[] = $temp_sh_page;
|
||||
}
|
||||
/*
|
||||
@ -427,11 +427,11 @@ class PMA_User_Schema
|
||||
<label for="pdf_page_number_opt"><?php echo __('Page number:'); ?></label>
|
||||
<select name="pdf_page_number" id="pdf_page_number_opt">
|
||||
<?php
|
||||
while ($pages = @PMA_DBI_fetchAssoc($test_rs)) {
|
||||
while ($pages = @$GLOBALS['dbi']->fetchAssoc($test_rs)) {
|
||||
echo ' <option value="' . $pages['page_nr'] . '">'
|
||||
. $pages['page_nr'] . ': ' . htmlspecialchars($pages['page_descr']) . '</option>' . "\n";
|
||||
} // end while
|
||||
PMA_DBI_freeResult($test_rs);
|
||||
$GLOBALS['dbi']->freeResult($test_rs);
|
||||
unset($test_rs);
|
||||
?>
|
||||
</select><br />
|
||||
@ -573,7 +573,7 @@ class PMA_User_Schema
|
||||
. '</u>';
|
||||
|
||||
if (isset($with_field_names)) {
|
||||
$fields = PMA_DBI_getColumns($db, $temp_sh_page['table_name']);
|
||||
$fields = $GLOBALS['dbi']->getColumns($db, $temp_sh_page['table_name']);
|
||||
// if the table has been dropped from outside phpMyAdmin,
|
||||
// we can no longer obtain its columns list
|
||||
if ($fields) {
|
||||
@ -638,7 +638,7 @@ class PMA_User_Schema
|
||||
$export_type = 'pdf';
|
||||
}
|
||||
|
||||
PMA_DBI_selectDb($db);
|
||||
$GLOBALS['dbi']->selectDb($db);
|
||||
|
||||
include "libraries/schema/" . ucfirst($export_type)
|
||||
. "_Relation_Schema.class.php";
|
||||
@ -716,7 +716,7 @@ class PMA_User_Schema
|
||||
* and PBXT tables, as this logic is just to put
|
||||
* the tables on the layout, not to determine relations
|
||||
*/
|
||||
$tables = PMA_DBI_getTablesFull($db);
|
||||
$tables = $GLOBALS['dbi']->getTablesFull($db);
|
||||
$foreignkey_tables = array();
|
||||
foreach ($tables as $table_name => $table_properties) {
|
||||
if (PMA_Util::isForeignKeySupported($table_properties['ENGINE'])) {
|
||||
@ -745,14 +745,14 @@ class PMA_User_Schema
|
||||
. ' GROUP BY master_table'
|
||||
. ' ORDER BY COUNT(master_table) DESC';
|
||||
$master_tables_rs = PMA_queryAsControlUser(
|
||||
$master_tables, false, PMA_DBI_QUERY_STORE
|
||||
$master_tables, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if ($master_tables_rs && PMA_DBI_numRows($master_tables_rs) > 0) {
|
||||
if ($master_tables_rs && $GLOBALS['dbi']->numRows($master_tables_rs) > 0) {
|
||||
/* first put all the master tables at beginning
|
||||
* of the list, so they are near the center of
|
||||
* the schema
|
||||
*/
|
||||
while (list(, $master_table) = PMA_DBI_fetchRow($master_tables_rs)) {
|
||||
while (list(, $master_table) = $GLOBALS['dbi']->fetchRow($master_tables_rs)) {
|
||||
$all_tables[] = $master_table;
|
||||
}
|
||||
|
||||
@ -886,10 +886,10 @@ class PMA_User_Schema
|
||||
. ' AND pdf_page_number = \''
|
||||
. PMA_Util::sqlAddSlashes($this->chosenPage) . '\'';
|
||||
$test_rs = PMA_queryAsControlUser(
|
||||
$test_query, false, PMA_DBI_QUERY_STORE
|
||||
$test_query, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
//echo $test_query;
|
||||
if ($test_rs && PMA_DBI_numRows($test_rs) > 0) {
|
||||
if ($test_rs && $GLOBALS['dbi']->numRows($test_rs) > 0) {
|
||||
if (isset($arrvalue['delete']) && $arrvalue['delete'] == 'y') {
|
||||
$ch_query = 'DELETE FROM '
|
||||
. PMA_Util::backquote($GLOBALS['cfgRelation']['db'])
|
||||
|
||||
@ -224,8 +224,10 @@ class Table_Stats
|
||||
|
||||
$this->_tableName = $tableName;
|
||||
$sql = 'DESCRIBE ' . PMA_Util::backquote($tableName);
|
||||
$result = PMA_DBI_tryQuery($sql, null, PMA_DBI_QUERY_STORE);
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
$result = $GLOBALS['dbi']->tryQuery(
|
||||
$sql, null, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$visio->dieSchema(
|
||||
$pageNumber,
|
||||
"VISIO",
|
||||
@ -249,7 +251,7 @@ class Table_Stats
|
||||
}
|
||||
$this->fields = array_keys($all_columns);
|
||||
} else {
|
||||
while ($row = PMA_DBI_fetchRow($result)) {
|
||||
while ($row = $GLOBALS['dbi']->fetchRow($result)) {
|
||||
$this->fields[] = $row[0];
|
||||
}
|
||||
}
|
||||
@ -273,9 +275,11 @@ class Table_Stats
|
||||
. ' WHERE db_name = \'' . PMA_Util::sqlAddSlashes($db) . '\''
|
||||
. ' AND table_name = \'' . PMA_Util::sqlAddSlashes($tableName) . '\''
|
||||
. ' AND pdf_page_number = ' . $pageNumber;
|
||||
$result = PMA_queryAsControlUser($sql, false, PMA_DBI_QUERY_STORE);
|
||||
$result = PMA_queryAsControlUser(
|
||||
$sql, false, PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
if (! $result || ! PMA_DBI_numRows($result)) {
|
||||
if (! $result || ! $GLOBALS['dbi']->numRows($result)) {
|
||||
$visio->dieSchema(
|
||||
$pageNumber,
|
||||
"VISIO",
|
||||
@ -285,18 +289,18 @@ class Table_Stats
|
||||
)
|
||||
);
|
||||
}
|
||||
list($this->x, $this->y) = PMA_DBI_fetchRow($result);
|
||||
list($this->x, $this->y) = $GLOBALS['dbi']->fetchRow($result);
|
||||
$this->x = (double) $this->x;
|
||||
$this->y = (double) $this->y;
|
||||
// displayfield
|
||||
$this->displayfield = PMA_getDisplayField($db, $tableName);
|
||||
// index
|
||||
$result = PMA_DBI_query(
|
||||
$result = $GLOBALS['dbi']->query(
|
||||
'SHOW INDEX FROM ' . PMA_Util::backquote($tableName) . ';', null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
if (PMA_DBI_numRows($result) > 0) {
|
||||
while ($row = PMA_DBI_fetchAssoc($result)) {
|
||||
if ($GLOBALS['dbi']->numRows($result) > 0) {
|
||||
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
|
||||
if ($row['Key_name'] == 'PRIMARY') {
|
||||
$this->primary[] = $row['Column_name'];
|
||||
}
|
||||
|
||||
@ -32,11 +32,11 @@ $err_url = 'index.php' . $url_query;
|
||||
/**
|
||||
* @global boolean Checks for superuser privileges
|
||||
*/
|
||||
$is_superuser = PMA_isSuperuser();
|
||||
$is_superuser = $GLOBALS['dbi']->isSuperuser();
|
||||
|
||||
// now, select the mysql db
|
||||
if ($is_superuser && ! PMA_DRIZZLE) {
|
||||
PMA_DBI_selectDb('mysql', $userlink);
|
||||
$GLOBALS['dbi']->selectDb('mysql', $userlink);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -44,12 +44,12 @@ if ($is_superuser && ! PMA_DRIZZLE) {
|
||||
*/
|
||||
$binary_logs = PMA_DRIZZLE
|
||||
? null
|
||||
: PMA_DBI_fetchResult(
|
||||
: $GLOBALS['dbi']->fetchResult(
|
||||
'SHOW MASTER LOGS',
|
||||
'Log_name',
|
||||
null,
|
||||
null,
|
||||
PMA_DBI_QUERY_STORE
|
||||
PMA_DatabaseInterface::QUERY_STORE
|
||||
);
|
||||
|
||||
PMA_Util::checkParameters(
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user