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\Configuration;
|
||||||
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
use D3\DataWizard\Application\Model\Exceptions\DataWizardException;
|
||||||
use D3\DataWizard\Application\Model\Exceptions\DebugException;
|
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\d3_cfg_mod_exception;
|
||||||
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
||||||
use Doctrine\DBAL\DBALException;
|
use Doctrine\DBAL\DBALException;
|
||||||
@ -63,10 +64,12 @@ class d3ExportWizard extends AdminDetailsController
|
|||||||
$id = Registry::getRequest()->getRequestEscapedParameter('exportid');
|
$id = Registry::getRequest()->getRequestEscapedParameter('exportid');
|
||||||
$export = $this->configuration->getExportById($id);
|
$export = $this->configuration->getExportById($id);
|
||||||
|
|
||||||
|
[ $queryString, $parameters ] = $export->getQuery();
|
||||||
|
|
||||||
if (Registry::getConfig()->getConfigParam('d3datawizard_debug')) {
|
if (Registry::getConfig()->getConfigParam('d3datawizard_debug')) {
|
||||||
throw oxNew(
|
throw oxNew(
|
||||||
DebugException::class,
|
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)
|
public function run($format = RendererBridge::FORMAT_CSV)
|
||||||
{
|
{
|
||||||
$query = trim($this->getQuery());
|
[ $rows, $fieldNames ] = $this->executeQuery( $this->getQuery() );
|
||||||
|
|
||||||
list( $rows, $fieldNames ) = $this->executeQuery( $query );
|
|
||||||
|
|
||||||
$content = $this->renderContent($rows, $fieldNames, $format);
|
$content = $this->renderContent($rows, $fieldNames, $format);
|
||||||
|
|
||||||
@ -112,15 +110,19 @@ abstract class ExportBase implements QueryBase
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $query
|
* @param array $query
|
||||||
*
|
*
|
||||||
* @return array
|
* @return array
|
||||||
* @throws DatabaseConnectionException
|
* @throws DatabaseConnectionException
|
||||||
* @throws DatabaseErrorException
|
* @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(
|
throw oxNew(
|
||||||
Exceptions\TaskException::class,
|
Exceptions\TaskException::class,
|
||||||
$this,
|
$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 ) {
|
if ( count( $rows ) <= 0 ) {
|
||||||
throw oxNew(
|
throw oxNew(
|
||||||
|
@ -40,7 +40,7 @@ interface QueryBase
|
|||||||
public function getButtonText() : string;
|
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