export handler accept prepared statements

This commit is contained in:
Daniel Seifert 2021-04-20 16:18:40 +02:00
bovenliggende 2014e273f3
commit 4739255992
Getekend door: DanielS
GPG sleutel-ID: 8A7C4C6ED1915C6F
3 gewijzigde bestanden met toevoegingen van 15 en 10 verwijderingen

Bestand weergeven

@ -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)
);
}

Bestand weergeven

@ -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(

Bestand weergeven

@ -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;
}