add prepared statement query generator

This commit is contained in:
Daniel Seifert 2021-01-23 21:53:18 +01:00
parent 1a339d4644
commit c74789faef
Signed by: DanielS
GPG Key ID: 6A513E13AEE66170

View File

@ -7,6 +7,7 @@
namespace D3\OxidSqlLogger;
use D3\ModCfg\Application\Model\d3database;
use Doctrine\DBAL\Logging\SQLLogger;
use Monolog;
use NilPortugues\Sql\QueryFormatter\Formatter;
@ -53,6 +54,8 @@ class OxidSQLLogger implements SQLLogger
$this->stopQuery();
}
$this->getPreparedStatementQuery($sql, $params);
$this->SQLQuery = (new SQLQuery()) ->setSql($sql)
->setParams($params)
->setTypes($types)
@ -62,6 +65,23 @@ class OxidSQLLogger implements SQLLogger
->setLogStartingFunction($this->logStartingFunction);
}
/**
* @param string $sql
* @param array $params
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
*/
public function getPreparedStatementQuery(&$sql, array $params = null)
{
if (class_exists(d3database::class)
&& method_exists(d3database::class, 'getPreparedStatementQuery')
&& count($params)
&& ($query = d3database::getInstance()->getPreparedStatementQuery($sql, $params))
&& strlen(trim($query))
) {
$sql = $query;
}
}
/**
* @inheritDoc
*/