From cacf466567663d9946cea86a77f70332deb9d2e3 Mon Sep 17 00:00:00 2001 From: Dominique Fournier Date: Fri, 8 Mar 2019 08:11:05 +0000 Subject: [PATCH] dblayeroo : Add meta support to do analyzis git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5088 bf3deb0d-5f1a-0410-827f-c0cc1f45334c --- dblayeroo.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/dblayeroo.php b/dblayeroo.php index 19a3112..72c8f6a 100644 --- a/dblayeroo.php +++ b/dblayeroo.php @@ -55,6 +55,11 @@ class dblayeroo // Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/ private static $instance = array (); + /** Store each executed requests meta data to analyze the times, number of + * requests, debugging + */ + private static $meta = array (); + /** Connection to the database engine * See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format * @param string $dsn PDO Data Source Name @@ -1476,6 +1481,15 @@ class dblayeroo } // }}} + public function meta ($meta = null) + // {{{ + { + if ($meta === null) + return self::$meta; + self::$meta = array (); + return $this; + } + // }}} ///////////////////////////////////// /// MANAGE THE REQUEST BY OOP /// @@ -3157,7 +3171,14 @@ class dblayeroo $this->debugLog ("Entering prepareRequest (XXX, ",false,")"); $st = $this->prepareRequest ($sql, false); $this->debugLog ("'",$this->getDisplayQuery (),"'"); + $startTime = microtime (true); $st->execute (); + self::$meta[] = array ( + "command" => $this->command, + "sql" => $sql, + "sqltime" => microtime (true) - $startTime, + "displayQuery" => $this->getDisplayQuery (), + ); switch ($this->command) { case "SELECT":