diff --git a/src/Application/Controller/Admin/d3ExportWizard.php b/src/Application/Controller/Admin/d3ExportWizard.php index 3cf500e..ef8d555 100644 --- a/src/Application/Controller/Admin/d3ExportWizard.php +++ b/src/Application/Controller/Admin/d3ExportWizard.php @@ -18,6 +18,7 @@ namespace D3\DataWizard\Application\Controller\Admin; use D3\DataWizard\Application\Model\Configuration; use D3\DataWizard\Application\Model\Exceptions\DataWizardException; use D3\DataWizard\Application\Model\Exceptions\DebugException; +use D3\ModCfg\Application\Model\d3database; use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception; use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException; use Doctrine\DBAL\DBALException; @@ -63,10 +64,12 @@ class d3ExportWizard extends AdminDetailsController $id = Registry::getRequest()->getRequestEscapedParameter('exportid'); $export = $this->configuration->getExportById($id); + [ $queryString, $parameters ] = $export->getQuery(); + if (Registry::getConfig()->getConfigParam('d3datawizard_debug')) { throw oxNew( DebugException::class, - $export->getQuery() + d3database::getInstance()->getPreparedStatementQuery($queryString, $parameters) ); } diff --git a/src/Application/Model/ExportBase.php b/src/Application/Model/ExportBase.php index e1b4c9a..ef2a0e8 100644 --- a/src/Application/Model/ExportBase.php +++ b/src/Application/Model/ExportBase.php @@ -42,9 +42,7 @@ abstract class ExportBase implements QueryBase */ public function run($format = RendererBridge::FORMAT_CSV) { - $query = trim($this->getQuery()); - - list( $rows, $fieldNames ) = $this->executeQuery( $query ); + [ $rows, $fieldNames ] = $this->executeQuery( $this->getQuery() ); $content = $this->renderContent($rows, $fieldNames, $format); @@ -112,15 +110,19 @@ abstract class ExportBase implements QueryBase } /** - * @param string $query + * @param array $query * * @return array * @throws DatabaseConnectionException * @throws DatabaseErrorException */ - protected function executeQuery( string $query ): array + protected function executeQuery( array $query ): array { - if ( strtolower( substr( $query, 0, 6 ) ) !== 'select' ) { + [ $queryString, $parameters ] = $query; + + $queryString = trim($queryString); + + if ( strtolower( substr( $queryString, 0, 6 ) ) !== 'select' ) { throw oxNew( Exceptions\TaskException::class, $this, @@ -128,7 +130,7 @@ abstract class ExportBase implements QueryBase ); } - $rows = DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC )->getAll( $query ); + $rows = DatabaseProvider::getDb( DatabaseProvider::FETCH_MODE_ASSOC )->getAll( $queryString, $parameters ); if ( count( $rows ) <= 0 ) { throw oxNew( diff --git a/src/Application/Model/QueryBase.php b/src/Application/Model/QueryBase.php index a068a2a..b034dd8 100644 --- a/src/Application/Model/QueryBase.php +++ b/src/Application/Model/QueryBase.php @@ -40,7 +40,7 @@ interface QueryBase public function getButtonText() : string; /** - * @return string + * @return array [string $query, array $parameters] */ - public function getQuery() : string; + public function getQuery() : array; } \ No newline at end of file