From 3102a23c0940ea234ca017f7d22191c31d1e0565 Mon Sep 17 00:00:00 2001 From: "Alexander M. Turek" Date: Sat, 14 Feb 2004 00:36:14 +0000 Subject: [PATCH] Introduced options parameter for query functions. --- ChangeLog | 5 +++++ libraries/database_interface.lib.php | 21 ++++++++++++++------- libraries/dbi/mysql.dbi.lib.php | 10 +++++----- libraries/dbi/mysqli.dbi.lib.php | 18 ++++++++++++------ libraries/mysql_charsets.lib.php | 2 +- 5 files changed, 37 insertions(+), 19 deletions(-) diff --git a/ChangeLog b/ChangeLog index a8137774a..b29596284 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,6 +5,11 @@ phpMyAdmin - Changelog $Id$ $Source$ +2004-02-14 Alexander M. Turek + * libraries/database_interface.lib.php, libraries/dbi/*.dbi.lib.php: + Introduced options parameter for query functions. + * libraries/mysql_charsets.lib.php: Fixed a "MySQL out of sync" error. + 2004-02-13 Alexander M. Turek * libraries/common.lib.php: Fixed bug #890186 (PMA chokes on undefined parser functions if one of the very first queries fails. diff --git a/libraries/database_interface.lib.php b/libraries/database_interface.lib.php index 35dc18317..f7f28d190 100644 --- a/libraries/database_interface.lib.php +++ b/libraries/database_interface.lib.php @@ -2,15 +2,22 @@ /* $Id$ */ // vim: expandtab sw=4 ts=4 sts=4: +/** + * Common Option Constants For DBI Functions + */ +define('PMA_DBI_QUERY_STORE', 1); // Force STORE_RESULT method, ignored by classic MySQL. + +/** + * Including The DBI Plugin + */ require_once('./libraries/dbi/' . $cfg['Server']['extension'] . '.dbi.lib.php'); -function PMA_DBI_query($query, $dbh = '') { - if (empty($dbh)) { - $dbh = $GLOBALS['userlink']; - } - - $res = PMA_DBI_try_query($query, $dbh) - or PMA_mysqlDie(PMA_DBI_getError($dbh), $query); +/** + * Common Functions + */ +function PMA_DBI_query($query, $link = NULL, $options = 0) { + $res = PMA_DBI_try_query($query, $link, $options) + or PMA_mysqlDie(PMA_DBI_getError(), $query); return $res; } diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index d415567c0..2b74c3d1b 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -89,7 +89,7 @@ function PMA_DBI_connect($user, $password) { return $link; } -function PMA_DBI_select_db($dbname, $link = '') { +function PMA_DBI_select_db($dbname, $link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -103,7 +103,7 @@ function PMA_DBI_select_db($dbname, $link = '') { return mysql_select_db($dbname, $link); } -function PMA_DBI_try_query($query, $link = '') { +function PMA_DBI_try_query($query, $link = NULL, $options = 0) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -169,7 +169,7 @@ function PMA_DBI_free_result($result) { return @mysql_free_result($result); } -function PMA_DBI_getError($link = '') { +function PMA_DBI_getError($link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -186,7 +186,7 @@ function PMA_DBI_getError($link = '') { return $error; } -function PMA_DBI_close($link = '') { +function PMA_DBI_close($link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -201,7 +201,7 @@ function PMA_DBI_num_rows($result) { return mysql_num_rows($result); } -function PMA_DBI_insert_id($link = '') { +function PMA_DBI_insert_id($link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index 6cf185865..7d0d30e98 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -76,7 +76,7 @@ function PMA_DBI_connect($user, $password) { return $link; } -function PMA_DBI_select_db($dbname, $link = '') { +function PMA_DBI_select_db($dbname, $link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -90,7 +90,13 @@ function PMA_DBI_select_db($dbname, $link = '') { return mysqli_select_db($link, $dbname); } -function PMA_DBI_try_query($query, $link = '') { +function PMA_DBI_try_query($query, $link = NULL, $options = 0) { + if ($options == $options | PMA_DBI_QUERY_STORE) { + $method = MYSQLI_STORE_RESULT; + } else { + $method = MYSQLI_USE_RESULT; + } + if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -101,7 +107,7 @@ function PMA_DBI_try_query($query, $link = '') { if (PMA_MYSQL_INT_VERSION < 40100) { $query = PMA_convert_charset($query); } - return mysqli_query($link, $query, MYSQLI_USE_RESULT); + return mysqli_query($link, $query, $method); } // The following function is meant for internal use only. @@ -155,7 +161,7 @@ function PMA_DBI_free_result($result) { return @mysqli_free_result($result); } -function PMA_DBI_getError($link = '') { +function PMA_DBI_getError($link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -172,7 +178,7 @@ function PMA_DBI_getError($link = '') { return $error; } -function PMA_DBI_close($link = '') { +function PMA_DBI_close($link = NULL) { if (empty($link)) { if (isset($GLOBALS['userlink'])) { $link = $GLOBALS['userlink']; @@ -217,4 +223,4 @@ function PMA_DBI_num_fields($result) { return mysqli_num_fields($result); } -?> +?> \ No newline at end of file diff --git a/libraries/mysql_charsets.lib.php b/libraries/mysql_charsets.lib.php index ab5f07104..1d5d28942 100644 --- a/libraries/mysql_charsets.lib.php +++ b/libraries/mysql_charsets.lib.php @@ -231,7 +231,7 @@ if (PMA_MYSQL_INT_VERSION >= 40100){ // MySQL 4.1.0 does not support seperate charset settings // for databases. - $res = PMA_DBI_query('SHOW CREATE DATABASE ' . PMA_backquote($db) . ';'); + $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); PMA_DBI_free_result($res);