export handler accept prepared statements
This commit is contained in:
parent
2014e273f3
commit
4739255992
@ -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)
|
||||
);
|
||||
}
|
||||
|
||||
|
@ -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(
|
||||
|
@ -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;
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user