diff options
| author | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-03-31 15:23:22 +0000 |
|---|---|---|
| committer | thomasb <thomasb@208e9e7b-5314-0410-a742-e7e81cd9613c> | 2010-03-31 15:23:22 +0000 |
| commit | 64be498b8042be839e0fb20aa08e0c36a7cc3b2d (patch) | |
| tree | de59a3b3823fd85710072bf85f32ae96f8a0dc34 /roundcubemail/program/include/rcube_mdb2.php | |
| parent | 583547321ea293e21cd112af67e5ec878ac9912e (diff) | |
Asynchronously expand contact groups + skip count queries in autocompletion mode + check for the existance of contactgroups table
git-svn-id: https://svn.roundcube.net/trunk@3449 208e9e7b-5314-0410-a742-e7e81cd9613c
Diffstat (limited to 'roundcubemail/program/include/rcube_mdb2.php')
| -rw-r--r-- | roundcubemail/program/include/rcube_mdb2.php | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/roundcubemail/program/include/rcube_mdb2.php b/roundcubemail/program/include/rcube_mdb2.php index aca44c963..10aaabe4a 100644 --- a/roundcubemail/program/include/rcube_mdb2.php +++ b/roundcubemail/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 @@ class rcube_mdb2 $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 @@ class rcube_mdb2 /** + * 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 |
