MySQL throws an exception if the table does not exist
authorFlávio Gomes da Silva Lisboa <flaviogomesdasilva@yahoo.com.br>
Sun, 24 Jul 2011 21:22:09 +0000 (23:22 +0200)
committerLars Kneschke <l.kneschke@metaways.de>
Sun, 24 Jul 2011 21:22:09 +0000 (23:22 +0200)
PostgreSQL returns an empty array if the table does not exist

tine20/Tinebase/Group/Sql.php

index b194536..b224f76 100644 (file)
@@ -53,15 +53,20 @@ class Tinebase_Group_Sql extends Tinebase_Group_Abstract
     /**
      * the constructor
      */
-    public function __construct() {
-       $this->_db = Tinebase_Core::getDb();
-       
+    public function __construct() 
+    {
+        $this->_db = Tinebase_Core::getDb();
+        
         $this->groupsTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . $this->_tableName));
         $this->groupMembersTable = new Tinebase_Db_Table(array('name' => SQL_TABLE_PREFIX . 'group_members'));
         
         try {
-            $this->_db->describeTable(SQL_TABLE_PREFIX . 'addressbook');
-            $this->_addressBookInstalled = true;
+            // MySQL throws an exception         if the table does not exist
+            // PostgreSQL returns an empty array if the table does not exist
+            $tableDescription = $this->_db->describeTable(SQL_TABLE_PREFIX . 'addressbook');
+            if (!empty($tableDescription)) {
+                $this->_addressBookInstalled = true;
+            }
         } catch (Zend_Db_Statement_Exception $zdse) {
             // nothing to do
         }