summaryrefslogtreecommitdiffstats
path: root/lib/private/DB
diff options
context:
space:
mode:
authorRobin Appelman <robin@icewind.nl>2018-01-12 13:44:30 +0100
committerRobin Appelman <robin@icewind.nl>2018-01-12 13:57:55 +0100
commit42b3aa3a0a9098a2810ded6f0e0e359a3c9e3337 (patch)
tree464fb00ca8d575c81775dd4d4600d7fb44cee737 /lib/private/DB
parentaad01894e38ff77781934c16b75dac43d49ec74a (diff)
downloadnextcloud-server-42b3aa3a0a9098a2810ded6f0e0e359a3c9e3337.tar.gz
nextcloud-server-42b3aa3a0a9098a2810ded6f0e0e359a3c9e3337.zip
reuse query builder
Signed-off-by: Robin Appelman <robin@icewind.nl>
Diffstat (limited to 'lib/private/DB')
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php7
-rw-r--r--lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php6
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php10
3 files changed, 13 insertions, 10 deletions
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
index 85b676be3f4..154f2447c77 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/ExpressionBuilder.php
@@ -52,13 +52,14 @@ class ExpressionBuilder implements IExpressionBuilder {
/**
* Initializes a new <tt>ExpressionBuilder</tt>.
*
- * @param \OCP\IDBConnection $connection
+ * @param IDBConnection $connection
+ * @param IQueryBuilder $queryBuilder
*/
- public function __construct(IDBConnection $connection) {
+ public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
$this->connection = $connection;
$this->helper = new QuoteHelper();
$this->expressionBuilder = new DoctrineExpressionBuilder($connection);
- $this->functionBuilder = $connection->getQueryBuilder()->func();
+ $this->functionBuilder = $queryBuilder->func();
}
/**
diff --git a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
index 17f7fd5aa47..aa7ef8e70be 100644
--- a/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
+++ b/lib/private/DB/QueryBuilder/ExpressionBuilder/MySqlExpressionBuilder.php
@@ -25,6 +25,7 @@ namespace OC\DB\QueryBuilder\ExpressionBuilder;
use OC\DB\Connection;
+use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\IDBConnection;
class MySqlExpressionBuilder extends ExpressionBuilder {
@@ -34,9 +35,10 @@ class MySqlExpressionBuilder extends ExpressionBuilder {
/**
* @param \OCP\IDBConnection|Connection $connection
+ * @param IQueryBuilder $queryBuilder
*/
- public function __construct(IDBConnection $connection) {
- parent::__construct($connection);
+ public function __construct(IDBConnection $connection, IQueryBuilder $queryBuilder) {
+ parent::__construct($connection, $queryBuilder);
$params = $connection->getParams();
$this->charset = isset($params['charset']) ? $params['charset'] : 'utf8';
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index 58be4b43255..d6f8bb48acd 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -112,15 +112,15 @@ class QueryBuilder implements IQueryBuilder {
*/
public function expr() {
if ($this->connection instanceof OracleConnection) {
- return new OCIExpressionBuilder($this->connection);
+ return new OCIExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
- return new PgSqlExpressionBuilder($this->connection);
+ return new PgSqlExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
- return new MySqlExpressionBuilder($this->connection);
+ return new MySqlExpressionBuilder($this->connection, $this);
} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
- return new SqliteExpressionBuilder($this->connection);
+ return new SqliteExpressionBuilder($this->connection, $this);
} else {
- return new ExpressionBuilder($this->connection);
+ return new ExpressionBuilder($this->connection, $this);
}
}