From c0297f4172da47a20350d597176ecafee47c97bb Mon Sep 17 00:00:00 2001
From: thomascube <thomas@roundcube.net>
Date: Wed, 31 Mar 2010 11:23:22 -0400
Subject: [PATCH] Asynchronously expand contact groups + skip count queries in autocompletion mode + check for the existance of contactgroups table
---
program/include/rcube_mdb2.php | 32 +++++++++++++++++++++++++++++++-
1 files changed, 31 insertions(+), 1 deletions(-)
diff --git a/program/include/rcube_mdb2.php b/program/include/rcube_mdb2.php
index aca44c9..10aaabe 100644
--- a/program/include/rcube_mdb2.php
+++ b/program/include/rcube_mdb2.php
@@ -35,6 +35,8 @@
*/
class rcube_mdb2
{
+ private static $tables;
+
var $db_dsnw; // DSN for write operations
var $db_dsnr; // DSN for read operations
var $db_connected = false; // Already connected ?
@@ -267,7 +269,7 @@
$this->db_error_msg = $q->userinfo;
raise_error(array('code' => 500, 'type' => 'db',
- 'line' => __LINE__, 'file' => __FILE__,
+ 'line' => __LINE__, 'file' => __FILE__,
'message' => $this->db_error_msg), TRUE, TRUE);
}
else
@@ -394,6 +396,34 @@
/**
+ * Wrapper for the SHOW TABLES command
+ *
+ * @return array List of all tables of the current database
+ */
+ function list_tables()
+ {
+ // get tables if not cached
+ if (!self::$tables) {
+ self::$tables = array();
+
+ switch ($this->db_provider) {
+ case 'sqlite':
+ $result = $this->db_handle->query("SELECT name FROM sqlite_master WHERE type='table'");
+ break;
+ default:
+ $result = $this->db_handle->query("SHOW TABLES");
+ }
+
+ if ($result !== false && !PEAR::isError($result))
+ while ($rec = $result->fetchRow(MDB2_FETCHMODE_ORDERED))
+ self::$tables[] = $rec[0];
+ }
+
+ return self::$tables;
+ }
+
+
+ /**
* Formats input so it can be safely used in a query
*
* @param mixed Value to quote
--
Gitblit v1.9.1