dblayeroo : Add meta support to do analyzis

git-svn-id: https://svn.fournier38.fr/svn/ProgSVN/trunk@5088 bf3deb0d-5f1a-0410-827f-c0cc1f45334c
This commit is contained in:
2019-03-08 08:11:05 +00:00
parent fbb7991a1f
commit cacf466567

View File

@@ -55,6 +55,11 @@ class dblayeroo
// Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/ // Based on an idea of http://tonylandis.com/php/php5-pdo-singleton-class/
private static $instance = array (); 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 /** Connection to the database engine
* See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format * See http://fr2.php.net/manual/en/pdo.construct.php for the $dsn format
* @param string $dsn PDO Data Source Name * @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 /// /// MANAGE THE REQUEST BY OOP ///
@@ -3157,7 +3171,14 @@ class dblayeroo
$this->debugLog ("Entering prepareRequest (XXX, ",false,")"); $this->debugLog ("Entering prepareRequest (XXX, ",false,")");
$st = $this->prepareRequest ($sql, false); $st = $this->prepareRequest ($sql, false);
$this->debugLog ("'",$this->getDisplayQuery (),"'"); $this->debugLog ("'",$this->getDisplayQuery (),"'");
$startTime = microtime (true);
$st->execute (); $st->execute ();
self::$meta[] = array (
"command" => $this->command,
"sql" => $sql,
"sqltime" => microtime (true) - $startTime,
"displayQuery" => $this->getDisplayQuery (),
);
switch ($this->command) switch ($this->command)
{ {
case "SELECT": case "SELECT":