summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@owncloud.com>2015-12-08 09:57:38 +0100
committerJoas Schilling <nickvergessen@owncloud.com>2015-12-08 11:04:28 +0100
commit9f9884930609addad3e37325731fb5406dd3aa44 (patch)
tree27adaa156fa4e393b7b91454fe6a35b58b4d577a /lib
parenta3391248e46bbc389dc1880f7ae50aa5dade8731 (diff)
downloadnextcloud-server-9f9884930609addad3e37325731fb5406dd3aa44.tar.gz
nextcloud-server-9f9884930609addad3e37325731fb5406dd3aa44.zip
Add a method to the get "to use" table and column name
Diffstat (limited to 'lib')
-rw-r--r--lib/private/db/querybuilder/querybuilder.php19
-rw-r--r--lib/private/db/querybuilder/quotehelper.php2
-rw-r--r--lib/public/db/querybuilder/iquerybuilder.php19
3 files changed, 38 insertions, 2 deletions
diff --git a/lib/private/db/querybuilder/querybuilder.php b/lib/private/db/querybuilder/querybuilder.php
index b874f5c9911..741da4efc27 100644
--- a/lib/private/db/querybuilder/querybuilder.php
+++ b/lib/private/db/querybuilder/querybuilder.php
@@ -1061,14 +1061,31 @@ class QueryBuilder implements IQueryBuilder {
}
/**
+ * Returns the table name quoted and with database prefix as needed by the implementation
+ *
* @param string $table
* @return string
*/
- private function getTableName($table) {
+ public function getTableName($table) {
if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
return $this->helper->quoteColumnName($table);
}
return $this->helper->quoteColumnName('*PREFIX*' . $table);
}
+
+ /**
+ * Returns the column name quoted and with table alias prefix as needed by the implementation
+ *
+ * @param string $column
+ * @param string $tableAlias
+ * @return string
+ */
+ public function getColumnName($column, $tableAlias = '') {
+ if ($tableAlias !== '') {
+ $tableAlias .= '.';
+ }
+
+ return $this->helper->quoteColumnName($tableAlias . $column);
+ }
}
diff --git a/lib/private/db/querybuilder/quotehelper.php b/lib/private/db/querybuilder/quotehelper.php
index 4b62fee6a6c..5ceb76bbf93 100644
--- a/lib/private/db/querybuilder/quotehelper.php
+++ b/lib/private/db/querybuilder/quotehelper.php
@@ -61,7 +61,7 @@ class QuoteHelper {
}
if (substr_count($string, '.')) {
- list($alias, $columnName) = explode('.', $string);
+ list($alias, $columnName) = explode('.', $string, 2);
if ($columnName === '*') {
return $string;
diff --git a/lib/public/db/querybuilder/iquerybuilder.php b/lib/public/db/querybuilder/iquerybuilder.php
index 1ff1077d53f..dd3ee7da5f5 100644
--- a/lib/public/db/querybuilder/iquerybuilder.php
+++ b/lib/public/db/querybuilder/iquerybuilder.php
@@ -820,4 +820,23 @@ interface IQueryBuilder {
* @since 9.0.0
*/
public function getLastInsertId();
+
+ /**
+ * Returns the table name quoted and with database prefix as needed by the implementation
+ *
+ * @param string $table
+ * @return string
+ * @since 9.0.0
+ */
+ public function getTableName($table);
+
+ /**
+ * Returns the column name quoted and with table alias prefix as needed by the implementation
+ *
+ * @param string $column
+ * @param string $tableAlias
+ * @return string
+ * @since 9.0.0
+ */
+ public function getColumnName($column, $tableAlias = '');
}