From c6709f67829d973a76c1538b5a3dcd8cf88399c1 Mon Sep 17 00:00:00 2001 From: Clemens Schwaighofer Date: Tue, 9 Dec 2014 14:04:14 +0900 Subject: [PATCH] Add reset/check for query call count Whenever a query is executed without the db_return method and it is a select query, then it is counted and if it is over a max value it will return false and terminate. With those functions that counter value can be checked and reset. To be used carefully. It is recommended to rather make often called queries with the same values prepare/execute style instead of resetting the count. --- www/libs/Class.DB.IO.inc | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/www/libs/Class.DB.IO.inc b/www/libs/Class.DB.IO.inc index aec6f15c..932d012b 100644 --- a/www/libs/Class.DB.IO.inc +++ b/www/libs/Class.DB.IO.inc @@ -758,6 +758,29 @@ // PUBLIC METHODS // ************************************************************* + // METHOD db_reset_query_called + // PARAMS query + // RETURN none + // DESC resets the call times for the max query called to 0 + // USE CAREFULLY: rather make the query prepare -> execute + public function db_reset_query_called($query) + { + $this->query_called[md5($query)] = 0; + } + + // METHOD db_get_query_called + // PARAMS query + // RETURN count of query called + // DESC gets how often a query was called already + public function db_get_query_called($query) + { + $md5 = md5($query); + if ($this->query_called[$md5]) + return $this->query_called[$md5]; + else + return 0; + } + // METHOD db_close // PARAMS none // RETURN none