From 12f1164148a6331a93e0b1f58a4beed227cf2d0c Mon Sep 17 00:00:00 2001 From: Sebastian Mendel Date: Fri, 9 Dec 2005 10:04:01 +0000 Subject: [PATCH] PMA_DBI_free_result() now accepts more than one resource to be freed --- ChangeLog | 8 ++++++-- libraries/dbi/mysql.dbi.lib.php | 16 +++++++++++----- libraries/dbi/mysqli.dbi.lib.php | 16 +++++++++++----- 3 files changed, 28 insertions(+), 12 deletions(-) diff --git a/ChangeLog b/ChangeLog index 83fafd9e2..d636d4766 100755 --- a/ChangeLog +++ b/ChangeLog @@ -5,8 +5,12 @@ phpMyAdmin - Changelog $Id$ $Source$ +2005-12-09 Sebastian Mendel + * libraries/dbi: + PMA_DBI_free_result() now accepts more than one resource to be freed + 2005-12-08 Marc Delisle - * scripts/setup.php: Typos + * scripts/setup.php: Typos * libraries/common.lib.php: unneeded parameter in PMA_safe_db_list() 2005-12-08 Michal Čihař @@ -25,7 +29,7 @@ $Source$ writable permissions, refuse to work with existing config dir. * lang/*, libraries/auth/config.auth.lib.php: Suggest to run setup script if auth with default values fails. - * libraries/grab_globals.lib.php: Do not choke on arrays in $_SERVER + * libraries/grab_globals.lib.php: Do not choke on arrays in $_SERVER array (bug #1370414). * libraries/sql_query_form.lib.php: Require bookmark code when we use it. * libraries/export/sql.php: Backquote database name (RFE#1376336). diff --git a/libraries/dbi/mysql.dbi.lib.php b/libraries/dbi/mysql.dbi.lib.php index 8890db954..43e730ed8 100644 --- a/libraries/dbi/mysql.dbi.lib.php +++ b/libraries/dbi/mysql.dbi.lib.php @@ -144,11 +144,17 @@ function PMA_DBI_fetch_row($result) { return PMA_mysql_fetch_array($result, MYSQL_NUM); } -function PMA_DBI_free_result($result) { - if (!is_bool($result)) { - return mysql_free_result($result); - } else { - return 0; +/** + * Frees the memory associated with the results + * + * @param result $result,... one or more mysql result resources + */ +function PMA_DBI_free_result() { + foreach ( func_get_args() as $result ) { + if ( is_resource($result) + && get_resource_type($result) === 'mysql result' ) { + mysqli_free_result($result); + } } } diff --git a/libraries/dbi/mysqli.dbi.lib.php b/libraries/dbi/mysqli.dbi.lib.php index af00b4dbb..6d411fb22 100644 --- a/libraries/dbi/mysqli.dbi.lib.php +++ b/libraries/dbi/mysqli.dbi.lib.php @@ -179,11 +179,17 @@ function PMA_DBI_fetch_row($result) { return PMA_mysqli_fetch_array($result, MYSQLI_NUM); } -function PMA_DBI_free_result($result) { - if (!is_bool($result)) { - return mysqli_free_result($result); - } else { - return 0; +/** + * Frees the memory associated with the results + * + * @param result $result,... one or more mysql result resources + */ +function PMA_DBI_free_result() { + foreach ( func_get_args() as $result ) { + if ( is_object($result) + && is_a($result, 'mysqli_result') ) { + mysqli_free_result($result); + } } }