Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added MySQLi library; Removed calls to old mysql_wrappers library.

  • Loading branch information...
commit 2915b5c3cea54b55d85f1b15029808480952b87d 1 parent 597dca0
@derrabus derrabus authored
Showing with 1,086 additions and 906 deletions.
  1. +29 −0 ChangeLog
  2. +5 −5 Documentation.html
  3. +6 −6 browse_foreigners.php
  4. +1 −1  db_create.php
  5. +10 −19 db_datadict.php
  6. +2 −2 db_details_common.php
  7. +9 −12 db_details_db_info.php
  8. +2 −2 db_details_links.php
  9. +14 −19 db_details_qbe.php
  10. +9 −6 db_details_structure.php
  11. +12 −13 db_printview.php
  12. +17 −33 db_search.php
  13. +18 −16 export.php
  14. +3 −3 ldi_table.php
  15. +11 −14 left.php
  16. +3 −3 libraries/auth/config.auth.lib.php
  17. +2 −2 libraries/auth/cookie.auth.lib.php
  18. +33 −44 libraries/bookmark.lib.php
  19. +26 −27 libraries/common.lib.php
  20. +57 −0 libraries/database_interface.lib.php
  21. +2 −2 libraries/db_table_exists.lib.php
  22. +48 −40 libraries/dbi/mysql.dbi.lib.php
  23. +216 −0 libraries/dbi/mysqli.dbi.lib.php
  24. +15 −13 libraries/display_tbl.lib.php
  25. +5 −5 libraries/export/csv.php
  26. +6 −6 libraries/export/latex.php
  27. +13 −13 libraries/export/sql.php
  28. +9 −9 libraries/export/xml.php
  29. +1 −1  libraries/get_foreign.lib.php
  30. +7 −9 libraries/mysql_charsets.lib.php
  31. +25 −33 libraries/relation.lib.php
  32. +2 −2 libraries/transformations.lib.php
  33. +6 −10 main.php
  34. +4 −4 mult_submits.inc.php
  35. +10 −9 pdf_pages.php
  36. +23 −28 pdf_schema.php
  37. +2 −2 querywindow.php
  38. +6 −7 read_dump.php
  39. +7 −2 server_common.inc.php
  40. +90 −106 server_privileges.php
  41. +3 −5 server_processlist.php
  42. +11 −14 server_status.php
  43. +12 −9 server_variables.php
  44. +23 −26 sql.php
  45. +8 −9 tbl_addfield.php
  46. +6 −8 tbl_alter.php
  47. +40 −42 tbl_change.php
  48. +6 −6 tbl_create.php
  49. +9 −10 tbl_indexes.php
  50. +18 −36 tbl_move_copy.php
  51. +8 −13 tbl_printview.php
  52. +2 −3 tbl_properties.inc.php
  53. +13 −13 tbl_properties_operations.php
  54. +4 −6 tbl_properties_structure.php
  55. +2 −3 tbl_properties_table_info.php
  56. +6 −12 tbl_query_box.php
  57. +15 −18 tbl_relation.php
  58. +3 −3 tbl_rename.php
  59. +24 −27 tbl_replace.php
  60. +99 −105 tbl_select.php
  61. +6 −8 transformation_wrapper.php
  62. +2 −2 user_password.php
View
29 ChangeLog
@@ -5,6 +5,35 @@ phpMyAdmin - Changelog
$Id$
$Source$
+2004-01-22 Alexander M. Turek <innocenteyes@derrabus.de>
+ * libraries/dbi/mysqli.dbi.lib.php: Experimental new MySQLi library.
+ * browse_foreigners.php, db_create.php, db_datadict.php,
+ db_details_common.php, db_details_db_info.php, db_details_qbe.php,
+ db_details_structure.php, db_printview.php, export.php, ldi_table.php,
+ left.php, main.php, mult_submits.php, pdf_pages.php, pdf_schema.php,
+ querywindow.php, read_dump.php, server_common.inc.php,
+ server_privileges.php, server_processlist.php, server_status.php,
+ server_variables.php, sql.php, tbl_addfield.php, tbl_alter.php,
+ tbl_change.php, tbl_create.php, tbl_index.php, tbl_move_copy.php,
+ tbl_printview.php, tbl_properties.inc.php, tbl_properties_operations.php,
+ tbl_properties_table_info.php, tbl_query_box.php, tbl_relation.php,
+ tbl_rename.php, tbl_replace.php, tbl_select.php,
+ transformation_wrapper.php, user_password.php, libraries/bookmark.lib.php,
+ libraries/common.lib.php, libraries/db_table_exists.lib.php,
+ libraries/display_tbl:lib.php, libraries/get_foreign.lib.php,
+ libraries/mysql_charsets.lib.php, libraries/relation.lib.php,
+ libraries/transformations.lib.php, libraries/auth/config.auth.lib.php,
+ libraries/auth/cookie.auth.lib.php, libraries/export/*.php:
+ - Removed most remaining calls to old mysql_wrappers library;
+ - Small optimizations and XHTML fixes.
+ * libraries/database_interface.lib.php, libraries/dbi/mysql.dbi.lib.php:
+ - Moved PMA_DBI_get_dblist() definition to database_interface.lib;
+ - Fixed "undefined constant" warning (bug #881637);
+ - Added new functions: PMA_DBI_select_db(), PMA_DBI_get_fields(),
+ PMA_DBI_get_fields_meta();
+ - Bypassing charset conversion code for MySQL >= 4.1 experimentally.
+ * Documentation.html: Changed my email address.
+
2004-01-21 Michal Cihar <thesiswritten@cihar.com>
* lang/czech: Fixed unclear message.
View
10 Documentation.html
@@ -2417,7 +2417,7 @@
phpMyAdmin provides experimental support for MySQL&nbsp;4.1 and 5.0. That
means that although you can assign character sets to a table or field,
phpMyAdmin will not recode the data when inserting or extracting it.
- Instead, it will still use the character set you specified for the MySQL
+ Instead, it will still use the character set you specified for the MySQL
onnection.<br />
When compiling php, we strongly recommend that you manually link the MySQL
extension to a MySQL client library of at least the same version since the
@@ -3522,13 +3522,13 @@
</p>
<h4>
[6.22] Bookmarks: Can I execute a default bookmark automatically
- when entering Browse mode for a table?
+ when entering Browse mode for a table?
</h4>
<p>
Yes. If a bookmark has the same label as a table name, it will be
- executed.
+ executed.
</p>
-
+
<a name="faqproject"></a><br />
<h3>[7. phpMyAdmin project]</h3>
@@ -3790,7 +3790,7 @@
* main author of the version 2.1.0.1
* bugfixes
-- Alexander M. Turek &lt;derrabus_at_gmx.de&gt;
+- Alexander M. Turek &lt;me_at_derrabus.de&gt;
* XML exports
* MySQL 4 related features
* various features and fixes
View
12 browse_foreigners.php
@@ -142,31 +142,31 @@ function formupdate(field, key) {
function dimsort($arrayA, $arrayB) {
$keyA = key($arrayA);
$keyB = key($arrayB);
-
+
if ($arrayA[$keyA] == $arrayB[$keyB]) {
return 0;
}
-
+
return ($arrayA[$keyA] < $arrayB[$keyB]) ? -1 : 1;
}
$mysql_key_relrow = array();
$mysql_val_relrow = array();
$count = 0;
- while ($relrow = @PMA_mysql_fetch_array($disp)) {
+ while ($relrow = @PMA_DBI_fetch_assoc($disp)) {
if ($foreign_display != FALSE) {
$val = $relrow[$foreign_display];
} else {
$val = '';
}
-
+
$mysql_key_relrow[$count] = array($relrow[$foreign_field] => $val);
$mysql_val_relrow[$count] = array($val => $relrow[$foreign_field]);
$count++;
}
-
+
usort($mysql_val_relrow, 'dimsort');
-
+
$hcount = 0;
for ($i = 0; $i < $count; $i++) {
$hcount++;
View
2  db_create.php
@@ -29,7 +29,7 @@
}
$sql_query .= ';';
-$result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, FALSE, $err_url);
+$result = PMA_DBI_query($sql_query);
/**
View
29 db_datadict.php
@@ -52,15 +52,11 @@
/**
* Selects the database and gets tables names
*/
-PMA_mysql_select_db($db);
-$sql = 'SHOW TABLES FROM ' . PMA_backquote($db);
-$rowset = @PMA_mysql_query($sql);
+PMA_DBI_select_db($db);
+$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
-if (!$rowset) {
- exit();
-}
$count = 0;
-while ($row = PMA_mysql_fetch_array($rowset)) {
+while ($row = PMA_DBI_fetch_assoc($rowset)) {
$myfieldname = 'Tables_in_' . htmlspecialchars($db);
$table = $row[$myfieldname];
if ($cfgRelation['commwork']) {
@@ -76,21 +72,17 @@
* Gets table informations
*/
// The 'show table' statement works correct since 3.23.03
- $local_query = 'SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'';
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- $showtable = PMA_mysql_fetch_array($result);
+ $result = PMA_DBI_query('SHOW TABLE STATUS LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
+ $showtable = PMA_DBI_fetch_assoc($result);
$num_rows = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
$show_comment = (isset($showtable['Comment']) ? $showtable['Comment'] : '');
- if ($result) {
- PMA_DBI_free_result($result);
- }
+ PMA_DBI_free_result($result);
/**
* Gets table keys and retains them
*/
- $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
$primary = '';
$indexes = array();
$lastIndex = '';
@@ -98,7 +90,7 @@
$indexes_data = array();
$pk_array = array(); // will be use to emphasis prim. keys in the table
// view
- while ($row = PMA_mysql_fetch_array($result)) {
+ while ($row = PMA_DBI_fetch_assoc($result)) {
// Backups the list of primary keys
if ($row['Key_name'] == 'PRIMARY') {
$primary .= $row['Column_name'] . ', ';
@@ -133,8 +125,7 @@
/**
* Gets fields properties
*/
- $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $result = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';');
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
if (!empty($cfgRelation['relation'])) {
@@ -190,7 +181,7 @@
<?php
$i = 0;
- while ($row = PMA_mysql_fetch_array($result)) {
+ while ($row = PMA_DBI_fetch_assoc($result)) {
$bgcolor = ($i % 2) ?$cfg['BgcolorOne'] : $cfg['BgcolorTwo'];
$i++;
View
4 db_details_common.php
@@ -25,7 +25,7 @@
if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page
if (!empty($db)) {
- $is_db = @PMA_mysql_select_db($db);
+ $is_db = PMA_DBI_select_db($db);
}
if (empty($db) || !$is_db) {
header('Location: ' . $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
@@ -38,7 +38,7 @@
*/
if (isset($submitcharset) && PMA_MYSQL_INT_VERSION >= 40101) {
$sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT CHARACTER SET ' . $db_charset;
- $result = PMA_mysql_query($sql_query, $userlink) or PMA_mysqlDie(PMA_mysql_error($userlink), $sql_query, '', $err_url);
+ $result = PMA_DBI_query($sql_query);
$message = $strSuccess;
}
View
21 db_details_db_info.php
@@ -18,11 +18,10 @@
$tables = array();
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE) {
- $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
- $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
+ $db_info_result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
// Blending out tables in use
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
- while ($tmp = PMA_mysql_fetch_row($db_info_result)) {
+ while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
// if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[1])) {
$sot_cache[$tmp[0]] = TRUE;
@@ -31,14 +30,12 @@
PMA_DBI_free_result($db_info_result);
if (isset($sot_cache)) {
- $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
- $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
+ $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
- while ($tmp = PMA_mysql_fetch_row($db_info_result)) {
+ while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) {
- $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
- $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
- $sts_tmp = PMA_mysql_fetch_array($sts_result);
+ $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
+ $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
$tables[] = $sts_tmp;
} else { // table in use
$tables[] = array('Name' => $tmp[0]);
@@ -51,13 +48,13 @@
}
}
if (!isset($sot_ready)) {
- $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
- $db_info_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
+ $db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
- while ($sts_tmp = PMA_mysql_fetch_array($db_info_result)) {
+ while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) {
$tables[] = $sts_tmp;
}
PMA_DBI_free_result($db_info_result);
+ unset($db_info_result);
}
}
$num_tables = (isset($tables) ? count($tables) : 0);
View
4 db_details_links.php
@@ -37,8 +37,8 @@
// Drop link if allowed
if (!$cfg['AllowUserDropDatabase']) {
// Check if the user is a Superuser
- $links_result = @PMA_mysql_query('USE mysql');
- $cfg['AllowUserDropDatabase'] = (!PMA_mysql_error());
+ $cfg['AllowUserDropDatabase'] = PMA_DBI_select_db('mysql');
+ PMA_DBI_select_db($db);
}
if ($cfg['AllowUserDropDatabase']) {
$lnk5 = 'sql.php';
View
33 db_details_qbe.php
@@ -114,7 +114,7 @@
/**
* Prepares the form
*/
-$tbl_result = PMA_mysql_list_tables($db);
+$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
$i = 0;
$k = 0;
@@ -129,8 +129,8 @@
// The tables list gets from MySQL
while ($i < $tbl_result_cnt) {
- $tbl = PMA_mysql_tablename($tbl_result, $i);
- $fld_results = @PMA_mysql_list_fields_alternate($db, $tbl) or PMA_mysqlDie(PMA_mysql_error(), 'PMA_mysql_list_fields_alternate(' . $db . ', ' . $tbl . ')', FALSE, $err_url);
+ list($tbl) = PMA_DBI_fetch_row($tbl_result);
+ $fld_results = PMA_DBI_get_fields($db, $tbl);
$fld_results_cnt = ($fld_results) ? count($fld_results) : 0;
$j = 0;
@@ -779,12 +779,11 @@
// ( When the control user is the same as the normal user
// because he is using one of his databases as pmadb,
// the last db selected is not always the one where we need to work)
- PMA_mysql_select_db($db);
+ PMA_DBI_select_db($db);
foreach($tab_all AS $tab) {
- $ind_qry = 'SHOW INDEX FROM ' . PMA_backquote($tab);
- $ind_rs = PMA_mysql_query($ind_qry);
- while ($ind = PMA_mysql_fetch_array($ind_rs)) {
+ $ind_rs = PMA_DBI_query('SHOW INDEX FROM ' . PMA_backquote($tab) . ';');
+ while ($ind = PMA_DBI_fetch_assoc($ind_rs)) {
$col1 = $tab . '.' . $ind['Column_name'];
if (isset($col_all[$col1])) {
if ($ind['non_unique'] == 0) {
@@ -853,10 +852,12 @@
if ($checked_tables[$tab] != 1 ) {
$rows_qry = 'SELECT COUNT(1) AS anz '
. 'FROM ' . PMA_backquote($tab);
- $rows_rs = PMA_mysql_query($rows_qry);
- while ($res = PMA_mysql_fetch_array($rows_rs)) {
+ $rows_rs = PMA_DBI_query($rows_qry);
+ while ($res = PMA_DBI_fetch_assoc($rows_rs)) {
$tsize[$tab] = $res['anz'];
}
+ PMA_DBI_free_result($rows_rs);
+ unset($rows_rs);
$checked_tables[$tab] = 1;
}
$csize[$tab] = $tsize[$tab];
@@ -928,16 +929,10 @@ function PMA_getRelatives($from) {
. ' AND ' . $to . '_db = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND ' . $from . '_table IN ' . $in_know
. ' AND ' . $to . '_table IN ' . $in_left;
- if (isset($dbh)) {
- PMA_mysql_select_db($cfgRelation['db'], $dbh);
- $relations = @PMA_mysql_query($rel_query, $dbh) or PMA_mysqlDie(PMA_mysql_error($dbh), $rel_query, '', $err_url_0);
- PMA_mysql_select_db($db, $dbh);
- } else {
- PMA_mysql_select_db($cfgRelation['db']);
- $relations = @PMA_mysql_query($rel_query) or PMA_mysqlDie('', $rel_query, '', $err_url_0);
- PMA_mysql_select_db($db);
- }
- while ($row = PMA_mysql_fetch_array($relations)) {
+ PMA_DBI_select_db($cfgRelation['db'], $dbh);
+ $relations = @PMA_DBI_query($rel_query, $dbh);
+ PMA_DBI_select_db($db, $dbh);
+ while ($row = PMA_DBI_fetch_assoc($relations)) {
$found_table = $row[$to . '_table'];
if (isset($tab_left[$found_table])) {
$fromclause .= "\n" . ' LEFT JOIN '
View
15 db_details_structure.php
@@ -156,8 +156,8 @@ function pma_TableHeader($alternate = FALSE) {
$tooltip_truename = array();
$tooltip_aliasname = array();
- $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
- while ($tmp = PMA_mysql_fetch_array($result)) {
+ $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
+ while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_truename[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : $tmp['Name']) : $tmp['Name']);
$tooltip_aliasname[$tmp['Name']] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : ''));
if (isset($tmp['Create_time']) && !empty($tmp['Create_time'])) {
@@ -345,9 +345,10 @@ function pma_TableHeader($alternate = FALSE) {
$local_query = 'SELECT COUNT(*) AS count FROM '
. PMA_backquote($db) . '.'
. PMA_backquote($table);
- $table_info_result = PMA_mysql_query($local_query)
- or PMA_mysqlDie('', $local_query, '', $err_url_0);
- $row_count = PMA_mysql_result($table_info_result, 0, 'count');
+ $table_info_result = PMA_DBI_query($local_query);
+ list($row_count) = PMA_DBI_fetch_row($table_info_result);
+ PMA_DBI_free_result($table_info_result);
+ unset($table_info_result);
$sum_entries += $row_count;
} else {
$row_count = $sts_data['Rows'];
@@ -660,10 +661,12 @@ function pma_TableHeader($alternate = FALSE) {
<?php echo $strPageNumber; ?>&nbsp;
<select name="pdf_page_number">
<?php
- while ($pages = @PMA_mysql_fetch_array($test_rs)) {
+ while ($pages = @PMA_DBI_fetch_assoc($test_rs)) {
echo "\n" . ' '
. '<option value="' . $pages['page_nr'] . '">' . $pages['page_nr'] . ': ' . $pages['page_descr'] . '</option>';
} // end while
+ PMA_DBI_free_result($test_rs);
+ unset($test_rs);
echo "\n";
?>
</select><br />
View
25 db_printview.php
@@ -32,46 +32,45 @@
// staybyte: speedup view on locked tables - 11 June 2001
// Special speedup for newer MySQL Versions (in 4.0 format changed)
if ($cfg['SkipLockedTables'] == TRUE) {
- $local_query = 'SHOW OPEN TABLES FROM ' . PMA_backquote($db);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $result = PMA_DBI_query('SHOW OPEN TABLES FROM ' . PMA_backquote($db) . ';');
// Blending out tables in use
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
- while ($tmp = PMA_mysql_fetch_array($result)) {
+ while ($tmp = PMA_DBI_fetch_row($result)) {
// if in use memorize tablename
if (preg_match('@in_use=[1-9]+@i', $tmp[0])) {
$sot_cache[$tmp[0]] = TRUE;
}
}
PMA_DBI_free_result($result);
+ unset($result);
if (isset($sot_cache)) {
- $local_query = 'SHOW TABLES FROM ' . PMA_backquote($db);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
+ $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
- while ($tmp = PMA_mysql_fetch_array($result)) {
+ while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) {
- $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\'';
- $sts_result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- $sts_tmp = PMA_mysql_fetch_array($sts_result);
+ $sts_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . addslashes($tmp[0]) . '\';');
+ $sts_tmp = PMA_DBI_fetch_assoc($sts_result);
$tables[] = $sts_tmp;
} else { // table in use
$tables[] = array('Name' => $tmp[0]);
}
}
PMA_DBI_free_result($result);
+ unset($result);
$sot_ready = TRUE;
}
}
}
}
if (!isset($sot_ready)) {
- $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
- while ($sts_tmp = PMA_mysql_fetch_array($result)) {
+ $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';');
+ if (PMA_DBI_num_rows($result) > 0) {
+ while ($sts_tmp = PMA_DBI_fetch_assoc($result)) {
$tables[] = $sts_tmp;
}
PMA_DBI_free_result($result);
+ unset($res);
}
}
$num_tables = (isset($tables) ? count($tables) : 0);
View
50 db_search.php
@@ -20,14 +20,8 @@
/**
* Get the list of tables from the current database
*/
-$list_tables = PMA_mysql_list_tables($db);
-$num_tables = ($list_tables ? PMA_DBI_num_rows($list_tables) : 0);
-for ($i = 0; $i < $num_tables; $i++) {
- $tables[] = PMA_mysql_tablename($list_tables, $i);
-}
-if ($num_tables) {
- PMA_DBI_free_result($list_tables);
-}
+$tables = PMA_DBI_get_tables($db);
+$num_tables = count($tables);
/**
@@ -63,17 +57,14 @@ function PMA_getSearchSqls($table, $search_str, $search_option)
$sqlstr_delete = 'DELETE';
// Fields to select
- $local_query = 'SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']);
- $res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url);
- $res_cnt = ($res ? PMA_DBI_num_rows($res) : 0);
- for ($i = 0; $i < $res_cnt; $i++) {
- $tblfields[] = PMA_backquote(PMA_mysql_result($res, $i, 'field'));
- } // end if
+ $res = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($GLOBALS['db']) . ';');
+ while (list($current) = PMA_DBI_fetch_row($res)) {
+ $tblfields[] = PMA_backquote($current);
+ } // while
+ PMA_DBI_free_result($res);
+ unset($current, $res);
$sqlstr_fieldstoselect = ' ' . implode(', ', $tblfields);
$tblfields_cnt = count($tblfields);
- if ($res) {
- PMA_DBI_free_result($res);
- }
// Table to use
$sqlstr_from = ' FROM ' . PMA_backquote($GLOBALS['db']) . '.' . PMA_backquote($table);
@@ -187,14 +178,10 @@ function PMA_getSearchSqls($table, $search_str, $search_option)
$newsearchsqls = PMA_getSearchSqls($onetable, $search_str, $search_option);
// Executes the "COUNT" statement
- $local_query = $newsearchsqls['select_count'];
- $res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url);
- if ($res) {
- $res_cnt = PMA_mysql_result($res, 0, 'count');
- PMA_DBI_free_result($res);
- } else {
- $res_cnt = 0;
- } // end if... else ...
+ $res = PMA_DBI_query($newsearchsqls['select_count']);
+ $res_cnt = PMA_DBI_fetch_assoc($res);
+ $res_cnt = $res_cnt['count'];
+ PMA_DBI_free_result($res);
$num_search_result_total = $res_cnt;
echo ' <!-- Search results in table ' . $onetable . ' (' . $res_cnt . ') -->' . "\n"
@@ -226,14 +213,11 @@ function PMA_getSearchSqls($table, $search_str, $search_option)
$newsearchsqls = PMA_getSearchSqls($table_select[$i], $search_str, $search_option);
// Executes the "COUNT" statement
- $local_query = $newsearchsqls['select_count'];
- $res = @PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, FALSE, $err_url);
- if ($res) {
- $res_cnt = PMA_mysql_result($res, 0, 'count');
- PMA_DBI_free_result($res);
- } else {
- $res_cnt = 0;
- } // end if... else ...
+ $res = PMA_DBI_query($newsearchsqls['select_count']);
+ $res_cnt = PMA_DBI_fetch_assoc($res);
+ $res_cnt = $res_cnt['count'];
+ PMA_DBI_free_result($res);
+ unset($res);
$num_search_result_total += $res_cnt;
echo ' <!-- Search results in table ' . $table_select[$i] . ' (' . $res_cnt . ') -->' . "\n"
View
34 export.php
@@ -309,8 +309,8 @@ function PMA_exportOutputHandler($line)
// Check if we have something to export
if ($export_type == 'database') {
- $tables = PMA_mysql_list_tables($db);
- $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
+ $tables = PMA_DBI_get_tables($db);
+ $num_tables = count($tables);
if ($num_tables == 0) {
$message = $strNoTablesFound;
$js_to_run = 'functions.js';
@@ -369,15 +369,15 @@ function PMA_exportOutputHandler($line)
|| !isset($tmp_select)) {
PMA_exportDBHeader($current_db);
PMA_exportDBCreate($current_db);
- $tables = PMA_mysql_list_tables($current_db);
- $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
- $i = 0;
- while ($i < $num_tables) {
- $table = PMA_mysql_tablename($tables, $i);
+ $tables = PMA_DBI_get_tables($current_db);
+ foreach ($tables as $table) {
$local_query = 'SELECT * FROM ' . PMA_backquote($current_db) . '.' . PMA_backquote($table);
- if (isset($GLOBALS[$what . '_structure'])) PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
- if (isset($GLOBALS[$what . '_data'])) PMA_exportData($current_db, $table, $crlf, $err_url, $local_query);
- $i++;
+ if (isset($GLOBALS[$what . '_structure'])) {
+ PMA_exportStructure($current_db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
+ }
+ if (isset($GLOBALS[$what . '_data'])) {
+ PMA_exportData($current_db, $table, $crlf, $err_url, $local_query);
+ }
}
PMA_exportDBFooter($current_db);
}
@@ -389,16 +389,18 @@ function PMA_exportOutputHandler($line)
$tmp_select = '|' . $tmp_select . '|';
}
$i = 0;
- while ($i < $num_tables) {
- $table = PMA_mysql_tablename($tables, $i);
+ foreach ($tables as $table) {
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
if ((isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|'))
|| !isset($tmp_select)) {
- if (isset($GLOBALS[$what . '_structure'])) PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
- if (isset($GLOBALS[$what . '_data'])) PMA_exportData($db, $table, $crlf, $err_url, $local_query);
+ if (isset($GLOBALS[$what . '_structure'])) {
+ PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates);
+ }
+ if (isset($GLOBALS[$what . '_data'])) {
+ PMA_exportData($db, $table, $crlf, $err_url, $local_query);
+ }
}
- $i++;
}
PMA_exportDBFooter($db);
} else {
@@ -415,7 +417,7 @@ function PMA_exportOutputHandler($line)
if (!empty($sql_query)) {
$local_query = $sql_query . $add_query;
- PMA_mysql_select_db($db);
+ PMA_DBI_select_db($db);
} else {
$local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . $add_query;
}
View
6 ldi_table.php
@@ -152,15 +152,15 @@
}
if (PMA_MYSQL_INT_VERSION > 40003) {
- $tmp_query = "SHOW VARIABLES LIKE 'local\\_infile'";
- $result = PMA_mysql_query($tmp_query);
+ $result = PMA_DBI_try_query('SHOW VARIABLES LIKE \'local\\_infile\';');
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
- $tmp = PMA_mysql_fetch_row($result);
+ $tmp = PMA_DBI_fetch_row($result);
if ($tmp[1] == 'ON') {
$local_option_selected = TRUE;
}
}
PMA_DBI_free_result($result);
+ unset($result);
}
?>
View
25 left.php
@@ -406,7 +406,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
if (!empty($db_start) && $db == $db_start) {
$selected_db = $j;
}
- $tables = @PMA_mysql_list_tables($db);
+ $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
@@ -421,8 +421,8 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
&& (!$cfg['LeftFrameLight'] || $selected_db == $j)) {
$tooltip = array();
$tooltip_name = array();
- $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
- while ($tmp = PMA_mysql_fetch_array($result)) {
+ $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
+ while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
@@ -471,8 +471,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
<?php
// Displays the list of tables from the current database
$tablestack = array();
- for ($t = 0; $t < $num_tables; $t++) {
- $table = PMA_mysql_tablename($tables, $t);
+ while (list($table) = PMA_DBI_fetch_row($tables)) {
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlspecialchars($tooltip_name[$table])
: '';
@@ -512,7 +511,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
$tablestack['']['pma_name'][] = $table;
$tablestack['']['pma_list_item'][] = $list_item;
}
- } // end for $t (tables list)
+ } // end while (tables list)
PMA_nestedSet($j, $tablestack);
?>
@@ -530,8 +529,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
// Builds the databases' names list
if (!empty($db_start) && $db == $db_start) {
// Gets the list of tables from the current database
- for ($t = 0; $t < $num_tables; $t++) {
- $table = PMA_mysql_tablename($tables, $t);
+ while (list($table) = PMA_DBI_fetch_row($tables)) {
$url_title = (!empty($tooltip) && isset($tooltip[$table]))
? htmlentities($tooltip[$table])
: '';
@@ -548,7 +546,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
} else {
$table_list .= ' <a class="tblItem" id="tbl_' . md5($table) . '" title="' . $url_title . '" target="phpmain' . $hash . '" href="' . $cfg['DefaultTabTable'] . '?' . $common_url_query . '&amp;table=' . urlencode($table) . '">' . ($alias != '' && $cfg['ShowTooltipAliasTB'] ? $alias : htmlspecialchars($table)) . '</a></nobr><br />' . "\n";
}
- } // end for $t (tables list)
+ } // end while (tables list)
if (!$table_list) {
$table_list = ' <br /><br />' . "\n"
@@ -618,7 +616,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
// Case where only one database has to be displayed
else if ($num_dbs == 1) {
$db = $dblist[0];
- $tables = @PMA_mysql_list_tables($db);
+ $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';');
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
@@ -632,8 +630,8 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
&& $num_tables) {
$tooltip = array();
$tooltip_name = array();
- $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
- while ($tmp = PMA_mysql_fetch_array($result)) {
+ $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db));
+ while ($tmp = PMA_DBI_fetch_assoc($result)) {
$tooltip_name[$tmp['Name']] = (!empty($tmp['Comment']) ? $tmp['Comment'] . ' ' : '');
$tmp['Comment'] = ($cfg['ShowTooltipAliasTB'] ? $tmp['Name'] : $tmp['Comment']);
@@ -692,8 +690,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
// Displays the list of tables from the current database
$tablestack = array();
- for ($j = 0; $j < $num_tables; $j++) {
- $table = PMA_mysql_tablename($tables, $j);
+ while (list($table) = PMA_DBI_fetch_row($tables)) {
$alias = (!empty($tooltip_name) && isset($tooltip_name[$table]))
? htmlentities($tooltip_name[$table])
: '';
View
6 libraries/auth/config.auth.lib.php
@@ -44,7 +44,7 @@ function PMA_auth_check()
function PMA_auth_set_user()
{
return TRUE;
-} // end of the 'PMA_auth_set_user()' function
+} // end of the 'PMA_auth_set_user()' function
/**
@@ -69,8 +69,8 @@ function PMA_auth_fails()
{
global $php_errormsg, $cfg;
global $right_font_family, $font_size, $font_bigger;
- if (PMA_mysql_error()) {
- $conn_error = PMA_mysql_error();
+ if (PMA_DBI_getError()) {
+ $conn_error = PMA_DBI_getError();
} else if (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
View
4 libraries/auth/cookie.auth.lib.php
@@ -591,8 +591,8 @@ function PMA_auth_fails()
// Deletes password cookie and displays the login form
setcookie('pma_cookie_password', base64_encode(''), 0, $GLOBALS['cookie_path'], '' , $GLOBALS['is_https']);
- if (PMA_mysql_error()) {
- $conn_error = PMA_mysql_error();
+ if (PMA_DBI_getError()) {
+ $conn_error = PMA_DBI_getError();
} else if (isset($php_errormsg)) {
$conn_error = $php_errormsg;
} else {
View
77 libraries/bookmark.lib.php
@@ -38,29 +38,29 @@ function PMA_getBookmarksParam()
/**
* Gets the list of bookmarks defined for the current database
*
- * @param string the current database name
- * @param array the bookmark parameters for the current user
+ * @global resource the controluser db connection handle
*
- * @return mixed the bookmarks list if defined, false else
+ * @param string the current database name
+ * @param array the bookmark parameters for the current user
+ *
+ * @return mixed the bookmarks list if defined, false else
*
* @access public
*/
function PMA_listBookmarks($db, $cfgBookmark)
{
+ global $dbh;
+
$query = 'SELECT label, id FROM '. PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE dbase = \'' . PMA_sqlAddslashes($db) . '\''
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')';
- if (isset($GLOBALS['dbh'])) {
- $result = PMA_mysql_query($query, $GLOBALS['dbh']);
- } else {
- $result = PMA_mysql_query($query);
- }
+ $result = PMA_DBI_query($query, $dbh);
// There is some bookmarks -> store them
if ($result > 0 && PMA_DBI_num_rows($result) > 0) {
$flag = 1;
- while ($row = PMA_mysql_fetch_row($result)) {
+ while ($row = PMA_DBI_fetch_row($result)) {
$bookmark_list[$flag . ' - ' . $row[0]] = $row[1];
$flag++;
} // end while
@@ -76,17 +76,20 @@ function PMA_listBookmarks($db, $cfgBookmark)
/**
* Gets the sql command from a bookmark
*
- * @param string the current database name
- * @param array the bookmark parameters for the current user
- * @param mixed the id of the bookmark to get
- * @param string which field to look up the $id
+ * @global resource the controluser db connection handle
+ *
+ * @param string the current database name
+ * @param array the bookmark parameters for the current user
+ * @param mixed the id of the bookmark to get
+ * @param string which field to look up the $id
*
- * @return string the sql query
+ * @return string the sql query
*
* @access public
*/
function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
{
+ global $dbh;
if (empty($cfgBookmark['db']) || empty($cfgBookmark['table'])) {
return '';
@@ -97,12 +100,8 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
. ' AND (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND ' . PMA_backquote($id_field) . ' = ' . $id;
- if (isset($GLOBALS['dbh'])) {
- $result = PMA_mysql_query($query, $GLOBALS['dbh']);
- } else {
- $result = PMA_mysql_query($query);
- }
- $bookmark_query = @PMA_mysql_result($result, 0, 'query') OR FALSE;
+ $result = PMA_DBI_try_query($query, $dbh);
+ list($bookmark_query) = PMA_DBI_fetch_row($result) or array(FALSE);
return $bookmark_query;
} // end of the 'PMA_queryBookmarks()' function
@@ -111,33 +110,23 @@ function PMA_queryBookmarks($db, $cfgBookmark, $id, $id_field = 'id')
/**
* Adds a bookmark
*
- * @param array the properties of the bookmark to add
- * @param array the bookmark parameters for the current user
- * @param boolean whether to make the bookmark available for all users
+ * @global resource the controluser db connection handle
*
- * @return boolean whether the INSERT succeeds or not
+ * @param array the properties of the bookmark to add
+ * @param array the bookmark parameters for the current user
+ * @param boolean whether to make the bookmark available for all users
+ *
+ * @return boolean whether the INSERT succeeds or not
*
* @access public
*/
function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
{
+ global $dbh;
+
$query = 'INSERT INTO ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' (id, dbase, user, query, label) VALUES (\'\', \'' . PMA_sqlAddslashes($fields['dbase']) . '\', \'' . ($all_users ? '' : PMA_sqlAddslashes($fields['user'])) . '\', \'' . PMA_sqlAddslashes(urldecode($fields['query'])) . '\', \'' . PMA_sqlAddslashes($fields['label']) . '\')';
- if (isset($GLOBALS['dbh'])) {
- $result = PMA_mysql_query($query, $GLOBALS['dbh']);
- if (PMA_mysql_error($GLOBALS['dbh'])) {
- $error = PMA_mysql_error($GLOBALS['dbh']);
- require_once('./header.inc.php');
- PMA_mysqlDie($error);
- }
- } else {
- $result = PMA_mysql_query($query);
- if (PMA_mysql_error()) {
- $error = PMA_mysql_error();
- require_once('./header.inc.php');
- PMA_mysqlDie($error);
- }
- }
+ $result = PMA_DBI_query($query, $dbh);
return TRUE;
} // end of the 'PMA_addBookmarks()' function
@@ -146,6 +135,8 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
/**
* Deletes a bookmark
*
+ * @global resource the controluser db connection handle
+ *
* @param string the current database name
* @param array the bookmark parameters for the current user
* @param integer the id of the bookmark to get
@@ -154,15 +145,13 @@ function PMA_addBookmarks($fields, $cfgBookmark, $all_users = false)
*/
function PMA_deleteBookmarks($db, $cfgBookmark, $id)
{
+ global $dbh;
+
$query = 'DELETE FROM ' . PMA_backquote($cfgBookmark['db']) . '.' . PMA_backquote($cfgBookmark['table'])
. ' WHERE (user = \'' . PMA_sqlAddslashes($cfgBookmark['user']) . '\''
. ' OR user = \'\')'
. ' AND id = ' . $id;
- if (isset($GLOBALS['dbh'])) {
- $result = PMA_mysql_query($query, $GLOBALS['dbh']);
- } else {
- $result = PMA_mysql_query($query);
- }
+ $result = PMA_DBI_try_query($query, $dbh);
} // end of the 'PMA_deleteBookmarks()' function
View
53 libraries/common.lib.php
@@ -458,7 +458,7 @@ function PMA_mysqlDie($error_message = '', $the_query = '',
require_once('./header.inc.php');
if (!$error_message) {
- $error_message = PMA_mysql_error();
+ $error_message = PMA_DBI_getError();
}
if (!$the_query && !empty($GLOBALS['sql_query'])) {
$the_query = $GLOBALS['sql_query'];
@@ -583,7 +583,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
$auth_query = 'SELECT User, Select_priv '
. 'FROM mysql.user '
. 'WHERE User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
- $rs = PMA_mysql_query($auth_query, $dbh); // Debug: or PMA_mysqlDie('', $auth_query, FALSE);
+ $rs = PMA_DBI_try_query($auth_query, $dbh);
} // end
}
@@ -591,7 +591,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// usable db list
if (!$dblist_cnt
&& ($rs && @PMA_DBI_num_rows($rs))) {
- $row = PMA_mysql_fetch_array($rs);
+ $row = PMA_DBI_fetch_assoc($rs);
PMA_DBI_free_result($rs);
// Correction uva 19991215
// Previous code assumed database "mysql" admin table "db" column
@@ -608,7 +608,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// 1. get allowed dbs from the "mysql.db" table
// lem9: User can be blank (anonymous user)
$local_query = 'SELECT DISTINCT Db FROM mysql.db WHERE Select_priv = \'Y\' AND (User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\' OR User = \'\')';
- $rs = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
+ $rs = PMA_DBI_try_query($local_query, $dbh);
if ($rs && @PMA_DBI_num_rows($rs)) {
// Will use as associative array of the following 2 code
// lines:
@@ -620,7 +620,7 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// populating $dblist[], as previous code did. But it is
// now populated with actual database names instead of
// with regular expressions.
- while ($row = PMA_mysql_fetch_array($rs)) {
+ while ($row = PMA_DBI_fetch_assoc($rs)) {
// loic1: all databases cases - part 1
if (empty($row['Db']) || $row['Db'] == '%') {
$uva_mydbs['%'] = 1;
@@ -632,15 +632,15 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
}
} // end while
PMA_DBI_free_result($rs);
- $uva_alldbs = mysql_list_dbs($GLOBALS['dbh']);
+ $uva_alldbs = PMA_DBI_query('SHOW DATABASES;', $GLOBALS['dbh']);
// loic1: all databases cases - part 2
if (isset($uva_mydbs['%'])) {
- while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) {
+ while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$dblist[] = $uva_row[0];
} // end while
} // end if
else {
- while ($uva_row = PMA_mysql_fetch_array($uva_alldbs)) {
+ while ($uva_row = PMA_DBI_fetch_row($uva_alldbs)) {
$uva_db = $uva_row[0];
if (isset($uva_mydbs[$uva_db]) && $uva_mydbs[$uva_db] == 1) {
$dblist[] = $uva_db;
@@ -668,9 +668,9 @@ function PMA_safe_db_list($only_db_check, $dbh, $dblist_cnt, $rs, $userlink, $cf
// 2. get allowed dbs from the "mysql.tables_priv" table
$local_query = 'SELECT DISTINCT Db FROM mysql.tables_priv WHERE Table_priv LIKE \'%Select%\' AND User = \'' . PMA_sqlAddslashes($cfg['Server']['user']) . '\'';
- $rs = PMA_mysql_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
+ $rs = PMA_DBI_try_query($local_query, $dbh);
if ($rs && @PMA_DBI_num_rows($rs)) {
- while ($row = PMA_mysql_fetch_array($rs)) {
+ while ($row = PMA_DBI_fetch_assoc($rs)) {
if (PMA_isInto($row['Db'], $dblist) == -1) {
$dblist[] = $row['Db'];
}
@@ -996,7 +996,7 @@ function PMA_setFontSizes()
// Connects to the server (validates user's login)
$userlink = PMA_DBI_connect($cfg['Server']['user'], $cfg['Server']['password']);
-
+
if (empty($dbh)) {
$dbh = $userlink;
}
@@ -1044,18 +1044,18 @@ function PMA_setFontSizes()
}
if ($is_show_dbs && ereg('(^|[^\])(_|%)', $dblist[$i])) {
$local_query = 'SHOW DATABASES LIKE \'' . $dblist[$i] . '\'';
- $rs = PMA_mysql_query($local_query, $dbh);
+ $rs = PMA_DBI_query($local_query, $dbh);
// "SHOW DATABASES" statement is disabled
if ($i == 0
- && (PMA_mysql_error() && mysql_errno() == 1045)) {
+ && (substr(PMA_DBI_getError($dbh), 1, 4) == 1045)) {
$true_dblist[] = str_replace('\\_', '_', str_replace('\\%', '%', $dblist[$i]));
$is_show_dbs = FALSE;
}
// Debug
- // else if (PMA_mysql_error()) {
- // PMA_mysqlDie('', $local_query, FALSE);
+ // else if (PMA_DBI_getError($dbh)) {
+ // PMA_mysqlDie(PMA_DBI_getError($dbh), $local_query, FALSE);
// }
- while ($row = @PMA_mysql_fetch_row($rs)) {
+ while ($row = @PMA_DBI_fetch_row($rs)) {
$true_dblist[] = $row[0];
} // end while
if ($rs) {
@@ -1110,7 +1110,7 @@ function PMA_availableDatabases($error_url = '')
if ($num_dbs) {
$true_dblist = array();
for ($i = 0; $i < $num_dbs; $i++) {
- $dblink = @PMA_mysql_select_db($dblist[$i]);
+ $dblink = @PMA_DBI_select_db($dblist[$i]);
if ($dblink) {
$true_dblist[] = $dblist[$i];
} // end if
@@ -1245,9 +1245,8 @@ function PMA_whichCrlf()
function PMA_countRecords($db, $table, $ret = FALSE)
{
global $err_url, $cfg;
- $local_query = 'SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'';
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url);
- $showtable = PMA_mysql_fetch_array($result);
+ $result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
+ $showtable = PMA_DBI_fetch_assoc($result);
$num = (isset($showtable['Rows']) ? $showtable['Rows'] : 0);
if ($num < $cfg['MaxExactCount']) {
unset($num);
@@ -1255,8 +1254,8 @@ function PMA_countRecords($db, $table, $ret = FALSE)
PMA_DBI_free_result($result);
if (!isset($num)) {
- $result = PMA_mysql_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table)) or PMA_mysqlDie('', $local_query, '', $err_url);
- $num = ($result) ? PMA_mysql_result($result, 0, 'num') : 0;
+ $result = PMA_DBI_query('SELECT COUNT(*) AS num FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
+ list($num) = ($result) ? PMA_DBI_fetch_row($result) : array(0);
PMA_DBI_free_result($result);
}
if ($ret) {
@@ -1302,9 +1301,9 @@ function PMA_showMessage($message)
// Corrects the tooltip text via JS if required
else if (!empty($GLOBALS['table']) && $cfg['ShowTooltip']) {
- $result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
+ $result = PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
if ($result) {
- $tbl_status = PMA_mysql_fetch_array($result, MYSQL_ASSOC);
+ $tbl_status = PMA_DBI_fetch_assoc($result);
$tooltip = (empty($tbl_status['Comment']))
? ''
: $tbl_status['Comment'] . ' ';
@@ -1333,14 +1332,14 @@ function PMA_showMessage($message)
if (isset($GLOBALS['table']) && isset($GLOBALS['sql_query'])
&& $GLOBALS['sql_query'] == 'TRUNCATE TABLE ' . PMA_backquote($GLOBALS['table'])) {
if (!isset($tbl_status)) {
- $result = @PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
+ $result = @PMA_DBI_try_query('SHOW TABLE STATUS FROM ' . PMA_backquote($GLOBALS['db']) . ' LIKE \'' . PMA_sqlAddslashes($GLOBALS['table'], TRUE) . '\'');
if ($result) {
- $tbl_status = PMA_mysql_fetch_array($result, MYSQL_ASSOC);
+ $tbl_status = PMA_DBI_fetch_assoc($result);
PMA_DBI_free_result($result);
}
}
if (isset($tbl_status) && (int) $tbl_status['Index_length'] > 1024) {
- @PMA_mysql_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
+ PMA_DBI_try_query('REPAIR TABLE ' . PMA_backquote($GLOBALS['table']));
}
}
unset($tbl_status);
View
57 libraries/database_interface.lib.php
@@ -15,4 +15,61 @@ function PMA_DBI_query($query, $dbh = '') {
return $res;
}
+function PMA_DBI_get_dblist($link = NULL) {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ $res = PMA_DBI_try_query('SHOW DATABASES;', $link);
+ $dbs_array = array();
+ while ($row = PMA_DBI_fetch_row($res)) {
+
+ // Before MySQL 4.0.2, SHOW DATABASES could send the
+ // whole list, so check if we really have access:
+ if (PMA_MYSQL_CLIENT_API < 40002) {
+ $dblink = @PMA_DBI_select_db($row[0], $link);
+ if (!$dblink) {
+ continue;
+ }
+ }
+ $dbs_array[] = $row[0];
+ }
+ PMA_DBI_free_result($res);
+ unset($res);
+
+ return $dbs_array;
+}
+
+function PMA_DBI_get_tables($database, $link = NULL) {
+ $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';');
+ $tables = array();
+ while (list($current) = PMA_DBI_fetch_row($result)) {
+ $tables[] = $current;
+ }
+ PMA_DBI_free_result($result);
+
+ return $tables;
+}
+
+function PMA_DBI_get_fields($database, $table, $link = NULL) {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ $result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($database) . '.' . PMA_backquote($table), $link);
+
+ $fields = array();
+ while ($row = PMA_DBI_fetch_assoc($result)) {
+ $fields[] = $row;
+ }
+
+ return $fields;
+}
+
?>
View
4 libraries/db_table_exists.lib.php
@@ -10,7 +10,7 @@
if (!isset($is_db) || !$is_db) {
// Not a valid db name -> back to the welcome page
if (!empty($db)) {
- $is_db = @PMA_mysql_select_db($db);
+ $is_db = @PMA_DBI_select_db($db);
}
if (empty($db) || !$is_db) {
if (!isset($is_transformation_wrapper)) {
@@ -22,7 +22,7 @@
if (!isset($is_table) || !$is_table) {
// Not a valid table name -> back to the db_details.php
if (!empty($table)) {
- $is_table = @PMA_mysql_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'');
+ $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';');
}
if (empty($table)
|| !($is_table && @PMA_DBI_num_rows($is_table))) {
View
88 libraries/dbi/mysql.dbi.lib.php
@@ -6,8 +6,6 @@
* Interface to the classic MySQL extension
*/
-require_once('./libraries/charset_conversion.lib.php');
-
/**
* Loads the mysql extensions if it is not loaded yet
*/
@@ -36,6 +34,7 @@ function PMA_DBI_connect($user, $password) {
$server_port = (empty($cfg['Server']['port']))
? ''
: ':' . $cfg['Server']['port'];
+
if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
$cfg['Server']['socket'] = '';
}
@@ -64,10 +63,10 @@ function PMA_DBI_connect($user, $password) {
} // end if
if (!defined('PMA_MYSQL_INT_VERSION')) {
- $result = PMA_DBI_try_query('SELECT VERSION() AS version', $link);
+ $result = mysql_query('SELECT VERSION() AS version', $link);
if ($result != FALSE && @mysql_num_rows($result) > 0) {
- $row = PMA_DBI_fetch_assoc($result);
- $match = explode('.', $row['version']);
+ $row = mysql_fetch_row($result);
+ $match = explode('.', $row[0]);
mysql_free_result($result);
}
if (!isset($row)) {
@@ -75,14 +74,35 @@ function PMA_DBI_connect($user, $password) {
define('PMA_MYSQL_STR_VERSION', '3.23.32');
} else{
define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
- define('PMA_MYSQL_STR_VERSION', $row['version']);
+ define('PMA_MYSQL_STR_VERSION', $row[0]);
unset($result, $row, $match);
}
}
+ if (PMA_MYSQL_INT_VERSION >= 40100) {
+ mysql_query('SET CHARACTER SET utf8;', $link);
+ mysql_query('SET SESSION character_set_connection = \'utf8\';', $link);
+ } else {
+ require_once('./libraries/charset_conversion.lib.php');
+ }
+
return $link;
}
+function PMA_DBI_select_db($dbname, $link = '') {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ if (PMA_MYSQL_INT_VERSION < 40100) {
+ $dbname = PMA_convert_charset($dbname);
+ }
+ return mysql_select_db($dbname, $link);
+}
+
function PMA_DBI_try_query($query, $link = '') {
if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
@@ -91,6 +111,9 @@ function PMA_DBI_try_query($query, $link = '') {
return FALSE;
}
}
+ if (PMA_MYSQL_INT_VERSION < 40100) {
+ $query = PMA_convert_charset($query);
+ }
return mysql_query(PMA_convert_charset($query), $link);
}
@@ -104,7 +127,8 @@ function PMA_mysql_fetch_array($result, $type = FALSE) {
} else {
$data = mysql_fetch_array($result);
}
- if (!(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
+ if (PMA_MYSQL_INT_VERSION >= 40100
+ || !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
/* No recoding -> return data as we got them */
return $data;
} else {
@@ -142,7 +166,7 @@ function PMA_DBI_fetch_row($result) {
}
function PMA_DBI_free_result($result) {
- return mysql_free_result($result);
+ return @mysql_free_result($result);
}
function PMA_DBI_getError($link = '') {
@@ -154,48 +178,23 @@ function PMA_DBI_getError($link = '') {
}
}
$error = mysql_errno($link);
- if ($error) {
- $error = mysql_errno($link);
- if (!empty($error)) {
- $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysql_error($link));
- }
+ if ($error && PMA_MYSQL_INT_VERSION >= 40100) {
+ $error = '#' . ((string) $error) . ' - ' . mysql_error($link);
+ } elseif ($error) {
+ $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysql_error($link));
}
+ return $error;
}
function PMA_DBI_close($link = '') {
if (empty($link)) {
- $link = $GLOBALS['userlink'];
- }
- @mysql_close($link);
-}
-
-function PMA_DBI_get_dblist($link = '') {
- if (empty($link)) {
if (isset($GLOBALS['userlink'])) {
$link = $GLOBALS['userlink'];
} else {
return FALSE;
}
}
- $res = PMA_DBI_try_query('SHOW DATABASES;', $link);
- $dbs_array = array();
- while ($row = PMA_DBI_fetch_row($res)) {
- // not sure if we have to convert before the (possible) select_db()
- $dbname = PMA_convert_display_charset($row[0]);
-
- // Before MySQL 4.0.2, SHOW DATABASES could send the
- // whole list, so check if we really have access:
- if (PMA_MYSQL_CLIENT_API < 40002) {
- $dblink = @PMA_mysql_select_db($dbname);
- if (!dblink) {
- continue;
- }
- }
- $dbs_array[] = $dbname;
- }
- PMA_DBI_free_result($res);
- unset($res);
- return $dbs_array;
+ return @mysql_close($link);
}
function PMA_DBI_num_rows($result) {
@@ -224,4 +223,13 @@ function PMA_DBI_affected_rows($link) {
return mysql_affected_rows($link);
}
-?>
+function PMA_DBI_get_fields_meta($result) {
+ $fields = array();
+ $num_fields = mysql_num_fields($result);
+ for ($i = 0; $i < $num_fields; $i++) {
+ $fields[] = mysql_fetch_field($result, $i);
+ }
+ return $fields;
+}
+
+?>
View
216 libraries/dbi/mysqli.dbi.lib.php
@@ -0,0 +1,216 @@
+<?php
+/* $Id$ */
+// vim: expandtab sw=4 ts=4 sts=4:
+
+/**
+ * Interface to the improved MySQL extension (MySQLi)
+ */
+
+/**
+ * Loads the MySQLi extension if it is not loaded yet
+ */
+if (!@function_exists('mysqli_connect')) {
+ PMA_dl('mysqli');
+}
+
+// check whether mysql is available
+if (!@function_exists('mysqli_connect')) {
+ require_once('./libraries/header_http.inc.php');
+ echo $strCantLoadMySQL . '<br />' . "\n" // TODO: Replace by a MySQLi related message
+ . '<a href="./Documentation.html#faqmysql" target="documentation">' . $GLOBALS['strDocu'] . '</a>' . "\n";
+ exit;
+}
+
+// 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);
+}
+
+function PMA_DBI_connect($user, $password) {
+ global $cfg, $php_errormsg;
+
+ $server_port = (empty($cfg['Server']['port']))
+ ? FALSE
+ : (int) $cfg['Server']['port'];
+
+ if (strtolower($cfg['Server']['connect_type']) == 'tcp') {
+ $cfg['Server']['socket'] = '';
+ }
+
+ $server_socket = (empty($cfg['Server']['socket']))
+ ? FALSE
+ : $cfg['Server']['socket'];
+
+ $link = mysqli_connect($cfg['Server']['host'], $user, $password, FALSE, $server_port, $server_socket);
+
+ if (empty($link)) {
+ PMA_auth_fails();
+ } // end if
+
+ if (!defined('PMA_MYSQL_INT_VERSION')) {
+ $result = mysqli_query($link, 'SELECT VERSION() AS version;', MYSQLI_STORE_RESULT);
+ if ($result != FALSE && @mysqli_num_rows($result) > 0) {
+ $row = mysqli_fetch_row($result);
+ $match = explode('.', $row[0]);
+ mysqli_free_result($result);
+ }
+ if (!isset($row)) {
+ define('PMA_MYSQL_INT_VERSION', 32332);
+ define('PMA_MYSQL_STR_VERSION', '3.23.32');
+ } else{
+ define('PMA_MYSQL_INT_VERSION', (int)sprintf('%d%02d%02d', $match[0], $match[1], intval($match[2])));
+ define('PMA_MYSQL_STR_VERSION', $row[0]);
+ unset($result, $row, $match);
+ }
+ }
+
+ if (PMA_MYSQL_INT_VERSION >= 40100) {
+ mysqli_query($link, 'SET CHARACTER SET utf8;', MYSQLI_STORE_RESULT);
+ mysqli_query($link, 'SET SESSION character_set_connection = \'utf8\';', MYSQLI_STORE_RESULT);
+ } else {
+ require_once('./libraries/charset_conversion.lib.php');
+ }
+
+ return $link;
+}
+
+function PMA_DBI_select_db($dbname, $link = '') {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ if (PMA_MYSQL_INT_VERSION < 40100) {
+ $dbname = PMA_convert_charset($dbname);
+ }
+ return mysqli_select_db($link, $dbname);
+}
+
+function PMA_DBI_try_query($query, $link = '') {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ if (PMA_MYSQL_INT_VERSION < 40100) {
+ $query = PMA_convert_charset($query);
+ }
+ return mysqli_query($link, $query, MYSQLI_USE_RESULT);
+}
+
+// The following function is meant for internal use only.
+// Do not call it from outside this library!
+function PMA_mysqli_fetch_array($result, $type = FALSE) {
+ global $cfg, $allow_recoding, $charset, $convcharset;
+
+ if ($type != FALSE) {
+ $data = mysqli_fetch_array($result, $type);
+ } else {
+ $data = mysqli_fetch_array($result);
+ }
+ if (PMA_MYSQL_INT_VERSION >= 40100
+ || !(isset($cfg['AllowAnywhereRecoding']) && $cfg['AllowAnywhereRecoding'] && $allow_recoding)) {
+ /* No recoding -> return data as we got them */
+ return $data;
+ } else {
+ $ret = array();
+ $num = mysqli_num_fields($result);
+ $fields = mysqli_fetch_fields($result);
+ $i = 0;
+ for($i = 0; $i < $num; $i++) {
+ if (!$meta) {
+ /* No meta information available -> we guess that it should be converted */
+ if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
+ if (isset($data[$name])) $ret[PMA_convert_display_charset($name)] = PMA_convert_display_charset($data[$name]);
+ } else {
+ /* Meta information available -> check type of field and convert it according to the type */
+ if (stristr($fields[$i]->type, 'BLOB') || stristr($fields[$i]->type, 'BINARY')) {
+ if (isset($data[$i])) $ret[$i] = $data[$i];
+ if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = $data[$fields[$i]->name];
+ } else {
+ if (isset($data[$i])) $ret[$i] = PMA_convert_display_charset($data[$i]);
+ if (isset($data[$fields[$i]->name])) $ret[PMA_convert_display_charset($fields[$i]->name)] = PMA_convert_display_charset($data[$fields[$i]->name]);
+ }
+ }
+ }
+ return $ret;
+ }
+}
+
+function PMA_DBI_fetch_assoc($result) {
+ return PMA_mysqli_fetch_array($result, MYSQLI_ASSOC);
+}
+
+function PMA_DBI_fetch_row($result) {
+ return PMA_mysqli_fetch_array($result, MYSQLI_NUM);
+}
+
+function PMA_DBI_free_result($result) {
+ return @mysqli_free_result($result);
+}
+
+function PMA_DBI_getError($link = '') {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ $error = mysqli_errno($link);
+ if ($error && PMA_MYSQL_INT_VERSION >= 40100) {
+ $error = '#' . ((string) $error) . ' - ' . mysqli_error($link);
+ } elseif ($error) {
+ $error = '#' . ((string) $error) . ' - ' . PMA_convert_display_charset(mysqli_error($link));
+ }
+ return $error;
+}
+
+function PMA_DBI_close($link = '') {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ return @mysqli_close($link);
+}
+
+function PMA_DBI_num_rows($result) {
+ return @mysqli_num_rows($result);
+}
+
+function PMA_DBI_insert_id($link) {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ return mysqli_insert_id($link);
+}
+
+function PMA_DBI_affected_rows($link) {
+ if (empty($link)) {
+ if (isset($GLOBALS['userlink'])) {
+ $link = $GLOBALS['userlink'];
+ } else {
+ return FALSE;
+ }
+ }
+ return mysqli_affected_rows($link);
+}
+
+function PMA_DBI_get_fields_meta($result) {
+ return mysqli_fetch_fields($result);
+}
+
+?>
View
28 libraries/display_tbl.lib.php
@@ -485,13 +485,12 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
isset($analyzed_sql[0]['table_ref']) && count($analyzed_sql[0]['table_ref']) == 1) {
// grab indexes data:
- $local_query = 'SHOW KEYS FROM ' . PMA_backquote($table);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $err_url_0);
- $idx_cnt = PMA_DBI_num_rows($result);
+ $result = PMA_DBI_query('SHOW KEYS FROM ' . PMA_backquote($table) . ';');
+ $idx_cnt = PMA_DBI_num_rows($result);
$prev_index = '';
for ($i = 0; $i < $idx_cnt; $i++) {
- $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_mysql_fetch_array($result));
+ $row = (defined('PMA_IDX_INCLUDED') ? $ret_keys[$i] : PMA_DBI_fetch_assoc($result));
if ($row['Key_name'] != $prev_index ){
$indexes[] = $row['Key_name'];
@@ -749,7 +748,7 @@ function PMA_displayTableHeaders(&$is_display, &$fields_meta, $fields_cnt = 0, $
// FROM `PMA_relation` AS `1` , `PMA_relation` AS `2`
if (($is_join
- && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_stt[1], $parts))
+ && !preg_match('~([^[:space:],]|`[^`]`)[[:space:]]+(as[[:space:]]+)?' . $fields_meta[$i]->name . '~i', $select_stt[1], $parts))
|| ( isset($analyzed_sql[0]['select_expr'][$i]['expr'])
&& isset($analyzed_sql[0]['select_expr'][$i]['column'])
&& $analyzed_sql[0]['select_expr'][$i]['expr'] !=
@@ -974,7 +973,10 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// loic1: use 'PMA_mysql_fetch_array' rather than 'PMA_mysql_fetch_row'
// to get the NULL values
- while ($row = PMA_mysql_fetch_array($dt_result)) {
+ // rabus: This function needs a little rework.
+ // Using MYSQL_BOTH just pollutes the memory!
+
+ while ($row = PMA_mysql_fetch_array($dt_result)) { // !UNWRAPPED FUNCTION!
// lem9: "vertical display" mode stuff
if (($row_no != 0) && ($repeat_cells != 0) && !($row_no % $repeat_cells) && ($disp_direction == 'horizontal' || $disp_direction == 'horizontalflipped')) {
@@ -1029,7 +1031,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// "primary" key to use in links
if ($is_display['edit_lnk'] == 'ur' /* || $is_display['edit_lnk'] == 'dr' */) {
for ($i = 0; $i < $fields_cnt; ++$i) {
- $field_flags = PMA_mysql_field_flags($dt_result, $i);
+ $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
$meta = $fields_meta[$i];
// do not use an alias in a condition
@@ -1300,9 +1302,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = ' . $row[$pointer];
- $dispresult = PMA_mysql_query($dispsql);
+ $dispresult = PMA_DBI_try_query($dispsql);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
- $dispval = PMA_mysql_result($dispresult, 0);
+ list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
}
else {
$dispval = $GLOBALS['strLinkNotFound'];
@@ -1338,7 +1340,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
// TEXT fields type, however TEXT fields must be displayed
// even if $cfg['ShowBlob'] is false -> get the true type
// of the fields.
- $field_flags = PMA_mysql_field_flags($dt_result, $i);
+ $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
if (stristr($field_flags, 'BINARY')) {
$blobtext = '[BLOB';
if (isset($row[$pointer])) {
@@ -1385,7 +1387,7 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
}
// loic1: displays special characters from binaries
- $field_flags = PMA_mysql_field_flags($dt_result, $i);
+ $field_flags = PMA_mysql_field_flags($dt_result, $i); // !UNWRAPPED FUNCTION!
if (stristr($field_flags, 'BINARY')) {
$row[$pointer] = str_replace("\x00", '\0', $row[$pointer]);
$row[$pointer] = str_replace("\x08", '\b', $row[$pointer]);
@@ -1427,9 +1429,9 @@ function PMA_displayTableBody(&$dt_result, &$is_display, $map, $analyzed_sql)
. ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0])
. ' WHERE ' . PMA_backquote($map[$meta->name][1])
. ' = \'' . PMA_sqlAddslashes($row[$pointer]) . '\'';
- $dispresult = @PMA_mysql_query($dispsql);
+ $dispresult = PMA_DBI_try_query($dispsql);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
- $dispval = PMA_mysql_result($dispresult, 0);
+ list($dispval) = PMA_DBI_fetch_row($dispresult);
}
else {
$dispval = $GLOBALS['strLinkNotFound'];
View
10 libraries/export/csv.php
@@ -113,18 +113,18 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
global $escaped;
// Gets the data from the database
- $result = PMA_mysql_query($sql_query) or PMA_mysqlDie('', $sql_query, '', $error_url);
- $fields_cnt = mysql_num_fields($result);
+ $result = PMA_DBI_query($sql_query);
+ $fields_cnt = PMA_DBI_num_fields($result);
// If required, get fields name at the first line
if (isset($GLOBALS['showcsvnames']) && $GLOBALS['showcsvnames'] == 'yes') {
$schema_insert = '';
for ($i = 0; $i < $fields_cnt; $i++) {
if ($enclosed == '') {
- $schema_insert .= stripslashes(mysql_field_name($result, $i));
+ $schema_insert .= stripslashes(mysql_field_name($result, $i)); //! UNWRAPPED FUNCTION!
} else {
$schema_insert .= $enclosed
- . str_replace($enclosed, $escaped . $enclosed, stripslashes(mysql_field_name($result, $i)))
+ . str_replace($enclosed, $escaped . $enclosed, stripslashes(mysql_field_name($result, $i))) //! UNWRAPPED FUNCTION!
. $enclosed;
}
$schema_insert .= $separator;
@@ -134,7 +134,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
} // end if
// Format the data
- while ($row = PMA_mysql_fetch_row($result)) {
+ while ($row = PMA_DBI_fetch_row($result)) {
$schema_insert = '';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j])) {
View
12 libraries/export/latex.php
@@ -159,7 +159,7 @@ function PMA_exportData($db, $table, $crlf, $error_url, $sql_query) {
}
// print the whole table
- while ($record = PMA_mysql_fetch_array($result, MYSQL_ASSOC)) {
+ while ($record = PMA_DBI_fetch_assoc($result)) {
$buffer = '';
// print each row
@@ -212,9 +212,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
/**
* Gets fields properties
*/
- PMA_mysql_select_db($db);
+ PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
- $result = PMA_mysql_query($local_query) or PMA_mysqlDie('', $local_query, '', $error_url);
+ $result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
@@ -237,9 +237,9 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM '. PMA_backquote($db);
- $keys_result = PMA_mysql_query($keys_query) or PMA_mysqlDie('', $keys_query, '', $error_url);
+ $keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
- while($key = PMA_mysql_fetch_array($keys_result)) {
+ while($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) $unique_keys[] = $key['Column_name'];
}
@@ -298,7 +298,7 @@ function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = fals
if (!PMA_exportOutputHandler($buffer)) return FALSE;
- while ($row = PMA_mysql_fetch_array($result)) {
+ while ($row = PMA_DBI_fetch_assoc($result)) {
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
View
26 libraries/export/sql.php
@@ -21,9 +21,9 @@
* even for 'text' fields.
*/
function PMA_fieldTypes($db, $table,$use_backquotes) {
- PMA_mysql_select_db($db);
- $table_def = PMA_mysql_query('SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
- while($row = @PMA_mysql_fetch_array($table_def)) {
+ PMA_DBI_select_db($db);
+ $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
+ while($row = PMA_DBI_fetch_assoc($table_def)) {
$types[PMA_backquote($row['Field'],$use_backquotes)] = ereg_replace('\\(.*', '', $row['Type']);
}
return $types;
@@ -154,10 +154,10 @@ function PMA_getTableDef($db, $table, $crlf, $error_url, $show_dates = false)
$new_crlf = $crlf;
- $result = PMA_mysql_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table) . '\'