| | |
| | | */ |
| | | 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 ? |
| | |
| | | |
| | | var $a_query_results = array('dummy'); |
| | | var $last_res_id = 0; |
| | | |
| | | private $tables; |
| | | |
| | | |
| | | /** |
| | |
| | | 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]; |
| | | if (!$this->tables) { |
| | | $this->db_handle->loadModule('Manager'); |
| | | if (!PEAR::isError($result = $this->db_handle->listTables())) |
| | | $this->tables = $result; |
| | | else |
| | | $this->tables = array(); |
| | | } |
| | | |
| | | return self::$tables; |
| | | return $this->tables; |
| | | } |
| | | |
| | | |