diff options
Diffstat (limited to 'lib/private/DB')
-rw-r--r-- | lib/private/DB/Connection.php | 6 | ||||
-rw-r--r-- | lib/private/DB/QueryBuilder/QueryBuilder.php | 22 |
2 files changed, 22 insertions, 6 deletions
diff --git a/lib/private/DB/Connection.php b/lib/private/DB/Connection.php index dfe2e86b617..497ff0c8a26 100644 --- a/lib/private/DB/Connection.php +++ b/lib/private/DB/Connection.php @@ -67,7 +67,11 @@ class Connection extends \Doctrine\DBAL\Connection implements IDBConnection { * @return \OCP\DB\QueryBuilder\IQueryBuilder */ public function getQueryBuilder() { - return new QueryBuilder($this); + return new QueryBuilder( + $this, + \OC::$server->getSystemConfig(), + \OC::$server->getLogger() + ); } /** diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php index aefc84f9c9a..d5dd9cf0366 100644 --- a/lib/private/DB/QueryBuilder/QueryBuilder.php +++ b/lib/private/DB/QueryBuilder/QueryBuilder.php @@ -31,16 +31,24 @@ use OC\DB\QueryBuilder\ExpressionBuilder\ExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\MySqlExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\OCIExpressionBuilder; use OC\DB\QueryBuilder\ExpressionBuilder\PgSqlExpressionBuilder; +use OC\SystemConfig; use OCP\DB\QueryBuilder\IQueryBuilder; use OCP\DB\QueryBuilder\IQueryFunction; use OCP\DB\QueryBuilder\IParameter; use OCP\IDBConnection; +use OCP\ILogger; class QueryBuilder implements IQueryBuilder { /** @var \OCP\IDBConnection */ private $connection; + /** @var SystemConfig */ + private $systemConfig; + + /** @var ILogger */ + private $logger; + /** @var \Doctrine\DBAL\Query\QueryBuilder */ private $queryBuilder; @@ -56,10 +64,14 @@ class QueryBuilder implements IQueryBuilder { /** * Initializes a new QueryBuilder. * - * @param \OCP\IDBConnection $connection + * @param IDBConnection $connection + * @param SystemConfig $systemConfig + * @param ILogger $logger */ - public function __construct(IDBConnection $connection) { + public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) { $this->connection = $connection; + $this->systemConfig = $systemConfig; + $this->logger = $logger; $this->queryBuilder = new \Doctrine\DBAL\Query\QueryBuilder($this->connection); $this->helper = new QuoteHelper(); } @@ -139,7 +151,7 @@ class QueryBuilder implements IQueryBuilder { * @return \Doctrine\DBAL\Driver\Statement|int */ public function execute() { - if (\OC::$server->getConfig()->getSystemValue('log_query', false)) { + if ($this->systemConfig->getValue('log_query', false)) { $params = []; foreach ($this->getParameters() as $placeholder => $value) { if (is_array($value)) { @@ -149,12 +161,12 @@ class QueryBuilder implements IQueryBuilder { } } if (empty($params)) { - \OC::$server->getLogger()->debug('DB QueryBuilder: \'{query}\'', [ + $this->logger->debug('DB QueryBuilder: \'{query}\'', [ 'query' => $this->getSQL(), 'app' => 'core', ]); } else { - \OC::$server->getLogger()->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [ + $this->logger->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [ 'query' => $this->getSQL(), 'params' => implode(', ', $params), 'app' => 'core', |