diff options
-rw-r--r-- | program/include/rcube_mdb2.php | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php index 6acb3a03d..a255d9e6e 100644 --- a/program/include/rcube_mdb2.php +++ b/program/include/rcube_mdb2.php @@ -48,6 +48,7 @@ class rcube_mdb2 private $a_query_results = array('dummy'); private $last_res_id = 0; private $tables; + private $variables; /** @@ -214,6 +215,31 @@ class rcube_mdb2 /** + * Get database runtime variables + * + * @param string Variable name + * @param mixed Default value if var is not set + * @return mixed Variable value or default + */ + public function get_variable($varname, $default = null) + { + if (!isset($this->variables)) { + $this->variables = array(); + + // only mysql and postgres are know to support this + if ($this->db_provider == 'pgsql' || $this->db_provider == 'mysql' || $this->db_provider == 'mysqli') { + $this->db_connect('r'); + $query = $this->db_provider == 'pgsql' ? 'SHOW ALL' : 'SHOW VARIABLES'; + foreach ((array)$this->db_handle->queryAll($query) as $row) + $this->variables[$row[0]] = $row[1]; + } + } + + return isset($this->variables[$varname]) ? $this->variables[$varname] : $default; + } + + + /** * Execute a SQL query * * @param string SQL query to execute |