add prepared statement query generator
This commit is contained in:
parent
1a339d4644
commit
c74789faef
@ -7,6 +7,7 @@
|
|||||||
|
|
||||||
namespace D3\OxidSqlLogger;
|
namespace D3\OxidSqlLogger;
|
||||||
|
|
||||||
|
use D3\ModCfg\Application\Model\d3database;
|
||||||
use Doctrine\DBAL\Logging\SQLLogger;
|
use Doctrine\DBAL\Logging\SQLLogger;
|
||||||
use Monolog;
|
use Monolog;
|
||||||
use NilPortugues\Sql\QueryFormatter\Formatter;
|
use NilPortugues\Sql\QueryFormatter\Formatter;
|
||||||
@ -53,6 +54,8 @@ class OxidSQLLogger implements SQLLogger
|
|||||||
$this->stopQuery();
|
$this->stopQuery();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$this->getPreparedStatementQuery($sql, $params);
|
||||||
|
|
||||||
$this->SQLQuery = (new SQLQuery()) ->setSql($sql)
|
$this->SQLQuery = (new SQLQuery()) ->setSql($sql)
|
||||||
->setParams($params)
|
->setParams($params)
|
||||||
->setTypes($types)
|
->setTypes($types)
|
||||||
@ -62,6 +65,23 @@ class OxidSQLLogger implements SQLLogger
|
|||||||
->setLogStartingFunction($this->logStartingFunction);
|
->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
|
* @inheritDoc
|
||||||
*/
|
*/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user