summaryrefslogtreecommitdiff
path: root/program/include/rcube_db_pgsql.php
diff options
context:
space:
mode:
authorAleksander Machniak <alec@alec.pl>2012-07-08 10:32:13 +0200
committerAleksander Machniak <alec@alec.pl>2012-07-08 10:32:13 +0200
commitc389a85978bc5cf8f0f9d06c58664a35c4746447 (patch)
tree17ad45365266e1c8450047927a6b016257a62b9f /program/include/rcube_db_pgsql.php
parentd239ee6df5ce530b7c978628919e6134e3e795d4 (diff)
Add get_variable() implementation
Diffstat (limited to 'program/include/rcube_db_pgsql.php')
-rw-r--r--program/include/rcube_db_pgsql.php37
1 files changed, 33 insertions, 4 deletions
diff --git a/program/include/rcube_db_pgsql.php b/program/include/rcube_db_pgsql.php
index 641b884d6..d357d88ce 100644
--- a/program/include/rcube_db_pgsql.php
+++ b/program/include/rcube_db_pgsql.php
@@ -1,6 +1,6 @@
<?php
-/*
+/**
+-----------------------------------------------------------------------+
| program/include/rcube_db_pgsql.php |
| |
@@ -26,8 +26,8 @@
*
* This is a wrapper for the PHP PDO
*
- * @package Database
- * @version 1.0
+ * @package Database
+ * @version 1.0
*/
class rcube_db_pgsql extends rcube_db
{
@@ -80,7 +80,36 @@ class rcube_db_pgsql extends rcube_db
*/
public function ilike($column, $value)
{
- return $this->quote_identifier($column).' ILIKE '.$this->quote($value);
+ return $this->quote_identifier($column) . ' ILIKE ' . $this->quote($value);
+ }
+
+ /**
+ * 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)
+ {
+ // There's a known case when max_allowed_packet is queried
+ // PostgreSQL doesn't have such limit, return immediately
+ if ($varname == 'max_allowed_packet') {
+ return $default;
+ }
+
+ if (!isset($this->variables)) {
+ $this->variables = array();
+
+ $result = $this->query('SHOW ALL');
+
+ while ($row = $this->fetch_array($result)) {
+ $this->variables[$row[0]] = $row[1];
+ }
+ }
+
+ return isset($this->variables[$varname]) ? $this->variables[$varname] : $default;
}
}