From 27a42f64821aa70a1f1d617ace94a80b1caab406 Mon Sep 17 00:00:00 2001 From: Jason Coward Date: Fri, 9 Jun 2017 13:02:11 -0600 Subject: [PATCH] Add ability to specify `extraTables` explicitly for MySQLVehicle extract --- src/Teleport/Action/Extract.php | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/src/Teleport/Action/Extract.php b/src/Teleport/Action/Extract.php index 27258fb..ea34c49 100644 --- a/src/Teleport/Action/Extract.php +++ b/src/Teleport/Action/Extract.php @@ -325,13 +325,19 @@ protected function createVehicles($vehicle) $modxDatabase = $this->modx->getOption('dbname', null, $this->modx->getOption('database')); $modxTablePrefix = $this->modx->getOption('table_prefix', null, ''); - $coreTables = array(); - foreach ($vehicle['object']['classes'] as $class) { - $coreTables[$class] = $this->modx->quote($this->modx->literal($this->modx->getTableName($class))); - } + if (!isset($vehicle['object']['extraTables'])) { + + $coreTables = array(); + foreach ($vehicle['object']['classes'] as $class) { + $coreTables[$class] = $this->modx->quote($this->modx->literal($this->modx->getTableName($class))); + } - $stmt = $this->modx->query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{$modxDatabase}' AND TABLE_NAME NOT IN (" . implode(',', $coreTables) . ")"); - $extraTables = $stmt->fetchAll(\PDO::FETCH_COLUMN); + $stmt = $this->modx->query("SELECT TABLE_NAME FROM information_schema.TABLES WHERE TABLE_SCHEMA = '{$modxDatabase}' AND TABLE_NAME NOT IN (" . implode(',', $coreTables) . ")"); + $extraTables = $stmt->fetchAll(\PDO::FETCH_COLUMN); + + } else { + $extraTables = (array)$vehicle['object']['extraTables']; + } if (is_array($extraTables) && !empty($extraTables)) { $excludeExtraTablePrefix = isset($vehicle['object']['excludeExtraTablePrefix']) && is_array($vehicle['object']['excludeExtraTablePrefix']) @@ -450,4 +456,4 @@ protected function createVehicles($vehicle) } return $vehicleCount; } -} +}