pass $db when fetching table description
authorPhilipp Schüle <p.schuele@metaways.de>
Mon, 7 Jul 2014 13:43:41 +0000 (15:43 +0200)
committerPhilipp Schüle <p.schuele@metaways.de>
Wed, 9 Jul 2014 16:32:26 +0000 (18:32 +0200)
... in Tinebase_Db_Table::getTableDescriptionFromCache

this is needed when working with tables in non-default databases

Change-Id: If7bf0f18ae56b944f52f6f7be0dbf0de826abe44
Reviewed-on: http://gerrit.tine20.com/customers/830
Reviewed-by: Philipp Schüle <p.schuele@metaways.de>
Tested-by: Philipp Schüle <p.schuele@metaways.de>
tine20/Tinebase/Db/Table.php

index fd956f9..5ceeda1 100644 (file)
@@ -79,16 +79,20 @@ class Tinebase_Db_Table extends Zend_Db_Table_Abstract
      */
     public static function getTableDescriptionFromCache($tableName, $db = NULL)
     {
+        if ($db === NULL) {
+            $db = Tinebase_Core::getDb();
+        }
         try {
-            $tableDescription = new Tinebase_Db_Table(array('name' => $tableName));
+            $config = array(
+                'name' => $tableName,
+                'db'   => $db
+            );
+            $tableDescription = new Tinebase_Db_Table($config);
             $tableInfo = $tableDescription->info();
             $result = $tableInfo['metadata'];
         } catch (Zend_Db_Table_Exception $zdte) {
             if (Tinebase_Core::isLogLevel(Zend_Log::NOTICE)) Tinebase_Core::getLogger()->notice(__METHOD__ . '::' . __LINE__
                 . ' Could not fetch schema from cache: ' . $zdte->getMessage());
-            if ($db === NULL) {
-                $db = Tinebase_Core::getDb();
-            }
             $result = $db->describeTable($tableName);
         }
         return $result;