aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/DB/QueryBuilder/QueryBuilder.php
diff options
context:
space:
mode:
Diffstat (limited to 'lib/private/DB/QueryBuilder/QueryBuilder.php')
-rw-r--r--lib/private/DB/QueryBuilder/QueryBuilder.php36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/private/DB/QueryBuilder/QueryBuilder.php b/lib/private/DB/QueryBuilder/QueryBuilder.php
index d5dd9cf0366..eac13b452ac 100644
--- a/lib/private/DB/QueryBuilder/QueryBuilder.php
+++ b/lib/private/DB/QueryBuilder/QueryBuilder.php
@@ -26,11 +26,17 @@ namespace OC\DB\QueryBuilder;
use Doctrine\DBAL\Platforms\MySqlPlatform;
use Doctrine\DBAL\Platforms\PostgreSqlPlatform;
+use Doctrine\DBAL\Platforms\SqlitePlatform;
use OC\DB\OracleConnection;
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\DB\QueryBuilder\ExpressionBuilder\SqliteExpressionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\FunctionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\OCIFunctionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\PgSqlFunctionBuilder;
+use OC\DB\QueryBuilder\FunctionBuilder\SqliteFunctionBuilder;
use OC\SystemConfig;
use OCP\DB\QueryBuilder\IQueryBuilder;
use OCP\DB\QueryBuilder\IQueryFunction;
@@ -110,12 +116,42 @@ class QueryBuilder implements IQueryBuilder {
return new PgSqlExpressionBuilder($this->connection);
} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
return new MySqlExpressionBuilder($this->connection);
+ } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
+ return new SqliteExpressionBuilder($this->connection);
} else {
return new ExpressionBuilder($this->connection);
}
}
/**
+ * Gets an FunctionBuilder used for object-oriented construction of query functions.
+ * This producer method is intended for convenient inline usage. Example:
+ *
+ * <code>
+ * $qb = $conn->getQueryBuilder()
+ * ->select('u')
+ * ->from('users', 'u')
+ * ->where($qb->fun()->md5('u.id'));
+ * </code>
+ *
+ * For more complex function construction, consider storing the function
+ * builder object in a local variable.
+ *
+ * @return \OCP\DB\QueryBuilder\IFunctionBuilder
+ */
+ public function func() {
+ if ($this->connection instanceof OracleConnection) {
+ return new OCIFunctionBuilder($this->helper);
+ } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
+ return new SqliteFunctionBuilder($this->helper);
+ } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
+ return new PgSqlFunctionBuilder($this->helper);
+ } else {
+ return new FunctionBuilder($this->helper);
+ }
+ }
+
+ /**
* Gets the type of the currently built query.
*
* @return integer