From c389a85978bc5cf8f0f9d06c58664a35c4746447 Mon Sep 17 00:00:00 2001 From: Aleksander Machniak Date: Sun, 8 Jul 2012 10:32:13 +0200 Subject: Add get_variable() implementation --- program/include/rcube_db_mysql.php | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'program/include/rcube_db_mysql.php') diff --git a/program/include/rcube_db_mysql.php b/program/include/rcube_db_mysql.php index 84a324701..71f81956a 100644 --- a/program/include/rcube_db_mysql.php +++ b/program/include/rcube_db_mysql.php @@ -90,4 +90,27 @@ class rcube_db_mysql extends rcube_db return $result; } + /** + * Get database runtime variables + * + * @param string $varname Variable name + * @param mixed $default Default value if variable is not set + * + * @return mixed Variable value or default + */ + public function get_variable($varname, $default = null) + { + if (!isset($this->variables)) { + $this->variables = array(); + + $result = $this->query('SHOW VARIABLES'); + + while ($sql_arr = $this->fetch_array($result)) { + $this->variables[$row[0]] = $row[1]; + } + } + + return isset($this->variables[$varname]) ? $this->variables[$varname] : $default; + } + } -- cgit v1.2.3