From bb5f11ece7b9e21366d2d84bfef1dd996070ebf4 Mon Sep 17 00:00:00 2001 From: skodak Date: Tue, 28 Oct 2008 22:31:26 +0000 Subject: [PATCH] MDL-14990 dml: towards proper logging/perf infrastructure --- lib/dml/moodle_database.php | 48 ++++++++++++++++++++++++++++++------- 1 file changed, 39 insertions(+), 9 deletions(-) diff --git a/lib/dml/moodle_database.php b/lib/dml/moodle_database.php index 6cea81570bc..b1dfe102f3c 100644 --- a/lib/dml/moodle_database.php +++ b/lib/dml/moodle_database.php @@ -5,21 +5,31 @@ require_once($CFG->libdir.'/dml/moodle_recordset.php'); /// GLOBAL CONSTANTS ///////////////////////////////////////////////////////// -/** - * Bitmask, indicates only :name type parameters are supported by db backend. - */ +/** Bitmask, indicates :name type parameters are supported by db backend. */ define('SQL_PARAMS_NAMED', 1); -/** - * Bitmask, indicates only ? type parameters are supported by db backend. - */ +/** Bitmask, indicates ? type parameters are supported by db backend. */ define('SQL_PARAMS_QM', 2); -/** - * Bitmask, indicates only $1, $2.. type parameters are supported by db backend. - */ +/** Bitmask, indicates $1, $2, ... type parameters are supported by db backend. */ define('SQL_PARAMS_DOLLAR', 4); + +/** Normal select query, reading only */ +define('SQL_QUERY_SELECT', 1); + +/** Insert select query, writing */ +define('SQL_QUERY_INSERT', 2); + +/** Update select query, writing */ +define('SQL_QUERY_UPDATE', 3); + +/** Query changing db structure, writing */ +define('SQL_QUERY_STRUCTURE', 4); + +/** Auxiliary query done by driver, setting connection config, getting table info, etc. */ +define('SQL_QUERY_AUX', 5); + /** * Abstract class representing moodle database interface. * @package dml @@ -228,6 +238,26 @@ abstract class moodle_database { $this->columns = array(); } + /** + * Called before each db query. + * @param string $sql + * @param array array of parameters + * @param int $type type of query + * @return void + */ + public function query_start($sql, $params, $type) { + //TODO + } + + /** + * Called immediately after each db query. + * @param mixed db specific result + * @return void + */ + public function query_end($result) { + //TODO + } + /** * Returns database server info array * @return array