From 93d6a2a7b3779867d8be02655896f34a536c77b3 Mon Sep 17 00:00:00 2001 From: trob Date: Mon, 20 Feb 2017 10:02:41 +0100 Subject: [PATCH 1/2] First try to have content_types working with additional connections --- .../components/com_fabrik/models/contenttypeexport.php | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/administrator/components/com_fabrik/models/contenttypeexport.php b/administrator/components/com_fabrik/models/contenttypeexport.php index 4f8a00c10eb..1f826d2312e 100644 --- a/administrator/components/com_fabrik/models/contenttypeexport.php +++ b/administrator/components/com_fabrik/models/contenttypeexport.php @@ -334,7 +334,7 @@ private function createFabrikElementXML($data, $tables, $mainTable) if ($params->get('join_db_name') !== $mainTable) { - $this->createTableXML($tables, $params->get('join_db_name')); + $this->createTableXML($tables, $params->get('join_db_name'),$params->get('join_conn_id')); } }; @@ -361,7 +361,7 @@ private function createFabrikElementXML($data, $tables, $mainTable) * * @throws Exception */ - private function createTableXML(&$tables, $tableName) + private function createTableXML(&$tables, $tableName,$tableConnId = 1) { if (in_array($tableName, self::$exportedTables)) { @@ -371,15 +371,17 @@ private function createTableXML(&$tables, $tableName) self::$exportedTables[] = $tableName; //$exporter = $this->db->getExporter(); + $tabDbo= FabrikWorker::getDbo(false, $tableConnId); // Until the J! exporters are fixed, we only handle Mysqli (with out extended class) - if (!($this->db instanceof JDatabaseDriverMysqli)) + if (!($tabDbo instanceof JDatabaseDriverMysqli)) { throw new Exception('Sorry, we currently only support the Mysqli database driver for export'); } $exporter = new JDatabaseExporterMysqli2; - $exporter->setDbo($this->db); + + $exporter->setDbo($tabDbo); $exporter->from($tableName); $tableDoc = new DOMDocument(); $xml = (string) $exporter; From e0a4a007c8dd7b77c6885915b1411af8a11526d0 Mon Sep 17 00:00:00 2001 From: trob Date: Mon, 20 Feb 2017 10:48:48 +0100 Subject: [PATCH 2/2] content_types connection id for joined tables --- .../components/com_fabrik/models/contenttypeexport.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/administrator/components/com_fabrik/models/contenttypeexport.php b/administrator/components/com_fabrik/models/contenttypeexport.php index 1f826d2312e..601bfef498b 100644 --- a/administrator/components/com_fabrik/models/contenttypeexport.php +++ b/administrator/components/com_fabrik/models/contenttypeexport.php @@ -214,6 +214,7 @@ public function create($formModel) // We don't want to export the main table, as a new one is created when importing the content type $this->listModel = $formModel->getListModel(); $mainTable = $this->listModel->getTable()->get('db_table_name'); + $mainTableConnection = $this->listModel->getTable()->get('connection_id'); $contentType = $this->doc->createElement('contenttype'); $tables = FabrikContentTypHelper::iniTableXML($this->doc, $mainTable); @@ -234,7 +235,7 @@ public function create($formModel) $elements[] = $elementModel->getElement()->getProperties(); } - $contentType->appendChild($this->createFabrikGroupXML($groupData, $elements, $tables, $mainTable)); + $contentType->appendChild($this->createFabrikGroupXML($groupData, $elements, $tables, $mainTable, $mainTableConnection)); } $contentType->appendChild($tables); @@ -280,7 +281,7 @@ private function version() * * @return DOMElement */ - private function createFabrikGroupXML($data, $elements, $tables, $mainTable = '') + private function createFabrikGroupXML($data, $elements, $tables, $mainTable = '', $mainTableConnection=1) { $tableParams = array('table_join', 'join_from_table'); @@ -295,7 +296,7 @@ private function createFabrikGroupXML($data, $elements, $tables, $mainTable = '' { if ($join->get($tableParam) !== $mainTable) { - $this->createTableXML($tables, $join->get($tableParam)); + $this->createTableXML($tables, $join->get($tableParam), $mainTableConnection); } }