Compare commits
3 Commits
Author | SHA1 | Date | |
---|---|---|---|
d587fde2e8 | |||
c74789faef | |||
1a339d4644 |
BIN
.gitattributes
vendored
Normal file
BIN
.gitattributes
vendored
Normal file
Binary file not shown.
@ -15,7 +15,10 @@ use Doctrine\DBAL\Configuration;
|
|||||||
*/
|
*/
|
||||||
class OxidEsalesDatabase extends \OxidEsales\Eshop\Core\Database\Adapter\Doctrine\Database
|
class OxidEsalesDatabase extends \OxidEsales\Eshop\Core\Database\Adapter\Doctrine\Database
|
||||||
{
|
{
|
||||||
public static function enableLogger($message = null)
|
/**
|
||||||
|
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
||||||
|
*/
|
||||||
|
public function d3EnableLogger($message)
|
||||||
{
|
{
|
||||||
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
$trace = debug_backtrace((PHP_VERSION_ID < 50306) ? 2 : DEBUG_BACKTRACE_IGNORE_ARGS);
|
||||||
|
|
||||||
@ -33,17 +36,20 @@ class OxidEsalesDatabase extends \OxidEsales\Eshop\Core\Database\Adapter\Doctrin
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return OxidSQLLogger
|
* @return mixed
|
||||||
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
||||||
*/
|
*/
|
||||||
public static function getLogger()
|
public function d3GetLogger()
|
||||||
{
|
{
|
||||||
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
|
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
|
||||||
$dbalConfig = $database->getConnection()->getConfiguration();
|
$dbalConfig = $database->getConnection()->getConfiguration();
|
||||||
return $dbalConfig->getSQLLogger();
|
return $dbalConfig->getSQLLogger();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static function disableLogger()
|
/**
|
||||||
|
* @throws \OxidEsales\Eshop\Core\Exception\DatabaseConnectionException
|
||||||
|
*/
|
||||||
|
public function d3DisableLogger()
|
||||||
{
|
{
|
||||||
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
|
$database = \OxidEsales\Eshop\Core\DatabaseProvider::getDb(\OxidEsales\Eshop\Core\DatabaseProvider::FETCH_MODE_ASSOC);
|
||||||
$dbalConfig = $database->getConnection()->getConfiguration();
|
$dbalConfig = $database->getConnection()->getConfiguration();
|
||||||
|
@ -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
|
||||||
*/
|
*/
|
||||||
|
@ -6,9 +6,14 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
function D3StartSQLLog($message = null) {
|
function D3StartSQLLog($message = null) {
|
||||||
\D3\OxidSqlLogger\OxidEsalesDatabase::enableLogger($message);
|
/** @var \D3\OxidSqlLogger\OxidEsalesDatabase $database */
|
||||||
|
$database = oxNew(\D3\OxidSqlLogger\OxidEsalesDatabase::class);
|
||||||
|
$database->d3EnableLogger($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function D3StopSQLLog() {
|
function D3StopSQLLog()
|
||||||
\D3\OxidSqlLogger\OxidEsalesDatabase::disableLogger();
|
{
|
||||||
|
/** @var \D3\OxidSqlLogger\OxidEsalesDatabase $database */
|
||||||
|
$database = oxNew(\D3\OxidSqlLogger\OxidEsalesDatabase::class);
|
||||||
|
$database->d3DisableLogger();
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user