Skip to content

Commit

Permalink
Changed some queries to use MYSQLI_STORE_RESULT.
Browse files Browse the repository at this point in the history
phpMyAdmin now works with MYSQLI_USE_RESULT as default.
  • Loading branch information
Marcel Tschopp committed Apr 10, 2004
1 parent b2e3128 commit 4e62f76
Show file tree
Hide file tree
Showing 22 changed files with 42 additions and 32 deletions.
11 changes: 11 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,17 @@ phpMyAdmin - Changelog
$Id$
$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>
* tbl_select.php, lang/*: feature 788608: new features for Search:
DISTINCT, IS NULL, IS NOT NULL, NOT LIKE, multiple select for ENUM,
Expand Down
2 changes: 1 addition & 1 deletion db_datadict.php
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
* Selects the database and gets tables names
*/
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;
while ($row = PMA_DBI_fetch_assoc($rowset)) {
Expand Down
8 changes: 4 additions & 4 deletions db_details_db_info.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
PMA_DBI_free_result($db_info_result);

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) {
while ($tmp = PMA_DBI_fetch_row($db_info_result)) {
if (!isset($sot_cache[$tmp[0]])) {
Expand All @@ -48,14 +48,14 @@
}
}
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) {
while ($sts_tmp = PMA_DBI_fetch_assoc($db_info_result)) {
$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);

Expand Down
2 changes: 1 addition & 1 deletion db_details_qbe.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@
/**
* 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);
$i = 0;
$k = 0;
Expand Down
3 changes: 2 additions & 1 deletion db_details_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,6 @@
$db = $newname;
}
}

/**
* 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)
Expand Down Expand Up @@ -243,6 +242,8 @@ function pma_TableHeader($alternate = FALSE) {
}

} // end while
PMA_DBI_free_result($result);
unset($result);
} // end if

if ($cfgRelation['commwork']) {
Expand Down
2 changes: 1 addition & 1 deletion db_printview.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
unset($result);

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) {
while ($tmp = PMA_DBI_fetch_row($result)) {
if (!isset($sot_cache[$tmp[0]])) {
Expand Down
4 changes: 2 additions & 2 deletions left.php
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ function PMA_nestedSet($baseid, $tablestack, $key = '__protected__', $keyhistory
if (!empty($db_start) && $db == $db_start) {
$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;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
Expand Down Expand Up @@ -641,7 +641,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_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;
$common_url_query = PMA_generate_common_url($db);
if ($num_tables) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/database_interface.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ function PMA_DBI_get_dblist($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();
while (list($current) = PMA_DBI_fetch_row($result)) {
$tables[] = $current;
Expand Down
2 changes: 1 addition & 1 deletion libraries/db_table_exists.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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_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)
|| !($is_table && @PMA_DBI_num_rows($is_table))) {
Expand Down
2 changes: 1 addition & 1 deletion libraries/dbi/mysqli.dbi.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ function PMA_DBI_try_query($query, $link = NULL, $options = 0) {
} elseif ($options == ($options | PMA_DBI_QUERY_UNBUFFERED)) {
$method = MYSQLI_USE_RESULT;
} else {
$method = MYSQLI_STORE_RESULT;
$method = MYSQLI_USE_RESULT;
}

if (empty($link)) {
Expand Down
2 changes: 0 additions & 2 deletions libraries/mysql_charsets.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ function PMA_getCollationDescr($collation) {

function PMA_getDbCollation($db) {
global $userlink;

if (PMA_MYSQL_INT_VERSION >= 40101) {
// MySQL 4.1.0 does not support seperate charset settings
// for databases.

$res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';', NULL, PMA_DBI_QUERY_STORE);
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
Expand Down
2 changes: 1 addition & 1 deletion libraries/relation.lib.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function PMA_getRelationsParam($verbose = FALSE)
// PMA_DBI_select_db($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)) {
if ($curr_table[0] == $cfg['Server']['bookmarktable']) {
Expand Down
8 changes: 4 additions & 4 deletions main.php
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@
// We were checking privileges with 'USE mysql' but users with the global
// priv CREATE TEMPORARY TABLES or LOCK TABLES can do a 'USE mysql'
// (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) {
$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);
Expand All @@ -201,7 +201,7 @@
// the first inexistant db name that we find, in most cases it's probably
// the one he just dropped :)
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) {
$re0 = '(^|(\\\\\\\\)+|[^\])'; // non-escaped wildcards
$re1 = '(^|[^\])(\\\)+'; // escaped wildcards
Expand All @@ -221,11 +221,11 @@
// Finally, let's try to get the user's privileges by using SHOW
// GRANTS...
// 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) {
// OK, now we'd have to guess the user's hostname, but we
// 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);
if ($rs_usr) {
Expand Down
2 changes: 1 addition & 1 deletion pdf_pages.php
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@

// We will need an array of all tables in this db
$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)) {
$selectboxall[] = $val[0];
}
Expand Down
2 changes: 1 addition & 1 deletion read_dump.php
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@
$goto = 'db_details.php';
} else {
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))) {
$goto = 'db_details.php';
unset($table);
Expand Down
2 changes: 1 addition & 1 deletion server_privileges.php
Original file line number Diff line number Diff line change
Expand Up @@ -1175,7 +1175,7 @@ function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
} else {
echo ' <input type="hidden" name="dbname" value="' . htmlspecialchars($dbname) . '"/>' . "\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();
while ($row = PMA_DBI_fetch_row($res)) {
if (!isset($found_rows) || !in_array($row[0], $found_rows)) {
Expand Down
4 changes: 2 additions & 2 deletions sql.php
Original file line number Diff line number Diff line change
Expand Up @@ -319,7 +319,7 @@
list($usec, $sec) = explode(' ',microtime());
$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());
$querytime_after = ((float)$usec + (float)$sec);
Expand Down Expand Up @@ -563,7 +563,7 @@
if (!isset($table)) {
$goto = 'db_details.php';
} 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))) {
$goto = 'db_details.php';
unset($table);
Expand Down
6 changes: 3 additions & 3 deletions tbl_change.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,11 @@
require('./tbl_properties_table_info.php');
echo '<br />';


/**
* Get the list of the fields of the current table
*/
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 (is_array($primary_key)) {
$primary_key_array = $primary_key;
Expand All @@ -91,8 +90,9 @@
$result = array();
foreach($primary_key_array AS $rowcount => $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]);
//PMA_DBI_free_result($result[$rowcount]);
$primary_keys[$rowcount] = $primary_key;

// No row returned
Expand Down
2 changes: 1 addition & 1 deletion tbl_indexes.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@
}
// Not a valid table name -> back to the default db_details sub-page
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)
|| !($is_table && PMA_DBI_num_rows($is_table))) {
Expand Down
2 changes: 1 addition & 1 deletion tbl_properties_structure.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@
/**
* Prepares the table structure display
*/
// 1. Get table information/display tabs
// 1. Get table information/display tabs;
require('./tbl_properties_table_info.php');

/**
Expand Down
2 changes: 1 addition & 1 deletion tbl_relation.php
Original file line number Diff line number Diff line change
Expand Up @@ -269,7 +269,7 @@ function PMA_generate_dropdown($dropdown_question,$radio_name,$choices,$selected
}
// [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_innodb['nix'] = '--';

Expand Down
2 changes: 1 addition & 1 deletion tbl_select.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
$err_url = $goto . '?' . PMA_generate_common_url($db, $table);

// 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);
while ($row = PMA_DBI_fetch_assoc($result)) {
$fields_list[] = $row['Field'];
Expand Down

0 comments on commit 4e62f76

Please sign in to comment.