From 1be5275eefa26207c04f1e6e60d60bfb18aa97a3 Mon Sep 17 00:00:00 2001 From: Michael Date: Fri, 2 Mar 2018 13:37:49 +0000 Subject: [PATCH] Some more performance measuring for database stuff --- include/dba.php | 32 ++++++++++++++++++++++++++------ 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/include/dba.php b/include/dba.php index 1407c1c6f5..9ac26aaa10 100644 --- a/include/dba.php +++ b/include/dba.php @@ -664,16 +664,24 @@ class dba { * @return array current row */ public static function fetch($stmt) { + $a = get_app(); + + $stamp1 = microtime(true); + + $columns = []; + if (!is_object($stmt)) { return false; } switch (self::$driver) { case 'pdo': - return $stmt->fetch(PDO::FETCH_ASSOC); + $columns = $stmt->fetch(PDO::FETCH_ASSOC); + break; case 'mysqli': if (get_class($stmt) == 'mysqli_result') { - return $stmt->fetch_assoc(); + $columns = $stmt->fetch_assoc(); + break; } // This code works, but is slow @@ -698,12 +706,14 @@ class dba { $result = $stmt->result_metadata(); $fields = $result->fetch_fields(); - $columns = []; foreach ($cols_num AS $param => $col) { $columns[$fields[$param]->name] = $col; } - return $columns; } + + $a->save_timestamp($stamp1, 'database'); + + return $columns; } /** @@ -1287,17 +1297,27 @@ class dba { * @return boolean was the close successful? */ public static function close($stmt) { + $a = get_app(); + + $stamp1 = microtime(true); + if (!is_object($stmt)) { return false; } switch (self::$driver) { case 'pdo': - return $stmt->closeCursor(); + $ret = $stmt->closeCursor(); + break; case 'mysqli': $stmt->free_result(); - return $stmt->close(); + $ret = $stmt->close(); + break; } + + $a->save_timestamp($stamp1, 'database'); + + return $ret; } }