From 540d55342413ed37346bf6c88929d08d61308f00 Mon Sep 17 00:00:00 2001 From: Dany De Bontridder Date: Thu, 19 Sep 2013 14:22:22 +0000 Subject: [PATCH] count accept a parameter, by default returns the number of rows of the last query --- include/class_database.php | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/include/class_database.php b/include/class_database.php index 2a0977fb5..68e3d0d57 100644 --- a/include/class_database.php +++ b/include/class_database.php @@ -347,17 +347,24 @@ class Database if ( $this->ret == false ) throw new Exception ('this->ret is empty'); return pg_fetch_array($this->ret,$p_indice ) ; } - /*!@brief return the number of rows found by the last query, - synomym for count()*/ - function size() + /*!@brief return the number of rows found by the last query, or the number + * of rows from $p_ret + * @param $p_ret is the result of a query, the default value is null, in that case + * it is related to the last query + * @note synomym for count() + */ + function size($p_ret = null) { - return pg_NumRows($this->ret); + if ($p_ret == null ) + return pg_NumRows($this->ret); + else + return pg_NumRows($p_ret); } /*!@brief return the number of rows found by the last query, synomym for size()*/ - function count() + function count($p_ret=null) { - return pg_NumRows($this->ret); + return $this->size($p_ret); } /*!\brief loop to apply all the path to a folder or