Changed some queries to use MYSQLI_STORE_RESULT.

phpMyAdmin now works with MYSQLI_USE_RESULT as default.
This commit is contained in:
Marcel Tschopp
2004-04-10 16:19:21 +00:00
parent b2e3128634
commit 4e62f7658f
22 changed files with 42 additions and 32 deletions

View File

@@ -5,6 +5,17 @@ phpMyAdmin - Changelog
$Id$ $Id$
$Source$ $Source$
2004-04-10 Marcel Tschopp <marcel.tschopp@gmx.net>
db_datadict.php, db_details_db_info.php, db_details_qbe.php,
db_details_structure.php, db_printview.php, left.php, main.php,
pdf_pages.php, read_dump.php, server_privileges.php, sql.php,
tbl_change.php, tbl_indexes.php, tbl_properties_structure.php,
tbl_relation.php, tbl_select.php, libraries/database_interface.lib.php,
libraries/db_table_exists.lib.php, libraries/mysql_charsets.lib.php,
libraries/relation.lib.php, libraries/dbi/mysqli.dbi.lib.php:
Changed some queries to use MYSQLI_STORE_RESULT. phpMyAdmin now works
with MYSQLI_USE_RESULT as default.
2004-04-07 Marc Delisle <lem9@users.sourceforge.net> 2004-04-07 Marc Delisle <lem9@users.sourceforge.net>
* tbl_select.php, lang/*: feature 788608: new features for Search: * tbl_select.php, lang/*: feature 788608: new features for Search:
DISTINCT, IS NULL, IS NOT NULL, NOT LIKE, multiple select for ENUM, DISTINCT, IS NULL, IS NOT NULL, NOT LIKE, multiple select for ENUM,

View File

@@ -53,7 +53,7 @@ if ($cfgRelation['commwork']) {
* Selects the database and gets tables names * Selects the database and gets tables names
*/ */
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $rowset = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$count = 0; $count = 0;
while ($row = PMA_DBI_fetch_assoc($rowset)) { while ($row = PMA_DBI_fetch_assoc($rowset)) {

View File

@@ -30,7 +30,7 @@ if ($cfg['SkipLockedTables'] == TRUE) {
PMA_DBI_free_result($db_info_result); PMA_DBI_free_result($db_info_result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $db_info_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) { while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {
@@ -48,14 +48,14 @@ if ($cfg['SkipLockedTables'] == TRUE) {
} }
} }
if (!isset($sot_ready)) { if (!isset($sot_ready)) {
$db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';'); $db_info_result = PMA_DBI_query('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) { if ($db_info_result != FALSE && PMA_DBI_num_rows($db_info_result) > 0) {
while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) { while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) {
$tables[] = $sts_tmp; $tables[] = $sts_tmp;
} }
PMA_DBI_free_result($db_info_result);
unset($db_info_result);
} }
@PMA_DBI_free_result($db_info_result);
unset($db_info_result);
} }
$num_tables = (isset($tables) ? count($tables) : 0); $num_tables = (isset($tables) ? count($tables) : 0);

View File

@@ -114,7 +114,7 @@ if ($row < 0) {
/** /**
* Prepares the form * Prepares the form
*/ */
$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result); $tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
$i = 0; $i = 0;
$k = 0; $k = 0;

View File

@@ -76,7 +76,6 @@ if (isset($db) && isset($db_rename) && $db_rename == 'true') {
$db = $newname; $db = $newname;
} }
} }
/** /**
* Prepares the tables list if the user where not redirected to this script * Prepares the tables list if the user where not redirected to this script
* because there is no table in the database ($is_info is TRUE) * because there is no table in the database ($is_info is TRUE)
@@ -243,6 +242,8 @@ else {
} }
} // end while } // end while
PMA_DBI_free_result($result);
unset($result);
} // end if } // end if
if ($cfgRelation['commwork']) { if ($cfgRelation['commwork']) {

View File

@@ -45,7 +45,7 @@ if ($cfg['SkipLockedTables'] == TRUE) {
unset($result); unset($result);
if (isset($sot_cache)) { if (isset($sot_cache)) {
$result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
if ($result != FALSE && PMA_DBI_num_rows($result) > 0) { if ($result != FALSE && PMA_DBI_num_rows($result) > 0) {
while ($tmp = PMA_DBI_fetch_row($result)) { while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) { if (!isset($sot_cache[$tmp[0]])) {

View File

@@ -417,7 +417,7 @@ if ($num_dbs > 1) {
if (!empty($db_start) && $db == $db_start) { if (!empty($db_start) && $db == $db_start) {
$selected_db = $j; $selected_db = $j;
} }
$tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db); $common_url_query = PMA_generate_common_url($db);
if ($num_tables) { if ($num_tables) {
@@ -641,7 +641,7 @@ if ($num_dbs > 1) {
// Case where only one database has to be displayed // Case where only one database has to be displayed
else if ($num_dbs == 1) { else if ($num_dbs == 1) {
$db = $dblist[0]; $db = $dblist[0];
$tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $tables = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0; $num_tables = ($tables) ? @PMA_DBI_num_rows($tables) : 0;
$common_url_query = PMA_generate_common_url($db); $common_url_query = PMA_generate_common_url($db);
if ($num_tables) { if ($num_tables) {

View File

@@ -52,7 +52,7 @@ function PMA_DBI_get_dblist($link = NULL) {
} }
function PMA_DBI_get_tables($database, $link = NULL) { function PMA_DBI_get_tables($database, $link = NULL) {
$result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';'); $result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($database) . ';', NULL, PMA_DBI_QUERY_STORE);
$tables = array(); $tables = array();
while (list($current) = PMA_DBI_fetch_row($result)) { while (list($current) = PMA_DBI_fetch_row($result)) {
$tables[] = $current; $tables[] = $current;

View File

@@ -22,7 +22,7 @@ if (!isset($is_db) || !$is_db) {
if (!isset($is_table) || !$is_table) { if (!isset($is_table) || !$is_table) {
// Not a valid table name -> back to the db_details.php // Not a valid table name -> back to the db_details.php
if (!empty($table)) { if (!empty($table)) {
$is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE);
} }
if (empty($table) if (empty($table)
|| !($is_table && @PMA_DBI_num_rows($is_table))) { || !($is_table && @PMA_DBI_num_rows($is_table))) {

View File

@@ -97,7 +97,7 @@ function PMA_DBI_try_query($query, $link = NULL, $options = 0) {
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) { } elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
$method = MYSQLI_USE_RESULT; $method = MYSQLI_USE_RESULT;
} else { } else {
$method = MYSQLI_STORE_RESULT; $method = MYSQLI_USE_RESULT;
} }
if (empty($link)) { if (empty($link)) {

View File

@@ -226,11 +226,9 @@ if (PMA_MYSQL_INT_VERSION >= 40100){
function PMA_getDbCollation($db) { function PMA_getDbCollation($db) {
global $userlink; global $userlink;
if (PMA_MYSQL_INT_VERSION >= 40101) { if (PMA_MYSQL_INT_VERSION >= 40101) {
// MySQL 4.1.0 does not support seperate charset settings // MySQL 4.1.0 does not support seperate charset settings
// for databases. // for databases.
$res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE); $res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$row = PMA_DBI_fetch_row($res); $row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res); PMA_DBI_free_result($res);

View File

@@ -104,7 +104,7 @@ function PMA_getRelationsParam($verbose = FALSE)
// PMA_DBI_select_db($cfgRelation['db']); // PMA_DBI_select_db($cfgRelation['db']);
$tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']); $tab_query = 'SHOW TABLES FROM ' . PMA_backquote($cfgRelation['db']);
$tab_rs = PMA_query_as_cu($tab_query, FALSE); $tab_rs = PMA_query_as_cu($tab_query, NULL, PMA_DBI_QUERY_STORE);
while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) { while ($curr_table = @PMA_DBI_fetch_row($tab_rs)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) { if ($curr_table[0] == $cfg['Server']['bookmarktable']) {

View File

@@ -180,7 +180,7 @@ if ($server > 0) {
// We were checking privileges with 'USE mysql' but users with the global // We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql' // priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (even if they cannot see the tables) // (even if they cannot see the tables)
$is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $userlink); $is_superuser = PMA_DBI_try_query('SELECT COUNT(*) FROM mysql.user', $userlink, PMA_DBI_QUERY_STORE);
if ($dbh) { if ($dbh) {
$local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\''; $local_query = 'SELECT Create_priv, Reload_priv FROM mysql.user WHERE User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\'';
$rs_usr = PMA_DBI_try_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE); $rs_usr = PMA_DBI_try_query($local_query, $dbh); // Debug: or PMA_mysqlDie('', $local_query, FALSE);
@@ -201,7 +201,7 @@ if ($server > 0) {
// the first inexistant db name that we find, in most cases it's probably // the first inexistant db name that we find, in most cases it's probably
// the one he just dropped :) // the one he just dropped :)
if (!$is_create_priv) { if (!$is_create_priv) {
$rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh); $rs_usr = PMA_DBI_try_query('SELECT DISTINCT Db FROM mysql.db WHERE Create_priv = \'Y\' AND User = \'' . PMA_sqlAddslashes($mysql_cur_user) . '\';', $dbh, PMA_DBI_QUERY_STORE);
if ($rs_usr) { if ($rs_usr) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards $re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards $re1 = '(^|[^\])(\\\)+'; // escaped wildcards
@@ -221,11 +221,11 @@ if ($server > 0) {
// Finally, let's try to get the user's privileges by using SHOW // Finally, let's try to get the user's privileges by using SHOW
// GRANTS... // GRANTS...
// Maybe we'll find a little CREATE priv there :) // Maybe we'll find a little CREATE priv there :)
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh); $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user_and_host . ';', $dbh, PMA_DBI_QUERY_STORE);
if (!$rs_usr) { if (!$rs_usr) {
// OK, now we'd have to guess the user's hostname, but we // OK, now we'd have to guess the user's hostname, but we
// only try out the 'username'@'%' case. // only try out the 'username'@'%' case.
$rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh); $rs_usr = PMA_DBI_try_query('SHOW GRANTS FOR ' . $mysql_cur_user . ';', $dbh, PMA_DBI_QUERY_STORE);
} }
unset($local_query); unset($local_query);
if ($rs_usr) { if ($rs_usr) {

View File

@@ -221,7 +221,7 @@ if ($cfgRelation['pdfwork']) {
// We will need an array of all tables in this db // We will need an array of all tables in this db
$selectboxall = array('--'); $selectboxall = array('--');
$alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';'); $alltab_rs = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
while ($val = @PMA_DBI_fetch_row($alltab_rs)) { while ($val = @PMA_DBI_fetch_row($alltab_rs)) {
$selectboxall[] = $val[0]; $selectboxall[] = $val[0];
} }

View File

@@ -346,7 +346,7 @@ if ($goto == 'tbl_properties.php') {
$goto = 'db_details.php'; $goto = 'db_details.php';
} else { } else {
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = PMA_DBI_try_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE);
if (!($is_table && @PMA_DBI_num_rows($is_table))) { if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php'; $goto = 'db_details.php';
unset($table); unset($table);

View File

@@ -1175,7 +1175,7 @@ if (empty($adduser) && empty($checkprivs)) {
} else { } else {
echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n" echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\n"
. ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n"; . ' <label for="text_tablename">' . $strAddPrivilegesOnTbl . ':</label>' . "\n";
if ($res = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';')) { if ($res = PMA_DBI_try_query('SHOW TABLES FROM ' . PMA_backquote($dbname) . ';', NULL, PMA_DBI_QUERY_STORE)) {
$pred_tbl_array = array(); $pred_tbl_array = array();
while ($row = PMA_DBI_fetch_row($res)) { while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) { if (!isset($found_rows) || !in_array($row[0], $found_rows)) {

View File

@@ -319,7 +319,7 @@ else {
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ',microtime());
$querytime_before = ((float)$usec + (float)$sec); $querytime_before = ((float)$usec + (float)$sec);
$result = @PMA_DBI_try_query($full_sql_query); $result = @PMA_DBI_try_query($full_sql_query, NULL, true);
list($usec, $sec) = explode(' ',microtime()); list($usec, $sec) = explode(' ',microtime());
$querytime_after = ((float)$usec + (float)$sec); $querytime_after = ((float)$usec + (float)$sec);
@@ -563,7 +563,7 @@ else {
if (!isset($table)) { if (!isset($table)) {
$goto = 'db_details.php'; $goto = 'db_details.php';
} else { } else {
$is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';'); $is_table = @PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\';', NULL, PMA_DBI_QUERY_STORE);
if (!($is_table && @PMA_DBI_num_rows($is_table))) { if (!($is_table && @PMA_DBI_num_rows($is_table))) {
$goto = 'db_details.php'; $goto = 'db_details.php';
unset($table); unset($table);

View File

@@ -74,12 +74,11 @@ $url_query = PMA_generate_common_url($db, $table)
require('./tbl_properties_table_info.php'); require('./tbl_properties_table_info.php');
echo '<br />'; echo '<br />';
/** /**
* Get the list of the fields of the current table * Get the list of the fields of the current table
*/ */
PMA_DBI_select_db($db); PMA_DBI_select_db($db);
$table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';'); $table_def = PMA_DBI_query('SHOW FIELDS FROM ' . PMA_backquote($table) . ';', NULL, PMA_DBI_QUERY_STORE);
if (isset($primary_key)) { if (isset($primary_key)) {
if (is_array($primary_key)) { if (is_array($primary_key)) {
$primary_key_array = $primary_key; $primary_key_array = $primary_key;
@@ -91,8 +90,9 @@ if (isset($primary_key)) {
$result = array(); $result = array();
foreach($primary_key_array AS $rowcount => $primary_key) { foreach($primary_key_array AS $rowcount => $primary_key) {
$local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';'; $local_query = 'SELECT * FROM ' . PMA_backquote($table) . ' WHERE ' . $primary_key . ';';
$result[$rowcount] = PMA_DBI_query($local_query); $result[$rowcount] = PMA_DBI_query($local_query, NULL, PMA_DBI_QUERY_STORE);
$row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]); $row[$rowcount] = PMA_DBI_fetch_assoc($result[$rowcount]);
//PMA_DBI_free_result($result[$rowcount]);
$primary_keys[$rowcount] = $primary_key; $primary_keys[$rowcount] = $primary_key;
// No row returned // No row returned

View File

@@ -37,7 +37,7 @@ if (!defined('PMA_IDX_INCLUDED')) {
} }
// Not a valid table name -> back to the default db_details sub-page // Not a valid table name -> back to the default db_details sub-page
if (!empty($table)) { if (!empty($table)) {
$is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\''); $is_table = PMA_DBI_query('SHOW TABLES LIKE \'' . PMA_sqlAddslashes($table, TRUE) . '\'', NULL, PMA_DBI_QUERY_STORE);
} }
if (empty($table) if (empty($table)
|| !($is_table && PMA_DBI_num_rows($is_table))) { || !($is_table && PMA_DBI_num_rows($is_table))) {

View File

@@ -34,7 +34,7 @@ $url_query .= '&amp;goto=tbl_properties_structure.php&amp;back=tbl_properties_st
/** /**
* Prepares the table structure display * Prepares the table structure display
*/ */
// 1. Get table information/display tabs // 1. Get table information/display tabs;
require('./tbl_properties_table_info.php'); require('./tbl_properties_table_info.php');
/** /**

View File

@@ -269,7 +269,7 @@ if ($cfgRelation['relwork']) {
} }
// [0] of the row is the name // [0] of the row is the name
$tab_rs = PMA_DBI_query($tab_query); $tab_rs = PMA_DBI_query($tab_query, NULL, PMA_DBI_QUERY_STORE);
$selectboxall['nix'] = '--'; $selectboxall['nix'] = '--';
$selectboxall_innodb['nix'] = '--'; $selectboxall_innodb['nix'] = '--';

View File

@@ -61,7 +61,7 @@ if (!isset($param) || $param[0] == '') {
$err_url = $goto . '?' . PMA_generate_common_url($db, $table); $err_url = $goto . '?' . PMA_generate_common_url($db, $table);
// Gets the list and number of fields // Gets the list and number of fields
$result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';'); $result = PMA_DBI_query('SHOW' . (PMA_MYSQL_INT_VERSION >= 40100 ? ' FULL' : '') . ' FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$fields_cnt = PMA_DBI_num_rows($result); $fields_cnt = PMA_DBI_num_rows($result);
while ($row = PMA_DBI_fetch_assoc($result)) { while ($row = PMA_DBI_fetch_assoc($result)) {
$fields_list[] = $row['Field']; $fields_list[] = $row['Field'];