Passed
Push — master ( d23e96...1bc100 )
by Roeland
11:25 queued 10s
created
lib/private/Diagnostics/QueryLogger.php 1 patch
Indentation   +55 added lines, -55 removed lines patch added patch discarded remove patch
@@ -29,68 +29,68 @@
 block discarded – undo
29 29
 use OCP\Diagnostics\IQueryLogger;
30 30
 
31 31
 class QueryLogger implements IQueryLogger {
32
-	/**
33
-	 * @var \OC\Diagnostics\Query
34
-	 */
35
-	protected $activeQuery;
32
+    /**
33
+     * @var \OC\Diagnostics\Query
34
+     */
35
+    protected $activeQuery;
36 36
 
37
-	/**
38
-	 * @var CappedMemoryCache
39
-	 */
40
-	protected $queries;
37
+    /**
38
+     * @var CappedMemoryCache
39
+     */
40
+    protected $queries;
41 41
 
42
-	/**
43
-	 * QueryLogger constructor.
44
-	 */
45
-	public function __construct() {
46
-		$this->queries = new CappedMemoryCache(1024);
47
-	}
42
+    /**
43
+     * QueryLogger constructor.
44
+     */
45
+    public function __construct() {
46
+        $this->queries = new CappedMemoryCache(1024);
47
+    }
48 48
 
49 49
 
50
-	/**
51
-	 * @var bool - Module needs to be activated by some app
52
-	 */
53
-	private $activated = false;
50
+    /**
51
+     * @var bool - Module needs to be activated by some app
52
+     */
53
+    private $activated = false;
54 54
 
55
-	/**
56
-	 * @inheritdoc
57
-	 */
58
-	public function startQuery($sql, array $params = null, array $types = null) {
59
-		if ($this->activated) {
60
-			$this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack());
61
-		}
62
-	}
55
+    /**
56
+     * @inheritdoc
57
+     */
58
+    public function startQuery($sql, array $params = null, array $types = null) {
59
+        if ($this->activated) {
60
+            $this->activeQuery = new Query($sql, $params, microtime(true), $this->getStack());
61
+        }
62
+    }
63 63
 
64
-	private function getStack() {
65
-		$stack = debug_backtrace();
66
-		array_shift($stack);
67
-		array_shift($stack);
68
-		array_shift($stack);
69
-		return $stack;
70
-	}
64
+    private function getStack() {
65
+        $stack = debug_backtrace();
66
+        array_shift($stack);
67
+        array_shift($stack);
68
+        array_shift($stack);
69
+        return $stack;
70
+    }
71 71
 
72
-	/**
73
-	 * @inheritdoc
74
-	 */
75
-	public function stopQuery() {
76
-		if ($this->activated && $this->activeQuery) {
77
-			$this->activeQuery->end(microtime(true));
78
-			$this->queries[] = $this->activeQuery;
79
-			$this->activeQuery = null;
80
-		}
81
-	}
72
+    /**
73
+     * @inheritdoc
74
+     */
75
+    public function stopQuery() {
76
+        if ($this->activated && $this->activeQuery) {
77
+            $this->activeQuery->end(microtime(true));
78
+            $this->queries[] = $this->activeQuery;
79
+            $this->activeQuery = null;
80
+        }
81
+    }
82 82
 
83
-	/**
84
-	 * @inheritdoc
85
-	 */
86
-	public function getQueries() {
87
-		return $this->queries->getData();
88
-	}
83
+    /**
84
+     * @inheritdoc
85
+     */
86
+    public function getQueries() {
87
+        return $this->queries->getData();
88
+    }
89 89
 
90
-	/**
91
-	 * @inheritdoc
92
-	 */
93
-	public function activate() {
94
-		$this->activated = true;
95
-	}
90
+    /**
91
+     * @inheritdoc
92
+     */
93
+    public function activate() {
94
+        $this->activated = true;
95
+    }
96 96
 }
Please login to merge, or discard this patch.
lib/private/Hooks/LegacyEmitter.php 1 patch
Indentation   +11 added lines, -11 removed lines patch added patch discarded remove patch
@@ -24,15 +24,15 @@
 block discarded – undo
24 24
 namespace OC\Hooks;
25 25
 
26 26
 abstract class LegacyEmitter extends BasicEmitter {
27
-	/**
28
-	 * @param string $scope
29
-	 * @param string $method
30
-	 * @param array $arguments
31
-	 *
32
-	 * @suppress PhanAccessMethodProtected
33
-	 */
34
-	protected function emit($scope, $method, array $arguments = array()) {
35
-		\OC_Hook::emit($scope, $method, $arguments);
36
-		parent::emit($scope, $method, $arguments);
37
-	}
27
+    /**
28
+     * @param string $scope
29
+     * @param string $method
30
+     * @param array $arguments
31
+     *
32
+     * @suppress PhanAccessMethodProtected
33
+     */
34
+    protected function emit($scope, $method, array $arguments = array()) {
35
+        \OC_Hook::emit($scope, $method, $arguments);
36
+        parent::emit($scope, $method, $arguments);
37
+    }
38 38
 }
Please login to merge, or discard this patch.
lib/private/Hooks/PublicEmitter.php 1 patch
Indentation   +10 added lines, -10 removed lines patch added patch discarded remove patch
@@ -24,14 +24,14 @@
 block discarded – undo
24 24
 namespace OC\Hooks;
25 25
 
26 26
 class PublicEmitter extends BasicEmitter {
27
-	/**
28
-	 * @param string $scope
29
-	 * @param string $method
30
-	 * @param array $arguments optional
31
-	 *
32
-	 * @suppress PhanAccessMethodProtected
33
-	 */
34
-	public function emit($scope, $method, array $arguments = array()) {
35
-		parent::emit($scope, $method, $arguments);
36
-	}
27
+    /**
28
+     * @param string $scope
29
+     * @param string $method
30
+     * @param array $arguments optional
31
+     *
32
+     * @suppress PhanAccessMethodProtected
33
+     */
34
+    public function emit($scope, $method, array $arguments = array()) {
35
+        parent::emit($scope, $method, $arguments);
36
+    }
37 37
 }
Please login to merge, or discard this patch.
core/Command/Db/Migrations/GenerateFromSchemaFileCommand.php 2 patches
Spacing   +4 added lines, -4 removed lines patch added patch discarded remove patch
@@ -60,14 +60,14 @@  discard block
 block discarded – undo
60 60
 		$appName = $input->getArgument('app');
61 61
 		$version = $input->getArgument('version');
62 62
 
63
-		if (!preg_match('/^\d{1,16}$/',$version)) {
63
+		if (!preg_match('/^\d{1,16}$/', $version)) {
64 64
 			$output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
65 65
 			return 1;
66 66
 		}
67 67
 
68
-		$schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml';
68
+		$schemaFile = $this->appManager->getAppPath($appName).'/appinfo/database.xml';
69 69
 		if (!file_exists($schemaFile)) {
70
-			$output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>');
70
+			$output->writeln('<error>App '.$appName.' does not have a database.xml file</error>');
71 71
 			return 2;
72 72
 		}
73 73
 
@@ -80,7 +80,7 @@  discard block
 block discarded – undo
80 80
 		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
81 81
 
82 82
 		$date = date('YmdHis');
83
-		$path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody);
83
+		$path = $this->generateMigration($ms, 'Version'.$version.'Date'.$date, $schemaBody);
84 84
 
85 85
 		$output->writeln("New migration class has been generated to <info>$path</info>");
86 86
 		return 0;
Please login to merge, or discard this patch.
Indentation   +99 added lines, -99 removed lines patch added patch discarded remove patch
@@ -36,170 +36,170 @@
 block discarded – undo
36 36
 
37 37
 class GenerateFromSchemaFileCommand extends GenerateCommand {
38 38
 
39
-	/** @var IConfig */
40
-	protected $config;
39
+    /** @var IConfig */
40
+    protected $config;
41 41
 
42
-	public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) {
43
-		parent::__construct($connection, $appManager);
44
-		$this->config = $config;
45
-	}
42
+    public function __construct(IConfig $config, IAppManager $appManager, IDBConnection $connection) {
43
+        parent::__construct($connection, $appManager);
44
+        $this->config = $config;
45
+    }
46 46
 
47 47
 
48
-	protected function configure() {
49
-		parent::configure();
48
+    protected function configure() {
49
+        parent::configure();
50 50
 
51
-		$this->setName('migrations:generate-from-schema');
52
-	}
51
+        $this->setName('migrations:generate-from-schema');
52
+    }
53 53
 
54
-	public function execute(InputInterface $input, OutputInterface $output) {
55
-		$appName = $input->getArgument('app');
56
-		$version = $input->getArgument('version');
54
+    public function execute(InputInterface $input, OutputInterface $output) {
55
+        $appName = $input->getArgument('app');
56
+        $version = $input->getArgument('version');
57 57
 
58
-		if (!preg_match('/^\d{1,16}$/',$version)) {
59
-			$output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
60
-			return 1;
61
-		}
58
+        if (!preg_match('/^\d{1,16}$/',$version)) {
59
+            $output->writeln('<error>The given version is invalid. Only 0-9 are allowed (max. 16 digits)</error>');
60
+            return 1;
61
+        }
62 62
 
63
-		$schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml';
64
-		if (!file_exists($schemaFile)) {
65
-			$output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>');
66
-			return 2;
67
-		}
63
+        $schemaFile = $this->appManager->getAppPath($appName) . '/appinfo/database.xml';
64
+        if (!file_exists($schemaFile)) {
65
+            $output->writeln('<error>App ' . $appName . ' does not have a database.xml file</error>');
66
+            return 2;
67
+        }
68 68
 
69
-		$reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform());
70
-		$schema = new Schema();
71
-		$reader->loadSchemaFromFile($schemaFile, $schema);
69
+        $reader = new MDB2SchemaReader($this->config, $this->connection->getDatabasePlatform());
70
+        $schema = new Schema();
71
+        $reader->loadSchemaFromFile($schemaFile, $schema);
72 72
 
73
-		$schemaBody = $this->schemaToMigration($schema);
73
+        $schemaBody = $this->schemaToMigration($schema);
74 74
 
75
-		$ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
75
+        $ms = new MigrationService($appName, $this->connection, new ConsoleOutput($output));
76 76
 
77
-		$date = date('YmdHis');
78
-		$path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody);
77
+        $date = date('YmdHis');
78
+        $path = $this->generateMigration($ms, 'Version' . $version . 'Date' . $date, $schemaBody);
79 79
 
80
-		$output->writeln("New migration class has been generated to <info>$path</info>");
81
-		return 0;
82
-	}
80
+        $output->writeln("New migration class has been generated to <info>$path</info>");
81
+        return 0;
82
+    }
83 83
 
84
-	/**
85
-	 * @param Schema $schema
86
-	 * @return string
87
-	 */
88
-	protected function schemaToMigration(Schema $schema) {
89
-		$content = <<<'EOT'
84
+    /**
85
+     * @param Schema $schema
86
+     * @return string
87
+     */
88
+    protected function schemaToMigration(Schema $schema) {
89
+        $content = <<<'EOT'
90 90
 		/** @var ISchemaWrapper $schema */
91 91
 		$schema = $schemaClosure();
92 92
 
93 93
 EOT;
94 94
 
95
-		foreach ($schema->getTables() as $table) {
96
-			$content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT'
95
+        foreach ($schema->getTables() as $table) {
96
+            $content .= str_replace('{{table-name}}', substr($table->getName(), 3), <<<'EOT'
97 97
 
98 98
 		if (!$schema->hasTable('{{table-name}}')) {
99 99
 			$table = $schema->createTable('{{table-name}}');
100 100
 
101 101
 EOT
102
-			);
102
+            );
103 103
 
104
-			foreach ($table->getColumns() as $column) {
105
-				$content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT'
104
+            foreach ($table->getColumns() as $column) {
105
+                $content .= str_replace(['{{name}}', '{{type}}'], [$column->getName(), $column->getType()->getName()], <<<'EOT'
106 106
 			$table->addColumn('{{name}}', '{{type}}', [
107 107
 
108 108
 EOT
109
-				);
110
-				if ($column->getAutoincrement()) {
111
-					$content .= <<<'EOT'
109
+                );
110
+                if ($column->getAutoincrement()) {
111
+                    $content .= <<<'EOT'
112 112
 				'autoincrement' => true,
113 113
 
114 114
 EOT;
115
-				}
116
-				$content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT'
115
+                }
116
+                $content .= str_replace('{{notnull}}', $column->getNotnull() ? 'true' : 'false', <<<'EOT'
117 117
 				'notnull' => {{notnull}},
118 118
 
119 119
 EOT
120
-				);
121
-				if ($column->getLength() !== null) {
122
-					$content .= str_replace('{{length}}', $column->getLength(), <<<'EOT'
120
+                );
121
+                if ($column->getLength() !== null) {
122
+                    $content .= str_replace('{{length}}', $column->getLength(), <<<'EOT'
123 123
 				'length' => {{length}},
124 124
 
125 125
 EOT
126
-					);
127
-				}
128
-				$default = $column->getDefault();
129
-				if ($default !== null) {
130
-					if (is_string($default)) {
131
-						$default = "'$default'";
132
-					} else if (is_bool($default)) {
133
-						$default = ($default === true) ? 'true' : 'false';
134
-					}
135
-					$content .= str_replace('{{default}}', $default, <<<'EOT'
126
+                    );
127
+                }
128
+                $default = $column->getDefault();
129
+                if ($default !== null) {
130
+                    if (is_string($default)) {
131
+                        $default = "'$default'";
132
+                    } else if (is_bool($default)) {
133
+                        $default = ($default === true) ? 'true' : 'false';
134
+                    }
135
+                    $content .= str_replace('{{default}}', $default, <<<'EOT'
136 136
 				'default' => {{default}},
137 137
 
138 138
 EOT
139
-					);
140
-				}
141
-				if ($column->getUnsigned()) {
142
-					$content .= <<<'EOT'
139
+                    );
140
+                }
141
+                if ($column->getUnsigned()) {
142
+                    $content .= <<<'EOT'
143 143
 				'unsigned' => true,
144 144
 
145 145
 EOT;
146
-				}
146
+                }
147 147
 
148
-				$content .= <<<'EOT'
148
+                $content .= <<<'EOT'
149 149
 			]);
150 150
 
151 151
 EOT;
152
-			}
152
+            }
153 153
 
154
-			$content .= <<<'EOT'
154
+            $content .= <<<'EOT'
155 155
 
156 156
 EOT;
157 157
 
158
-			$primaryKey = $table->getPrimaryKey();
159
-			if ($primaryKey !== null) {
160
-				$content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT'
158
+            $primaryKey = $table->getPrimaryKey();
159
+            if ($primaryKey !== null) {
160
+                $content .= str_replace('{{columns}}', implode('\', \'', $primaryKey->getUnquotedColumns()), <<<'EOT'
161 161
 			$table->setPrimaryKey(['{{columns}}']);
162 162
 
163 163
 EOT
164
-				);
165
-			}
166
-
167
-			foreach ($table->getIndexes() as $index) {
168
-				if ($index->isPrimary()) {
169
-					continue;
170
-				}
171
-
172
-				if ($index->isUnique()) {
173
-					$content .= str_replace(
174
-						['{{columns}}', '{{name}}'],
175
-						[implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
176
-						<<<'EOT'
164
+                );
165
+            }
166
+
167
+            foreach ($table->getIndexes() as $index) {
168
+                if ($index->isPrimary()) {
169
+                    continue;
170
+                }
171
+
172
+                if ($index->isUnique()) {
173
+                    $content .= str_replace(
174
+                        ['{{columns}}', '{{name}}'],
175
+                        [implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
176
+                        <<<'EOT'
177 177
 			$table->addUniqueIndex(['{{columns}}'], '{{name}}');
178 178
 
179 179
 EOT
180
-					);
181
-				} else {
182
-					$content .= str_replace(
183
-						['{{columns}}', '{{name}}'],
184
-						[implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
185
-						<<<'EOT'
180
+                    );
181
+                } else {
182
+                    $content .= str_replace(
183
+                        ['{{columns}}', '{{name}}'],
184
+                        [implode('\', \'', $index->getUnquotedColumns()), $index->getName()],
185
+                        <<<'EOT'
186 186
 			$table->addIndex(['{{columns}}'], '{{name}}');
187 187
 
188 188
 EOT
189
-					);
190
-				}
191
-			}
189
+                    );
190
+                }
191
+            }
192 192
 
193
-			$content .= <<<'EOT'
193
+            $content .= <<<'EOT'
194 194
 		}
195 195
 
196 196
 EOT;
197
-		}
197
+        }
198 198
 
199
-		$content .= <<<'EOT'
199
+        $content .= <<<'EOT'
200 200
 		return $schema;
201 201
 EOT;
202 202
 
203
-		return $content;
204
-	}
203
+        return $content;
204
+    }
205 205
 }
Please login to merge, or discard this patch.
apps/files/lib/Activity/Settings/FileDeleted.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,72 +27,72 @@
 block discarded – undo
27 27
 
28 28
 class FileDeleted implements ISetting {
29 29
 
30
-	/** @var IL10N */
31
-	protected $l;
30
+    /** @var IL10N */
31
+    protected $l;
32 32
 
33
-	/**
34
-	 * @param IL10N $l
35
-	 */
36
-	public function __construct(IL10N $l) {
37
-		$this->l = $l;
38
-	}
33
+    /**
34
+     * @param IL10N $l
35
+     */
36
+    public function __construct(IL10N $l) {
37
+        $this->l = $l;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string Lowercase a-z and underscore only identifier
42
-	 * @since 11.0.0
43
-	 */
44
-	public function getIdentifier() {
45
-		return 'file_deleted';
46
-	}
40
+    /**
41
+     * @return string Lowercase a-z and underscore only identifier
42
+     * @since 11.0.0
43
+     */
44
+    public function getIdentifier() {
45
+        return 'file_deleted';
46
+    }
47 47
 
48
-	/**
49
-	 * @return string A translated string
50
-	 * @since 11.0.0
51
-	 */
52
-	public function getName() {
53
-		return $this->l->t('A file or folder has been <strong>deleted</strong>');
54
-	}
48
+    /**
49
+     * @return string A translated string
50
+     * @since 11.0.0
51
+     */
52
+    public function getName() {
53
+        return $this->l->t('A file or folder has been <strong>deleted</strong>');
54
+    }
55 55
 
56
-	/**
57
-	 * @return int whether the filter should be rather on the top or bottom of
58
-	 * the admin section. The filters are arranged in ascending order of the
59
-	 * priority values. It is required to return a value between 0 and 100.
60
-	 * @since 11.0.0
61
-	 */
62
-	public function getPriority() {
63
-		return 3;
64
-	}
56
+    /**
57
+     * @return int whether the filter should be rather on the top or bottom of
58
+     * the admin section. The filters are arranged in ascending order of the
59
+     * priority values. It is required to return a value between 0 and 100.
60
+     * @since 11.0.0
61
+     */
62
+    public function getPriority() {
63
+        return 3;
64
+    }
65 65
 
66
-	/**
67
-	 * @return bool True when the option can be changed for the stream
68
-	 * @since 11.0.0
69
-	 */
70
-	public function canChangeStream() {
71
-		return true;
72
-	}
66
+    /**
67
+     * @return bool True when the option can be changed for the stream
68
+     * @since 11.0.0
69
+     */
70
+    public function canChangeStream() {
71
+        return true;
72
+    }
73 73
 
74
-	/**
75
-	 * @return bool True when the option can be changed for the stream
76
-	 * @since 11.0.0
77
-	 */
78
-	public function isDefaultEnabledStream() {
79
-		return true;
80
-	}
74
+    /**
75
+     * @return bool True when the option can be changed for the stream
76
+     * @since 11.0.0
77
+     */
78
+    public function isDefaultEnabledStream() {
79
+        return true;
80
+    }
81 81
 
82
-	/**
83
-	 * @return bool True when the option can be changed for the mail
84
-	 * @since 11.0.0
85
-	 */
86
-	public function canChangeMail() {
87
-		return true;
88
-	}
82
+    /**
83
+     * @return bool True when the option can be changed for the mail
84
+     * @since 11.0.0
85
+     */
86
+    public function canChangeMail() {
87
+        return true;
88
+    }
89 89
 
90
-	/**
91
-	 * @return bool True when the option can be changed for the stream
92
-	 * @since 11.0.0
93
-	 */
94
-	public function isDefaultEnabledMail() {
95
-		return false;
96
-	}
90
+    /**
91
+     * @return bool True when the option can be changed for the stream
92
+     * @since 11.0.0
93
+     */
94
+    public function isDefaultEnabledMail() {
95
+        return false;
96
+    }
97 97
 }
98 98
 
Please login to merge, or discard this patch.
apps/files/lib/Activity/Settings/FileRestored.php 1 patch
Indentation   +59 added lines, -59 removed lines patch added patch discarded remove patch
@@ -27,72 +27,72 @@
 block discarded – undo
27 27
 
28 28
 class FileRestored implements ISetting {
29 29
 
30
-	/** @var IL10N */
31
-	protected $l;
30
+    /** @var IL10N */
31
+    protected $l;
32 32
 
33
-	/**
34
-	 * @param IL10N $l
35
-	 */
36
-	public function __construct(IL10N $l) {
37
-		$this->l = $l;
38
-	}
33
+    /**
34
+     * @param IL10N $l
35
+     */
36
+    public function __construct(IL10N $l) {
37
+        $this->l = $l;
38
+    }
39 39
 
40
-	/**
41
-	 * @return string Lowercase a-z and underscore only identifier
42
-	 * @since 11.0.0
43
-	 */
44
-	public function getIdentifier() {
45
-		return 'file_restored';
46
-	}
40
+    /**
41
+     * @return string Lowercase a-z and underscore only identifier
42
+     * @since 11.0.0
43
+     */
44
+    public function getIdentifier() {
45
+        return 'file_restored';
46
+    }
47 47
 
48
-	/**
49
-	 * @return string A translated string
50
-	 * @since 11.0.0
51
-	 */
52
-	public function getName() {
53
-		return $this->l->t('A file or folder has been <strong>restored</strong>');
54
-	}
48
+    /**
49
+     * @return string A translated string
50
+     * @since 11.0.0
51
+     */
52
+    public function getName() {
53
+        return $this->l->t('A file or folder has been <strong>restored</strong>');
54
+    }
55 55
 
56
-	/**
57
-	 * @return int whether the filter should be rather on the top or bottom of
58
-	 * the admin section. The filters are arranged in ascending order of the
59
-	 * priority values. It is required to return a value between 0 and 100.
60
-	 * @since 11.0.0
61
-	 */
62
-	public function getPriority() {
63
-		return 4;
64
-	}
56
+    /**
57
+     * @return int whether the filter should be rather on the top or bottom of
58
+     * the admin section. The filters are arranged in ascending order of the
59
+     * priority values. It is required to return a value between 0 and 100.
60
+     * @since 11.0.0
61
+     */
62
+    public function getPriority() {
63
+        return 4;
64
+    }
65 65
 
66
-	/**
67
-	 * @return bool True when the option can be changed for the stream
68
-	 * @since 11.0.0
69
-	 */
70
-	public function canChangeStream() {
71
-		return true;
72
-	}
66
+    /**
67
+     * @return bool True when the option can be changed for the stream
68
+     * @since 11.0.0
69
+     */
70
+    public function canChangeStream() {
71
+        return true;
72
+    }
73 73
 
74
-	/**
75
-	 * @return bool True when the option can be changed for the stream
76
-	 * @since 11.0.0
77
-	 */
78
-	public function isDefaultEnabledStream() {
79
-		return true;
80
-	}
74
+    /**
75
+     * @return bool True when the option can be changed for the stream
76
+     * @since 11.0.0
77
+     */
78
+    public function isDefaultEnabledStream() {
79
+        return true;
80
+    }
81 81
 
82
-	/**
83
-	 * @return bool True when the option can be changed for the mail
84
-	 * @since 11.0.0
85
-	 */
86
-	public function canChangeMail() {
87
-		return true;
88
-	}
82
+    /**
83
+     * @return bool True when the option can be changed for the mail
84
+     * @since 11.0.0
85
+     */
86
+    public function canChangeMail() {
87
+        return true;
88
+    }
89 89
 
90
-	/**
91
-	 * @return bool True when the option can be changed for the stream
92
-	 * @since 11.0.0
93
-	 */
94
-	public function isDefaultEnabledMail() {
95
-		return false;
96
-	}
90
+    /**
91
+     * @return bool True when the option can be changed for the stream
92
+     * @since 11.0.0
93
+     */
94
+    public function isDefaultEnabledMail() {
95
+        return false;
96
+    }
97 97
 }
98 98
 
Please login to merge, or discard this patch.
lib/public/AppFramework/Controller.php 2 patches
Indentation   +112 added lines, -112 removed lines patch added patch discarded remove patch
@@ -44,116 +44,116 @@
 block discarded – undo
44 44
  */
45 45
 abstract class Controller {
46 46
 
47
-	/**
48
-	 * app name
49
-	 * @var string
50
-	 * @since 7.0.0
51
-	 */
52
-	protected $appName;
53
-
54
-	/**
55
-	 * current request
56
-	 * @var \OCP\IRequest
57
-	 * @since 6.0.0
58
-	 */
59
-	protected $request;
60
-
61
-	/**
62
-	 * @var array
63
-	 * @since 7.0.0
64
-	 */
65
-	private $responders;
66
-
67
-	/**
68
-	 * constructor of the controller
69
-	 * @param string $appName the name of the app
70
-	 * @param IRequest $request an instance of the request
71
-	 * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
72
-	 */
73
-	public function __construct($appName,
74
-	                            IRequest $request) {
75
-		$this->appName = $appName;
76
-		$this->request = $request;
77
-
78
-		// default responders
79
-		$this->responders = array(
80
-			'json' => function ($data) {
81
-				if ($data instanceof DataResponse) {
82
-					$response = new JSONResponse(
83
-						$data->getData(),
84
-						$data->getStatus()
85
-					);
86
-					$dataHeaders = $data->getHeaders();
87
-					$headers = $response->getHeaders();
88
-					// do not overwrite Content-Type if it already exists
89
-					if (isset($dataHeaders['Content-Type'])) {
90
-						unset($headers['Content-Type']);
91
-					}
92
-					$response->setHeaders(array_merge($dataHeaders, $headers));
93
-					return $response;
94
-				}
95
-				return new JSONResponse($data);
96
-			}
97
-		);
98
-	}
99
-
100
-
101
-	/**
102
-	 * Parses an HTTP accept header and returns the supported responder type
103
-	 * @param string $acceptHeader
104
-	 * @param string $default
105
-	 * @return string the responder type
106
-	 * @since 7.0.0
107
-	 * @since 9.1.0 Added default parameter
108
-	 */
109
-	public function getResponderByHTTPHeader($acceptHeader, $default='json') {
110
-		$headers = explode(',', $acceptHeader);
111
-
112
-		// return the first matching responder
113
-		foreach ($headers as $header) {
114
-			$header = strtolower(trim($header));
115
-
116
-			$responder = str_replace('application/', '', $header);
117
-
118
-			if (array_key_exists($responder, $this->responders)) {
119
-				return $responder;
120
-			}
121
-		}
122
-
123
-		// no matching header return default
124
-		return $default;
125
-	}
126
-
127
-
128
-	/**
129
-	 * Registers a formatter for a type
130
-	 * @param string $format
131
-	 * @param \Closure $responder
132
-	 * @since 7.0.0
133
-	 */
134
-	protected function registerResponder($format, \Closure $responder) {
135
-		$this->responders[$format] = $responder;
136
-	}
137
-
138
-
139
-	/**
140
-	 * Serializes and formats a response
141
-	 * @param mixed $response the value that was returned from a controller and
142
-	 * is not a Response instance
143
-	 * @param string $format the format for which a formatter has been registered
144
-	 * @throws \DomainException if format does not match a registered formatter
145
-	 * @return Response
146
-	 * @since 7.0.0
147
-	 */
148
-	public function buildResponse($response, $format='json') {
149
-		if(array_key_exists($format, $this->responders)) {
150
-
151
-			$responder = $this->responders[$format];
152
-
153
-			return $responder($response);
154
-
155
-		}
156
-		throw new \DomainException('No responder registered for format '.
157
-			$format . '!');
158
-	}
47
+    /**
48
+     * app name
49
+     * @var string
50
+     * @since 7.0.0
51
+     */
52
+    protected $appName;
53
+
54
+    /**
55
+     * current request
56
+     * @var \OCP\IRequest
57
+     * @since 6.0.0
58
+     */
59
+    protected $request;
60
+
61
+    /**
62
+     * @var array
63
+     * @since 7.0.0
64
+     */
65
+    private $responders;
66
+
67
+    /**
68
+     * constructor of the controller
69
+     * @param string $appName the name of the app
70
+     * @param IRequest $request an instance of the request
71
+     * @since 6.0.0 - parameter $appName was added in 7.0.0 - parameter $app was removed in 7.0.0
72
+     */
73
+    public function __construct($appName,
74
+                                IRequest $request) {
75
+        $this->appName = $appName;
76
+        $this->request = $request;
77
+
78
+        // default responders
79
+        $this->responders = array(
80
+            'json' => function ($data) {
81
+                if ($data instanceof DataResponse) {
82
+                    $response = new JSONResponse(
83
+                        $data->getData(),
84
+                        $data->getStatus()
85
+                    );
86
+                    $dataHeaders = $data->getHeaders();
87
+                    $headers = $response->getHeaders();
88
+                    // do not overwrite Content-Type if it already exists
89
+                    if (isset($dataHeaders['Content-Type'])) {
90
+                        unset($headers['Content-Type']);
91
+                    }
92
+                    $response->setHeaders(array_merge($dataHeaders, $headers));
93
+                    return $response;
94
+                }
95
+                return new JSONResponse($data);
96
+            }
97
+        );
98
+    }
99
+
100
+
101
+    /**
102
+     * Parses an HTTP accept header and returns the supported responder type
103
+     * @param string $acceptHeader
104
+     * @param string $default
105
+     * @return string the responder type
106
+     * @since 7.0.0
107
+     * @since 9.1.0 Added default parameter
108
+     */
109
+    public function getResponderByHTTPHeader($acceptHeader, $default='json') {
110
+        $headers = explode(',', $acceptHeader);
111
+
112
+        // return the first matching responder
113
+        foreach ($headers as $header) {
114
+            $header = strtolower(trim($header));
115
+
116
+            $responder = str_replace('application/', '', $header);
117
+
118
+            if (array_key_exists($responder, $this->responders)) {
119
+                return $responder;
120
+            }
121
+        }
122
+
123
+        // no matching header return default
124
+        return $default;
125
+    }
126
+
127
+
128
+    /**
129
+     * Registers a formatter for a type
130
+     * @param string $format
131
+     * @param \Closure $responder
132
+     * @since 7.0.0
133
+     */
134
+    protected function registerResponder($format, \Closure $responder) {
135
+        $this->responders[$format] = $responder;
136
+    }
137
+
138
+
139
+    /**
140
+     * Serializes and formats a response
141
+     * @param mixed $response the value that was returned from a controller and
142
+     * is not a Response instance
143
+     * @param string $format the format for which a formatter has been registered
144
+     * @throws \DomainException if format does not match a registered formatter
145
+     * @return Response
146
+     * @since 7.0.0
147
+     */
148
+    public function buildResponse($response, $format='json') {
149
+        if(array_key_exists($format, $this->responders)) {
150
+
151
+            $responder = $this->responders[$format];
152
+
153
+            return $responder($response);
154
+
155
+        }
156
+        throw new \DomainException('No responder registered for format '.
157
+            $format . '!');
158
+    }
159 159
 }
Please login to merge, or discard this patch.
Spacing   +5 added lines, -5 removed lines patch added patch discarded remove patch
@@ -77,7 +77,7 @@  discard block
 block discarded – undo
77 77
 
78 78
 		// default responders
79 79
 		$this->responders = array(
80
-			'json' => function ($data) {
80
+			'json' => function($data) {
81 81
 				if ($data instanceof DataResponse) {
82 82
 					$response = new JSONResponse(
83 83
 						$data->getData(),
@@ -106,7 +106,7 @@  discard block
 block discarded – undo
106 106
 	 * @since 7.0.0
107 107
 	 * @since 9.1.0 Added default parameter
108 108
 	 */
109
-	public function getResponderByHTTPHeader($acceptHeader, $default='json') {
109
+	public function getResponderByHTTPHeader($acceptHeader, $default = 'json') {
110 110
 		$headers = explode(',', $acceptHeader);
111 111
 
112 112
 		// return the first matching responder
@@ -145,8 +145,8 @@  discard block
 block discarded – undo
145 145
 	 * @return Response
146 146
 	 * @since 7.0.0
147 147
 	 */
148
-	public function buildResponse($response, $format='json') {
149
-		if(array_key_exists($format, $this->responders)) {
148
+	public function buildResponse($response, $format = 'json') {
149
+		if (array_key_exists($format, $this->responders)) {
150 150
 
151 151
 			$responder = $this->responders[$format];
152 152
 
@@ -154,6 +154,6 @@  discard block
 block discarded – undo
154 154
 
155 155
 		}
156 156
 		throw new \DomainException('No responder registered for format '.
157
-			$format . '!');
157
+			$format.'!');
158 158
 	}
159 159
 }
Please login to merge, or discard this patch.
apps/dav/appinfo/v1/publicwebdav.php 2 patches
Indentation   +48 added lines, -48 removed lines patch added patch discarded remove patch
@@ -38,21 +38,21 @@  discard block
 block discarded – undo
38 38
 
39 39
 // Backends
40 40
 $authBackend = new OCA\DAV\Connector\PublicAuth(
41
-	\OC::$server->getRequest(),
42
-	\OC::$server->getShareManager(),
43
-	\OC::$server->getSession()
41
+    \OC::$server->getRequest(),
42
+    \OC::$server->getShareManager(),
43
+    \OC::$server->getSession()
44 44
 );
45 45
 $authPlugin = new \Sabre\DAV\Auth\Plugin($authBackend);
46 46
 
47 47
 $serverFactory = new OCA\DAV\Connector\Sabre\ServerFactory(
48
-	\OC::$server->getConfig(),
49
-	\OC::$server->getLogger(),
50
-	\OC::$server->getDatabaseConnection(),
51
-	\OC::$server->getUserSession(),
52
-	\OC::$server->getMountManager(),
53
-	\OC::$server->getTagManager(),
54
-	\OC::$server->getRequest(),
55
-	\OC::$server->getPreviewManager()
48
+    \OC::$server->getConfig(),
49
+    \OC::$server->getLogger(),
50
+    \OC::$server->getDatabaseConnection(),
51
+    \OC::$server->getUserSession(),
52
+    \OC::$server->getMountManager(),
53
+    \OC::$server->getTagManager(),
54
+    \OC::$server->getRequest(),
55
+    \OC::$server->getPreviewManager()
56 56
 );
57 57
 
58 58
 $requestUri = \OC::$server->getRequest()->getRequestUri();
@@ -61,43 +61,43 @@  discard block
 block discarded – undo
61 61
 $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
62 62
 
63 63
 $server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
64
-	$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
65
-	$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
66
-	$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
67
-	if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
68
-		// this is what is thrown when trying to access a non-existing share
69
-		throw new \Sabre\DAV\Exception\NotAuthenticated();
70
-	}
71
-
72
-	$share = $authBackend->getShare();
73
-	$owner = $share->getShareOwner();
74
-	$isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
75
-	$fileId = $share->getNodeId();
76
-
77
-	// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
78
-	$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
79
-	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
80
-		return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
81
-	});
82
-
83
-	\OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
84
-
85
-	OC_Util::tearDownFS();
86
-	OC_Util::setupFS($owner);
87
-	$ownerView = new \OC\Files\View('/'. $owner . '/files');
88
-	$path = $ownerView->getPath($fileId);
89
-	$fileInfo = $ownerView->getFileInfo($path);
90
-	$linkCheckPlugin->setFileInfo($fileInfo);
91
-
92
-	// If not readble (files_drop) enable the filesdrop plugin
93
-	if (!$isReadable) {
94
-		$filesDropPlugin->enable();
95
-	}
96
-
97
-	$view = new \OC\Files\View($ownerView->getAbsolutePath($path));
98
-	$filesDropPlugin->setView($view);
99
-
100
-	return $view;
64
+    $isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
65
+    $federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
66
+    $federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
67
+    if ($federatedShareProvider->isOutgoingServer2serverShareEnabled() === false && !$isAjax) {
68
+        // this is what is thrown when trying to access a non-existing share
69
+        throw new \Sabre\DAV\Exception\NotAuthenticated();
70
+    }
71
+
72
+    $share = $authBackend->getShare();
73
+    $owner = $share->getShareOwner();
74
+    $isReadable = $share->getPermissions() & \OCP\Constants::PERMISSION_READ;
75
+    $fileId = $share->getNodeId();
76
+
77
+    // FIXME: should not add storage wrappers outside of preSetup, need to find a better way
78
+    $previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
79
+    \OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
80
+        return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
81
+    });
82
+
83
+    \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper($previousLog);
84
+
85
+    OC_Util::tearDownFS();
86
+    OC_Util::setupFS($owner);
87
+    $ownerView = new \OC\Files\View('/'. $owner . '/files');
88
+    $path = $ownerView->getPath($fileId);
89
+    $fileInfo = $ownerView->getFileInfo($path);
90
+    $linkCheckPlugin->setFileInfo($fileInfo);
91
+
92
+    // If not readble (files_drop) enable the filesdrop plugin
93
+    if (!$isReadable) {
94
+        $filesDropPlugin->enable();
95
+    }
96
+
97
+    $view = new \OC\Files\View($ownerView->getAbsolutePath($path));
98
+    $filesDropPlugin->setView($view);
99
+
100
+    return $view;
101 101
 });
102 102
 
103 103
 $server->addPlugin($linkCheckPlugin);
Please login to merge, or discard this patch.
Spacing   +3 added lines, -3 removed lines patch added patch discarded remove patch
@@ -60,7 +60,7 @@  discard block
 block discarded – undo
60 60
 $linkCheckPlugin = new \OCA\DAV\Files\Sharing\PublicLinkCheckPlugin();
61 61
 $filesDropPlugin = new \OCA\DAV\Files\Sharing\FilesDropPlugin();
62 62
 
63
-$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function (\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
63
+$server = $serverFactory->createServer($baseuri, $requestUri, $authPlugin, function(\Sabre\DAV\Server $server) use ($authBackend, $linkCheckPlugin, $filesDropPlugin) {
64 64
 	$isAjax = (isset($_SERVER['HTTP_X_REQUESTED_WITH']) && $_SERVER['HTTP_X_REQUESTED_WITH'] === 'XMLHttpRequest');
65 65
 	$federatedSharingApp = new \OCA\FederatedFileSharing\AppInfo\Application();
66 66
 	$federatedShareProvider = $federatedSharingApp->getFederatedShareProvider();
@@ -76,7 +76,7 @@  discard block
 block discarded – undo
76 76
 
77 77
 	// FIXME: should not add storage wrappers outside of preSetup, need to find a better way
78 78
 	$previousLog = \OC\Files\Filesystem::logWarningWhenAddingStorageWrapper(false);
79
-	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function ($mountPoint, $storage) use ($share) {
79
+	\OC\Files\Filesystem::addStorageWrapper('sharePermissions', function($mountPoint, $storage) use ($share) {
80 80
 		return new \OC\Files\Storage\Wrapper\PermissionsMask(array('storage' => $storage, 'mask' => $share->getPermissions() | \OCP\Constants::PERMISSION_SHARE));
81 81
 	});
82 82
 
@@ -84,7 +84,7 @@  discard block
 block discarded – undo
84 84
 
85 85
 	OC_Util::tearDownFS();
86 86
 	OC_Util::setupFS($owner);
87
-	$ownerView = new \OC\Files\View('/'. $owner . '/files');
87
+	$ownerView = new \OC\Files\View('/'.$owner.'/files');
88 88
 	$path = $ownerView->getPath($fileId);
89 89
 	$fileInfo = $ownerView->getFileInfo($path);
90 90
 	$linkCheckPlugin->setFileInfo($fileInfo);
Please login to merge, or discard this patch.
lib/private/DB/QueryBuilder/QueryBuilder.php 2 patches
Spacing   +7 added lines, -7 removed lines patch added patch discarded remove patch
@@ -191,9 +191,9 @@  discard block
 block discarded – undo
191 191
 			$params = [];
192 192
 			foreach ($this->getParameters() as $placeholder => $value) {
193 193
 				if (is_array($value)) {
194
-					$params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
194
+					$params[] = $placeholder.' => (\''.implode('\', \'', $value).'\')';
195 195
 				} else {
196
-					$params[] = $placeholder . ' => \'' . $value . '\'';
196
+					$params[] = $placeholder.' => \''.$value.'\'';
197 197
 				}
198 198
 			}
199 199
 			if (empty($params)) {
@@ -410,7 +410,7 @@  discard block
 block discarded – undo
410 410
 	public function selectAlias($select, $alias) {
411 411
 
412 412
 		$this->queryBuilder->addSelect(
413
-			$this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
413
+			$this->helper->quoteColumnName($select).' AS '.$this->helper->quoteColumnName($alias)
414 414
 		);
415 415
 
416 416
 		return $this;
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
 	public function selectDistinct($select) {
433 433
 
434 434
 		$this->queryBuilder->addSelect(
435
-			'DISTINCT ' . $this->helper->quoteColumnName($select)
435
+			'DISTINCT '.$this->helper->quoteColumnName($select)
436 436
 		);
437 437
 
438 438
 		return $this;
@@ -1109,7 +1109,7 @@  discard block
 block discarded – undo
1109 1109
 	 * @return IParameter
1110 1110
 	 */
1111 1111
 	public function createParameter($name) {
1112
-		return new Parameter(':' . $name);
1112
+		return new Parameter(':'.$name);
1113 1113
 	}
1114 1114
 
1115 1115
 	/**
@@ -1176,7 +1176,7 @@  discard block
 block discarded – undo
1176 1176
 			return $table;
1177 1177
 		}
1178 1178
 
1179
-		return '*PREFIX*' . $table;
1179
+		return '*PREFIX*'.$table;
1180 1180
 	}
1181 1181
 
1182 1182
 	/**
@@ -1191,7 +1191,7 @@  discard block
 block discarded – undo
1191 1191
 			$tableAlias .= '.';
1192 1192
 		}
1193 1193
 
1194
-		return $this->helper->quoteColumnName($tableAlias . $column);
1194
+		return $this->helper->quoteColumnName($tableAlias.$column);
1195 1195
 	}
1196 1196
 
1197 1197
 	/**
Please login to merge, or discard this patch.
Indentation   +1173 added lines, -1173 removed lines patch added patch discarded remove patch
@@ -47,1177 +47,1177 @@
 block discarded – undo
47 47
 
48 48
 class QueryBuilder implements IQueryBuilder {
49 49
 
50
-	/** @var \OCP\IDBConnection */
51
-	private $connection;
52
-
53
-	/** @var SystemConfig */
54
-	private $systemConfig;
55
-
56
-	/** @var ILogger */
57
-	private $logger;
58
-
59
-	/** @var \Doctrine\DBAL\Query\QueryBuilder */
60
-	private $queryBuilder;
61
-
62
-	/** @var QuoteHelper */
63
-	private $helper;
64
-
65
-	/** @var bool */
66
-	private $automaticTablePrefix = true;
67
-
68
-	/** @var string */
69
-	protected $lastInsertedTable;
70
-
71
-	/**
72
-	 * Initializes a new QueryBuilder.
73
-	 *
74
-	 * @param IDBConnection $connection
75
-	 * @param SystemConfig $systemConfig
76
-	 * @param ILogger $logger
77
-	 */
78
-	public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) {
79
-		$this->connection = $connection;
80
-		$this->systemConfig = $systemConfig;
81
-		$this->logger = $logger;
82
-		$this->queryBuilder = new \Doctrine\DBAL\Query\QueryBuilder($this->connection);
83
-		$this->helper = new QuoteHelper();
84
-	}
85
-
86
-	/**
87
-	 * Enable/disable automatic prefixing of table names with the oc_ prefix
88
-	 *
89
-	 * @param bool $enabled If set to true table names will be prefixed with the
90
-	 * owncloud database prefix automatically.
91
-	 * @since 8.2.0
92
-	 */
93
-	public function automaticTablePrefix($enabled) {
94
-		$this->automaticTablePrefix = (bool) $enabled;
95
-	}
96
-
97
-	/**
98
-	 * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
99
-	 * This producer method is intended for convenient inline usage. Example:
100
-	 *
101
-	 * <code>
102
-	 *     $qb = $conn->getQueryBuilder()
103
-	 *         ->select('u')
104
-	 *         ->from('users', 'u')
105
-	 *         ->where($qb->expr()->eq('u.id', 1));
106
-	 * </code>
107
-	 *
108
-	 * For more complex expression construction, consider storing the expression
109
-	 * builder object in a local variable.
110
-	 *
111
-	 * @return \OCP\DB\QueryBuilder\IExpressionBuilder
112
-	 */
113
-	public function expr() {
114
-		if ($this->connection instanceof OracleConnection) {
115
-			return new OCIExpressionBuilder($this->connection, $this);
116
-		} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
117
-			return new PgSqlExpressionBuilder($this->connection, $this);
118
-		} else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
119
-			return new MySqlExpressionBuilder($this->connection, $this);
120
-		} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
121
-			return new SqliteExpressionBuilder($this->connection, $this);
122
-		} else {
123
-			return new ExpressionBuilder($this->connection, $this);
124
-		}
125
-	}
126
-
127
-	/**
128
-	 * Gets an FunctionBuilder used for object-oriented construction of query functions.
129
-	 * This producer method is intended for convenient inline usage. Example:
130
-	 *
131
-	 * <code>
132
-	 *     $qb = $conn->getQueryBuilder()
133
-	 *         ->select('u')
134
-	 *         ->from('users', 'u')
135
-	 *         ->where($qb->fun()->md5('u.id'));
136
-	 * </code>
137
-	 *
138
-	 * For more complex function construction, consider storing the function
139
-	 * builder object in a local variable.
140
-	 *
141
-	 * @return \OCP\DB\QueryBuilder\IFunctionBuilder
142
-	 */
143
-	public function func() {
144
-		if ($this->connection instanceof OracleConnection) {
145
-			return new OCIFunctionBuilder($this->helper);
146
-		} else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
147
-			return new SqliteFunctionBuilder($this->helper);
148
-		} else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
149
-			return new PgSqlFunctionBuilder($this->helper);
150
-		} else {
151
-			return new FunctionBuilder($this->helper);
152
-		}
153
-	}
154
-
155
-	/**
156
-	 * Gets the type of the currently built query.
157
-	 *
158
-	 * @return integer
159
-	 */
160
-	public function getType() {
161
-		return $this->queryBuilder->getType();
162
-	}
163
-
164
-	/**
165
-	 * Gets the associated DBAL Connection for this query builder.
166
-	 *
167
-	 * @return \OCP\IDBConnection
168
-	 */
169
-	public function getConnection() {
170
-		return $this->connection;
171
-	}
172
-
173
-	/**
174
-	 * Gets the state of this query builder instance.
175
-	 *
176
-	 * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
177
-	 */
178
-	public function getState() {
179
-		return $this->queryBuilder->getState();
180
-	}
181
-
182
-	/**
183
-	 * Executes this query using the bound parameters and their types.
184
-	 *
185
-	 * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
186
-	 * for insert, update and delete statements.
187
-	 *
188
-	 * @return \Doctrine\DBAL\Driver\Statement|int
189
-	 */
190
-	public function execute() {
191
-		if ($this->systemConfig->getValue('log_query', false)) {
192
-			$params = [];
193
-			foreach ($this->getParameters() as $placeholder => $value) {
194
-				if (is_array($value)) {
195
-					$params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
196
-				} else {
197
-					$params[] = $placeholder . ' => \'' . $value . '\'';
198
-				}
199
-			}
200
-			if (empty($params)) {
201
-				$this->logger->debug('DB QueryBuilder: \'{query}\'', [
202
-					'query' => $this->getSQL(),
203
-					'app' => 'core',
204
-				]);
205
-			} else {
206
-				$this->logger->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [
207
-					'query' => $this->getSQL(),
208
-					'params' => implode(', ', $params),
209
-					'app' => 'core',
210
-				]);
211
-			}
212
-		}
213
-
214
-		return $this->queryBuilder->execute();
215
-	}
216
-
217
-	/**
218
-	 * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
219
-	 *
220
-	 * <code>
221
-	 *     $qb = $conn->getQueryBuilder()
222
-	 *         ->select('u')
223
-	 *         ->from('User', 'u')
224
-	 *     echo $qb->getSQL(); // SELECT u FROM User u
225
-	 * </code>
226
-	 *
227
-	 * @return string The SQL query string.
228
-	 */
229
-	public function getSQL() {
230
-		return $this->queryBuilder->getSQL();
231
-	}
232
-
233
-	/**
234
-	 * Sets a query parameter for the query being constructed.
235
-	 *
236
-	 * <code>
237
-	 *     $qb = $conn->getQueryBuilder()
238
-	 *         ->select('u')
239
-	 *         ->from('users', 'u')
240
-	 *         ->where('u.id = :user_id')
241
-	 *         ->setParameter(':user_id', 1);
242
-	 * </code>
243
-	 *
244
-	 * @param string|integer $key The parameter position or name.
245
-	 * @param mixed $value The parameter value.
246
-	 * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
247
-	 *
248
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
249
-	 */
250
-	public function setParameter($key, $value, $type = null) {
251
-		$this->queryBuilder->setParameter($key, $value, $type);
252
-
253
-		return $this;
254
-	}
255
-
256
-	/**
257
-	 * Sets a collection of query parameters for the query being constructed.
258
-	 *
259
-	 * <code>
260
-	 *     $qb = $conn->getQueryBuilder()
261
-	 *         ->select('u')
262
-	 *         ->from('users', 'u')
263
-	 *         ->where('u.id = :user_id1 OR u.id = :user_id2')
264
-	 *         ->setParameters(array(
265
-	 *             ':user_id1' => 1,
266
-	 *             ':user_id2' => 2
267
-	 *         ));
268
-	 * </code>
269
-	 *
270
-	 * @param array $params The query parameters to set.
271
-	 * @param array $types The query parameters types to set.
272
-	 *
273
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
274
-	 */
275
-	public function setParameters(array $params, array $types = array()) {
276
-		$this->queryBuilder->setParameters($params, $types);
277
-
278
-		return $this;
279
-	}
280
-
281
-	/**
282
-	 * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
283
-	 *
284
-	 * @return array The currently defined query parameters indexed by parameter index or name.
285
-	 */
286
-	public function getParameters() {
287
-		return $this->queryBuilder->getParameters();
288
-	}
289
-
290
-	/**
291
-	 * Gets a (previously set) query parameter of the query being constructed.
292
-	 *
293
-	 * @param mixed $key The key (index or name) of the bound parameter.
294
-	 *
295
-	 * @return mixed The value of the bound parameter.
296
-	 */
297
-	public function getParameter($key) {
298
-		return $this->queryBuilder->getParameter($key);
299
-	}
300
-
301
-	/**
302
-	 * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
303
-	 *
304
-	 * @return array The currently defined query parameter types indexed by parameter index or name.
305
-	 */
306
-	public function getParameterTypes() {
307
-		return $this->queryBuilder->getParameterTypes();
308
-	}
309
-
310
-	/**
311
-	 * Gets a (previously set) query parameter type of the query being constructed.
312
-	 *
313
-	 * @param mixed $key The key (index or name) of the bound parameter type.
314
-	 *
315
-	 * @return mixed The value of the bound parameter type.
316
-	 */
317
-	public function getParameterType($key) {
318
-		return $this->queryBuilder->getParameterType($key);
319
-	}
320
-
321
-	/**
322
-	 * Sets the position of the first result to retrieve (the "offset").
323
-	 *
324
-	 * @param integer $firstResult The first result to return.
325
-	 *
326
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
327
-	 */
328
-	public function setFirstResult($firstResult) {
329
-		$this->queryBuilder->setFirstResult($firstResult);
330
-
331
-		return $this;
332
-	}
333
-
334
-	/**
335
-	 * Gets the position of the first result the query object was set to retrieve (the "offset").
336
-	 * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
337
-	 *
338
-	 * @return integer The position of the first result.
339
-	 */
340
-	public function getFirstResult() {
341
-		return $this->queryBuilder->getFirstResult();
342
-	}
343
-
344
-	/**
345
-	 * Sets the maximum number of results to retrieve (the "limit").
346
-	 *
347
-	 * NOTE: Setting max results to "0" will cause mixed behaviour. While most
348
-	 * of the databases will just return an empty result set, Oracle will return
349
-	 * all entries.
350
-	 *
351
-	 * @param integer $maxResults The maximum number of results to retrieve.
352
-	 *
353
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
354
-	 */
355
-	public function setMaxResults($maxResults) {
356
-		$this->queryBuilder->setMaxResults($maxResults);
357
-
358
-		return $this;
359
-	}
360
-
361
-	/**
362
-	 * Gets the maximum number of results the query object was set to retrieve (the "limit").
363
-	 * Returns NULL if {@link setMaxResults} was not applied to this query builder.
364
-	 *
365
-	 * @return integer The maximum number of results.
366
-	 */
367
-	public function getMaxResults() {
368
-		return $this->queryBuilder->getMaxResults();
369
-	}
370
-
371
-	/**
372
-	 * Specifies an item that is to be returned in the query result.
373
-	 * Replaces any previously specified selections, if any.
374
-	 *
375
-	 * <code>
376
-	 *     $qb = $conn->getQueryBuilder()
377
-	 *         ->select('u.id', 'p.id')
378
-	 *         ->from('users', 'u')
379
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
380
-	 * </code>
381
-	 *
382
-	 * @param mixed ...$selects The selection expressions.
383
-	 *
384
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
385
-	 */
386
-	public function select(...$selects) {
387
-		if (count($selects) === 1 && is_array($selects[0])) {
388
-			$selects = $selects[0];
389
-		}
390
-
391
-		$this->queryBuilder->select(
392
-			$this->helper->quoteColumnNames($selects)
393
-		);
394
-
395
-		return $this;
396
-	}
397
-
398
-	/**
399
-	 * Specifies an item that is to be returned with a different name in the query result.
400
-	 *
401
-	 * <code>
402
-	 *     $qb = $conn->getQueryBuilder()
403
-	 *         ->selectAlias('u.id', 'user_id')
404
-	 *         ->from('users', 'u')
405
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
406
-	 * </code>
407
-	 *
408
-	 * @param mixed $select The selection expressions.
409
-	 * @param string $alias The column alias used in the constructed query.
410
-	 *
411
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
412
-	 */
413
-	public function selectAlias($select, $alias) {
414
-
415
-		$this->queryBuilder->addSelect(
416
-			$this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
417
-		);
418
-
419
-		return $this;
420
-	}
421
-
422
-	/**
423
-	 * Specifies an item that is to be returned uniquely in the query result.
424
-	 *
425
-	 * <code>
426
-	 *     $qb = $conn->getQueryBuilder()
427
-	 *         ->selectDistinct('type')
428
-	 *         ->from('users');
429
-	 * </code>
430
-	 *
431
-	 * @param mixed $select The selection expressions.
432
-	 *
433
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
434
-	 */
435
-	public function selectDistinct($select) {
436
-
437
-		$this->queryBuilder->addSelect(
438
-			'DISTINCT ' . $this->helper->quoteColumnName($select)
439
-		);
440
-
441
-		return $this;
442
-	}
443
-
444
-	/**
445
-	 * Adds an item that is to be returned in the query result.
446
-	 *
447
-	 * <code>
448
-	 *     $qb = $conn->getQueryBuilder()
449
-	 *         ->select('u.id')
450
-	 *         ->addSelect('p.id')
451
-	 *         ->from('users', 'u')
452
-	 *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
453
-	 * </code>
454
-	 *
455
-	 * @param mixed ...$selects The selection expression.
456
-	 *
457
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
458
-	 */
459
-	public function addSelect(...$selects) {
460
-		if (count($selects) === 1 && is_array($selects[0])) {
461
-			$selects = $selects[0];
462
-		}
463
-
464
-		$this->queryBuilder->addSelect(
465
-			$this->helper->quoteColumnNames($selects)
466
-		);
467
-
468
-		return $this;
469
-	}
470
-
471
-	/**
472
-	 * Turns the query being built into a bulk delete query that ranges over
473
-	 * a certain table.
474
-	 *
475
-	 * <code>
476
-	 *     $qb = $conn->getQueryBuilder()
477
-	 *         ->delete('users', 'u')
478
-	 *         ->where('u.id = :user_id');
479
-	 *         ->setParameter(':user_id', 1);
480
-	 * </code>
481
-	 *
482
-	 * @param string $delete The table whose rows are subject to the deletion.
483
-	 * @param string $alias The table alias used in the constructed query.
484
-	 *
485
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
486
-	 */
487
-	public function delete($delete = null, $alias = null) {
488
-		$this->queryBuilder->delete(
489
-			$this->getTableName($delete),
490
-			$alias
491
-		);
492
-
493
-		return $this;
494
-	}
495
-
496
-	/**
497
-	 * Turns the query being built into a bulk update query that ranges over
498
-	 * a certain table
499
-	 *
500
-	 * <code>
501
-	 *     $qb = $conn->getQueryBuilder()
502
-	 *         ->update('users', 'u')
503
-	 *         ->set('u.password', md5('password'))
504
-	 *         ->where('u.id = ?');
505
-	 * </code>
506
-	 *
507
-	 * @param string $update The table whose rows are subject to the update.
508
-	 * @param string $alias The table alias used in the constructed query.
509
-	 *
510
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
511
-	 */
512
-	public function update($update = null, $alias = null) {
513
-		$this->queryBuilder->update(
514
-			$this->getTableName($update),
515
-			$alias
516
-		);
517
-
518
-		return $this;
519
-	}
520
-
521
-	/**
522
-	 * Turns the query being built into an insert query that inserts into
523
-	 * a certain table
524
-	 *
525
-	 * <code>
526
-	 *     $qb = $conn->getQueryBuilder()
527
-	 *         ->insert('users')
528
-	 *         ->values(
529
-	 *             array(
530
-	 *                 'name' => '?',
531
-	 *                 'password' => '?'
532
-	 *             )
533
-	 *         );
534
-	 * </code>
535
-	 *
536
-	 * @param string $insert The table into which the rows should be inserted.
537
-	 *
538
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
539
-	 */
540
-	public function insert($insert = null) {
541
-		$this->queryBuilder->insert(
542
-			$this->getTableName($insert)
543
-		);
544
-
545
-		$this->lastInsertedTable = $insert;
546
-
547
-		return $this;
548
-	}
549
-
550
-	/**
551
-	 * Creates and adds a query root corresponding to the table identified by the
552
-	 * given alias, forming a cartesian product with any existing query roots.
553
-	 *
554
-	 * <code>
555
-	 *     $qb = $conn->getQueryBuilder()
556
-	 *         ->select('u.id')
557
-	 *         ->from('users', 'u')
558
-	 * </code>
559
-	 *
560
-	 * @param string $from The table.
561
-	 * @param string|null $alias The alias of the table.
562
-	 *
563
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
564
-	 */
565
-	public function from($from, $alias = null) {
566
-		$this->queryBuilder->from(
567
-			$this->getTableName($from),
568
-			$this->quoteAlias($alias)
569
-		);
570
-
571
-		return $this;
572
-	}
573
-
574
-	/**
575
-	 * Creates and adds a join to the query.
576
-	 *
577
-	 * <code>
578
-	 *     $qb = $conn->getQueryBuilder()
579
-	 *         ->select('u.name')
580
-	 *         ->from('users', 'u')
581
-	 *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
582
-	 * </code>
583
-	 *
584
-	 * @param string $fromAlias The alias that points to a from clause.
585
-	 * @param string $join The table name to join.
586
-	 * @param string $alias The alias of the join table.
587
-	 * @param string $condition The condition for the join.
588
-	 *
589
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
590
-	 */
591
-	public function join($fromAlias, $join, $alias, $condition = null) {
592
-		$this->queryBuilder->join(
593
-			$this->quoteAlias($fromAlias),
594
-			$this->getTableName($join),
595
-			$this->quoteAlias($alias),
596
-			$condition
597
-		);
598
-
599
-		return $this;
600
-	}
601
-
602
-	/**
603
-	 * Creates and adds a join to the query.
604
-	 *
605
-	 * <code>
606
-	 *     $qb = $conn->getQueryBuilder()
607
-	 *         ->select('u.name')
608
-	 *         ->from('users', 'u')
609
-	 *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
610
-	 * </code>
611
-	 *
612
-	 * @param string $fromAlias The alias that points to a from clause.
613
-	 * @param string $join The table name to join.
614
-	 * @param string $alias The alias of the join table.
615
-	 * @param string $condition The condition for the join.
616
-	 *
617
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
618
-	 */
619
-	public function innerJoin($fromAlias, $join, $alias, $condition = null) {
620
-		$this->queryBuilder->innerJoin(
621
-			$this->quoteAlias($fromAlias),
622
-			$this->getTableName($join),
623
-			$this->quoteAlias($alias),
624
-			$condition
625
-		);
626
-
627
-		return $this;
628
-	}
629
-
630
-	/**
631
-	 * Creates and adds a left join to the query.
632
-	 *
633
-	 * <code>
634
-	 *     $qb = $conn->getQueryBuilder()
635
-	 *         ->select('u.name')
636
-	 *         ->from('users', 'u')
637
-	 *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
638
-	 * </code>
639
-	 *
640
-	 * @param string $fromAlias The alias that points to a from clause.
641
-	 * @param string $join The table name to join.
642
-	 * @param string $alias The alias of the join table.
643
-	 * @param string $condition The condition for the join.
644
-	 *
645
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
646
-	 */
647
-	public function leftJoin($fromAlias, $join, $alias, $condition = null) {
648
-		$this->queryBuilder->leftJoin(
649
-			$this->quoteAlias($fromAlias),
650
-			$this->getTableName($join),
651
-			$this->quoteAlias($alias),
652
-			$condition
653
-		);
654
-
655
-		return $this;
656
-	}
657
-
658
-	/**
659
-	 * Creates and adds a right join to the query.
660
-	 *
661
-	 * <code>
662
-	 *     $qb = $conn->getQueryBuilder()
663
-	 *         ->select('u.name')
664
-	 *         ->from('users', 'u')
665
-	 *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
666
-	 * </code>
667
-	 *
668
-	 * @param string $fromAlias The alias that points to a from clause.
669
-	 * @param string $join The table name to join.
670
-	 * @param string $alias The alias of the join table.
671
-	 * @param string $condition The condition for the join.
672
-	 *
673
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
674
-	 */
675
-	public function rightJoin($fromAlias, $join, $alias, $condition = null) {
676
-		$this->queryBuilder->rightJoin(
677
-			$this->quoteAlias($fromAlias),
678
-			$this->getTableName($join),
679
-			$this->quoteAlias($alias),
680
-			$condition
681
-		);
682
-
683
-		return $this;
684
-	}
685
-
686
-	/**
687
-	 * Sets a new value for a column in a bulk update query.
688
-	 *
689
-	 * <code>
690
-	 *     $qb = $conn->getQueryBuilder()
691
-	 *         ->update('users', 'u')
692
-	 *         ->set('u.password', md5('password'))
693
-	 *         ->where('u.id = ?');
694
-	 * </code>
695
-	 *
696
-	 * @param string $key The column to set.
697
-	 * @param string $value The value, expression, placeholder, etc.
698
-	 *
699
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
700
-	 */
701
-	public function set($key, $value) {
702
-		$this->queryBuilder->set(
703
-			$this->helper->quoteColumnName($key),
704
-			$this->helper->quoteColumnName($value)
705
-		);
706
-
707
-		return $this;
708
-	}
709
-
710
-	/**
711
-	 * Specifies one or more restrictions to the query result.
712
-	 * Replaces any previously specified restrictions, if any.
713
-	 *
714
-	 * <code>
715
-	 *     $qb = $conn->getQueryBuilder()
716
-	 *         ->select('u.name')
717
-	 *         ->from('users', 'u')
718
-	 *         ->where('u.id = ?');
719
-	 *
720
-	 *     // You can optionally programatically build and/or expressions
721
-	 *     $qb = $conn->getQueryBuilder();
722
-	 *
723
-	 *     $or = $qb->expr()->orx();
724
-	 *     $or->add($qb->expr()->eq('u.id', 1));
725
-	 *     $or->add($qb->expr()->eq('u.id', 2));
726
-	 *
727
-	 *     $qb->update('users', 'u')
728
-	 *         ->set('u.password', md5('password'))
729
-	 *         ->where($or);
730
-	 * </code>
731
-	 *
732
-	 * @param mixed ...$predicates The restriction predicates.
733
-	 *
734
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
735
-	 */
736
-	public function where(...$predicates) {
737
-		call_user_func_array(
738
-			[$this->queryBuilder, 'where'],
739
-			$predicates
740
-		);
741
-
742
-		return $this;
743
-	}
744
-
745
-	/**
746
-	 * Adds one or more restrictions to the query results, forming a logical
747
-	 * conjunction with any previously specified restrictions.
748
-	 *
749
-	 * <code>
750
-	 *     $qb = $conn->getQueryBuilder()
751
-	 *         ->select('u')
752
-	 *         ->from('users', 'u')
753
-	 *         ->where('u.username LIKE ?')
754
-	 *         ->andWhere('u.is_active = 1');
755
-	 * </code>
756
-	 *
757
-	 * @param mixed ...$where The query restrictions.
758
-	 *
759
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
760
-	 *
761
-	 * @see where()
762
-	 */
763
-	public function andWhere(...$where) {
764
-		call_user_func_array(
765
-			[$this->queryBuilder, 'andWhere'],
766
-			$where
767
-		);
768
-
769
-		return $this;
770
-	}
771
-
772
-	/**
773
-	 * Adds one or more restrictions to the query results, forming a logical
774
-	 * disjunction with any previously specified restrictions.
775
-	 *
776
-	 * <code>
777
-	 *     $qb = $conn->getQueryBuilder()
778
-	 *         ->select('u.name')
779
-	 *         ->from('users', 'u')
780
-	 *         ->where('u.id = 1')
781
-	 *         ->orWhere('u.id = 2');
782
-	 * </code>
783
-	 *
784
-	 * @param mixed ...$where The WHERE statement.
785
-	 *
786
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
787
-	 *
788
-	 * @see where()
789
-	 */
790
-	public function orWhere(...$where) {
791
-		call_user_func_array(
792
-			[$this->queryBuilder, 'orWhere'],
793
-			$where
794
-		);
795
-
796
-		return $this;
797
-	}
798
-
799
-	/**
800
-	 * Specifies a grouping over the results of the query.
801
-	 * Replaces any previously specified groupings, if any.
802
-	 *
803
-	 * <code>
804
-	 *     $qb = $conn->getQueryBuilder()
805
-	 *         ->select('u.name')
806
-	 *         ->from('users', 'u')
807
-	 *         ->groupBy('u.id');
808
-	 * </code>
809
-	 *
810
-	 * @param mixed ...$groupBys The grouping expression.
811
-	 *
812
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
813
-	 */
814
-	public function groupBy(...$groupBys) {
815
-		if (count($groupBys) === 1 && is_array($groupBys[0])) {
816
-			$groupBys = $groupBys[0];
817
-		}
818
-
819
-		call_user_func_array(
820
-			[$this->queryBuilder, 'groupBy'],
821
-			$this->helper->quoteColumnNames($groupBys)
822
-		);
823
-
824
-		return $this;
825
-	}
826
-
827
-	/**
828
-	 * Adds a grouping expression to the query.
829
-	 *
830
-	 * <code>
831
-	 *     $qb = $conn->getQueryBuilder()
832
-	 *         ->select('u.name')
833
-	 *         ->from('users', 'u')
834
-	 *         ->groupBy('u.lastLogin');
835
-	 *         ->addGroupBy('u.createdAt')
836
-	 * </code>
837
-	 *
838
-	 * @param mixed ...$groupBy The grouping expression.
839
-	 *
840
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
841
-	 */
842
-	public function addGroupBy(...$groupBys) {
843
-		if (count($groupBys) === 1 && is_array($groupBys[0])) {
844
-			$$groupBys = $groupBys[0];
845
-		}
846
-
847
-		call_user_func_array(
848
-			[$this->queryBuilder, 'addGroupBy'],
849
-			$this->helper->quoteColumnNames($groupBys)
850
-		);
851
-
852
-		return $this;
853
-	}
854
-
855
-	/**
856
-	 * Sets a value for a column in an insert query.
857
-	 *
858
-	 * <code>
859
-	 *     $qb = $conn->getQueryBuilder()
860
-	 *         ->insert('users')
861
-	 *         ->values(
862
-	 *             array(
863
-	 *                 'name' => '?'
864
-	 *             )
865
-	 *         )
866
-	 *         ->setValue('password', '?');
867
-	 * </code>
868
-	 *
869
-	 * @param string $column The column into which the value should be inserted.
870
-	 * @param string $value The value that should be inserted into the column.
871
-	 *
872
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
873
-	 */
874
-	public function setValue($column, $value) {
875
-		$this->queryBuilder->setValue(
876
-			$this->helper->quoteColumnName($column),
877
-			$value
878
-		);
879
-
880
-		return $this;
881
-	}
882
-
883
-	/**
884
-	 * Specifies values for an insert query indexed by column names.
885
-	 * Replaces any previous values, if any.
886
-	 *
887
-	 * <code>
888
-	 *     $qb = $conn->getQueryBuilder()
889
-	 *         ->insert('users')
890
-	 *         ->values(
891
-	 *             array(
892
-	 *                 'name' => '?',
893
-	 *                 'password' => '?'
894
-	 *             )
895
-	 *         );
896
-	 * </code>
897
-	 *
898
-	 * @param array $values The values to specify for the insert query indexed by column names.
899
-	 *
900
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
901
-	 */
902
-	public function values(array $values) {
903
-		$quotedValues = [];
904
-		foreach ($values as $key => $value) {
905
-			$quotedValues[$this->helper->quoteColumnName($key)] = $value;
906
-		}
907
-
908
-		$this->queryBuilder->values($quotedValues);
909
-
910
-		return $this;
911
-	}
912
-
913
-	/**
914
-	 * Specifies a restriction over the groups of the query.
915
-	 * Replaces any previous having restrictions, if any.
916
-	 *
917
-	 * @param mixed ...$having The restriction over the groups.
918
-	 *
919
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
920
-	 */
921
-	public function having(...$having) {
922
-		call_user_func_array(
923
-			[$this->queryBuilder, 'having'],
924
-			$having
925
-		);
926
-
927
-		return $this;
928
-	}
929
-
930
-	/**
931
-	 * Adds a restriction over the groups of the query, forming a logical
932
-	 * conjunction with any existing having restrictions.
933
-	 *
934
-	 * @param mixed ...$having The restriction to append.
935
-	 *
936
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
937
-	 */
938
-	public function andHaving(...$having) {
939
-		call_user_func_array(
940
-			[$this->queryBuilder, 'andHaving'],
941
-			$having
942
-		);
943
-
944
-		return $this;
945
-	}
946
-
947
-	/**
948
-	 * Adds a restriction over the groups of the query, forming a logical
949
-	 * disjunction with any existing having restrictions.
950
-	 *
951
-	 * @param mixed ...$having The restriction to add.
952
-	 *
953
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
954
-	 */
955
-	public function orHaving(...$having) {
956
-		call_user_func_array(
957
-			[$this->queryBuilder, 'orHaving'],
958
-			$having
959
-		);
960
-
961
-		return $this;
962
-	}
963
-
964
-	/**
965
-	 * Specifies an ordering for the query results.
966
-	 * Replaces any previously specified orderings, if any.
967
-	 *
968
-	 * @param string $sort The ordering expression.
969
-	 * @param string $order The ordering direction.
970
-	 *
971
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
972
-	 */
973
-	public function orderBy($sort, $order = null) {
974
-		$this->queryBuilder->orderBy(
975
-			$this->helper->quoteColumnName($sort),
976
-			$order
977
-		);
978
-
979
-		return $this;
980
-	}
981
-
982
-	/**
983
-	 * Adds an ordering to the query results.
984
-	 *
985
-	 * @param string $sort The ordering expression.
986
-	 * @param string $order The ordering direction.
987
-	 *
988
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
989
-	 */
990
-	public function addOrderBy($sort, $order = null) {
991
-		$this->queryBuilder->addOrderBy(
992
-			$this->helper->quoteColumnName($sort),
993
-			$order
994
-		);
995
-
996
-		return $this;
997
-	}
998
-
999
-	/**
1000
-	 * Gets a query part by its name.
1001
-	 *
1002
-	 * @param string $queryPartName
1003
-	 *
1004
-	 * @return mixed
1005
-	 */
1006
-	public function getQueryPart($queryPartName) {
1007
-		return $this->queryBuilder->getQueryPart($queryPartName);
1008
-	}
1009
-
1010
-	/**
1011
-	 * Gets all query parts.
1012
-	 *
1013
-	 * @return array
1014
-	 */
1015
-	public function getQueryParts() {
1016
-		return $this->queryBuilder->getQueryParts();
1017
-	}
1018
-
1019
-	/**
1020
-	 * Resets SQL parts.
1021
-	 *
1022
-	 * @param array|null $queryPartNames
1023
-	 *
1024
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1025
-	 */
1026
-	public function resetQueryParts($queryPartNames = null) {
1027
-		$this->queryBuilder->resetQueryParts($queryPartNames);
1028
-
1029
-		return $this;
1030
-	}
1031
-
1032
-	/**
1033
-	 * Resets a single SQL part.
1034
-	 *
1035
-	 * @param string $queryPartName
1036
-	 *
1037
-	 * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1038
-	 */
1039
-	public function resetQueryPart($queryPartName) {
1040
-		$this->queryBuilder->resetQueryPart($queryPartName);
1041
-
1042
-		return $this;
1043
-	}
1044
-
1045
-	/**
1046
-	 * Creates a new named parameter and bind the value $value to it.
1047
-	 *
1048
-	 * This method provides a shortcut for PDOStatement::bindValue
1049
-	 * when using prepared statements.
1050
-	 *
1051
-	 * The parameter $value specifies the value that you want to bind. If
1052
-	 * $placeholder is not provided bindValue() will automatically create a
1053
-	 * placeholder for you. An automatic placeholder will be of the name
1054
-	 * ':dcValue1', ':dcValue2' etc.
1055
-	 *
1056
-	 * For more information see {@link http://php.net/pdostatement-bindparam}
1057
-	 *
1058
-	 * Example:
1059
-	 * <code>
1060
-	 * $value = 2;
1061
-	 * $q->eq( 'id', $q->bindValue( $value ) );
1062
-	 * $stmt = $q->executeQuery(); // executed with 'id = 2'
1063
-	 * </code>
1064
-	 *
1065
-	 * @license New BSD License
1066
-	 * @link http://www.zetacomponents.org
1067
-	 *
1068
-	 * @param mixed $value
1069
-	 * @param mixed $type
1070
-	 * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
1071
-	 *
1072
-	 * @return IParameter the placeholder name used.
1073
-	 */
1074
-	public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) {
1075
-		return new Parameter($this->queryBuilder->createNamedParameter($value, $type, $placeHolder));
1076
-	}
1077
-
1078
-	/**
1079
-	 * Creates a new positional parameter and bind the given value to it.
1080
-	 *
1081
-	 * Attention: If you are using positional parameters with the query builder you have
1082
-	 * to be very careful to bind all parameters in the order they appear in the SQL
1083
-	 * statement , otherwise they get bound in the wrong order which can lead to serious
1084
-	 * bugs in your code.
1085
-	 *
1086
-	 * Example:
1087
-	 * <code>
1088
-	 *  $qb = $conn->getQueryBuilder();
1089
-	 *  $qb->select('u.*')
1090
-	 *     ->from('users', 'u')
1091
-	 *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
1092
-	 *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
1093
-	 * </code>
1094
-	 *
1095
-	 * @param mixed $value
1096
-	 * @param integer $type
1097
-	 *
1098
-	 * @return IParameter
1099
-	 */
1100
-	public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) {
1101
-		return new Parameter($this->queryBuilder->createPositionalParameter($value, $type));
1102
-	}
1103
-
1104
-	/**
1105
-	 * Creates a new parameter
1106
-	 *
1107
-	 * Example:
1108
-	 * <code>
1109
-	 *  $qb = $conn->getQueryBuilder();
1110
-	 *  $qb->select('u.*')
1111
-	 *     ->from('users', 'u')
1112
-	 *     ->where('u.username = ' . $qb->createParameter('name'))
1113
-	 *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
1114
-	 * </code>
1115
-	 *
1116
-	 * @param string $name
1117
-	 *
1118
-	 * @return IParameter
1119
-	 */
1120
-	public function createParameter($name) {
1121
-		return new Parameter(':' . $name);
1122
-	}
1123
-
1124
-	/**
1125
-	 * Creates a new function
1126
-	 *
1127
-	 * Attention: Column names inside the call have to be quoted before hand
1128
-	 *
1129
-	 * Example:
1130
-	 * <code>
1131
-	 *  $qb = $conn->getQueryBuilder();
1132
-	 *  $qb->select($qb->createFunction('COUNT(*)'))
1133
-	 *     ->from('users', 'u')
1134
-	 *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
1135
-	 * </code>
1136
-	 * <code>
1137
-	 *  $qb = $conn->getQueryBuilder();
1138
-	 *  $qb->select($qb->createFunction('COUNT(`column`)'))
1139
-	 *     ->from('users', 'u')
1140
-	 *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
1141
-	 * </code>
1142
-	 *
1143
-	 * @param string $call
1144
-	 *
1145
-	 * @return IQueryFunction
1146
-	 */
1147
-	public function createFunction($call) {
1148
-		return new QueryFunction($call);
1149
-	}
1150
-
1151
-	/**
1152
-	 * Used to get the id of the last inserted element
1153
-	 * @return int
1154
-	 * @throws \BadMethodCallException When being called before an insert query has been run.
1155
-	 */
1156
-	public function getLastInsertId() {
1157
-		if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && $this->lastInsertedTable) {
1158
-			// lastInsertId() needs the prefix but no quotes
1159
-			$table = $this->prefixTableName($this->lastInsertedTable);
1160
-			return (int) $this->connection->lastInsertId($table);
1161
-		}
1162
-
1163
-		throw new \BadMethodCallException('Invalid call to getLastInsertId without using insert() before.');
1164
-	}
1165
-
1166
-	/**
1167
-	 * Returns the table name quoted and with database prefix as needed by the implementation
1168
-	 *
1169
-	 * @param string $table
1170
-	 * @return string
1171
-	 */
1172
-	public function getTableName($table) {
1173
-		if ($table instanceof IQueryFunction) {
1174
-			return (string) $table;
1175
-		}
1176
-
1177
-		$table = $this->prefixTableName($table);
1178
-		return $this->helper->quoteColumnName($table);
1179
-	}
1180
-
1181
-	/**
1182
-	 * Returns the table name with database prefix as needed by the implementation
1183
-	 *
1184
-	 * @param string $table
1185
-	 * @return string
1186
-	 */
1187
-	protected function prefixTableName($table) {
1188
-		if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
1189
-			return $table;
1190
-		}
1191
-
1192
-		return '*PREFIX*' . $table;
1193
-	}
1194
-
1195
-	/**
1196
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
1197
-	 *
1198
-	 * @param string $column
1199
-	 * @param string $tableAlias
1200
-	 * @return string
1201
-	 */
1202
-	public function getColumnName($column, $tableAlias = '') {
1203
-		if ($tableAlias !== '') {
1204
-			$tableAlias .= '.';
1205
-		}
1206
-
1207
-		return $this->helper->quoteColumnName($tableAlias . $column);
1208
-	}
1209
-
1210
-	/**
1211
-	 * Returns the column name quoted and with table alias prefix as needed by the implementation
1212
-	 *
1213
-	 * @param string $alias
1214
-	 * @return string
1215
-	 */
1216
-	public function quoteAlias($alias) {
1217
-		if ($alias === '' || $alias === null) {
1218
-			return $alias;
1219
-		}
1220
-
1221
-		return $this->helper->quoteColumnName($alias);
1222
-	}
50
+    /** @var \OCP\IDBConnection */
51
+    private $connection;
52
+
53
+    /** @var SystemConfig */
54
+    private $systemConfig;
55
+
56
+    /** @var ILogger */
57
+    private $logger;
58
+
59
+    /** @var \Doctrine\DBAL\Query\QueryBuilder */
60
+    private $queryBuilder;
61
+
62
+    /** @var QuoteHelper */
63
+    private $helper;
64
+
65
+    /** @var bool */
66
+    private $automaticTablePrefix = true;
67
+
68
+    /** @var string */
69
+    protected $lastInsertedTable;
70
+
71
+    /**
72
+     * Initializes a new QueryBuilder.
73
+     *
74
+     * @param IDBConnection $connection
75
+     * @param SystemConfig $systemConfig
76
+     * @param ILogger $logger
77
+     */
78
+    public function __construct(IDBConnection $connection, SystemConfig $systemConfig, ILogger $logger) {
79
+        $this->connection = $connection;
80
+        $this->systemConfig = $systemConfig;
81
+        $this->logger = $logger;
82
+        $this->queryBuilder = new \Doctrine\DBAL\Query\QueryBuilder($this->connection);
83
+        $this->helper = new QuoteHelper();
84
+    }
85
+
86
+    /**
87
+     * Enable/disable automatic prefixing of table names with the oc_ prefix
88
+     *
89
+     * @param bool $enabled If set to true table names will be prefixed with the
90
+     * owncloud database prefix automatically.
91
+     * @since 8.2.0
92
+     */
93
+    public function automaticTablePrefix($enabled) {
94
+        $this->automaticTablePrefix = (bool) $enabled;
95
+    }
96
+
97
+    /**
98
+     * Gets an ExpressionBuilder used for object-oriented construction of query expressions.
99
+     * This producer method is intended for convenient inline usage. Example:
100
+     *
101
+     * <code>
102
+     *     $qb = $conn->getQueryBuilder()
103
+     *         ->select('u')
104
+     *         ->from('users', 'u')
105
+     *         ->where($qb->expr()->eq('u.id', 1));
106
+     * </code>
107
+     *
108
+     * For more complex expression construction, consider storing the expression
109
+     * builder object in a local variable.
110
+     *
111
+     * @return \OCP\DB\QueryBuilder\IExpressionBuilder
112
+     */
113
+    public function expr() {
114
+        if ($this->connection instanceof OracleConnection) {
115
+            return new OCIExpressionBuilder($this->connection, $this);
116
+        } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
117
+            return new PgSqlExpressionBuilder($this->connection, $this);
118
+        } else if ($this->connection->getDatabasePlatform() instanceof MySqlPlatform) {
119
+            return new MySqlExpressionBuilder($this->connection, $this);
120
+        } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
121
+            return new SqliteExpressionBuilder($this->connection, $this);
122
+        } else {
123
+            return new ExpressionBuilder($this->connection, $this);
124
+        }
125
+    }
126
+
127
+    /**
128
+     * Gets an FunctionBuilder used for object-oriented construction of query functions.
129
+     * This producer method is intended for convenient inline usage. Example:
130
+     *
131
+     * <code>
132
+     *     $qb = $conn->getQueryBuilder()
133
+     *         ->select('u')
134
+     *         ->from('users', 'u')
135
+     *         ->where($qb->fun()->md5('u.id'));
136
+     * </code>
137
+     *
138
+     * For more complex function construction, consider storing the function
139
+     * builder object in a local variable.
140
+     *
141
+     * @return \OCP\DB\QueryBuilder\IFunctionBuilder
142
+     */
143
+    public function func() {
144
+        if ($this->connection instanceof OracleConnection) {
145
+            return new OCIFunctionBuilder($this->helper);
146
+        } else if ($this->connection->getDatabasePlatform() instanceof SqlitePlatform) {
147
+            return new SqliteFunctionBuilder($this->helper);
148
+        } else if ($this->connection->getDatabasePlatform() instanceof PostgreSqlPlatform) {
149
+            return new PgSqlFunctionBuilder($this->helper);
150
+        } else {
151
+            return new FunctionBuilder($this->helper);
152
+        }
153
+    }
154
+
155
+    /**
156
+     * Gets the type of the currently built query.
157
+     *
158
+     * @return integer
159
+     */
160
+    public function getType() {
161
+        return $this->queryBuilder->getType();
162
+    }
163
+
164
+    /**
165
+     * Gets the associated DBAL Connection for this query builder.
166
+     *
167
+     * @return \OCP\IDBConnection
168
+     */
169
+    public function getConnection() {
170
+        return $this->connection;
171
+    }
172
+
173
+    /**
174
+     * Gets the state of this query builder instance.
175
+     *
176
+     * @return integer Either QueryBuilder::STATE_DIRTY or QueryBuilder::STATE_CLEAN.
177
+     */
178
+    public function getState() {
179
+        return $this->queryBuilder->getState();
180
+    }
181
+
182
+    /**
183
+     * Executes this query using the bound parameters and their types.
184
+     *
185
+     * Uses {@see Connection::executeQuery} for select statements and {@see Connection::executeUpdate}
186
+     * for insert, update and delete statements.
187
+     *
188
+     * @return \Doctrine\DBAL\Driver\Statement|int
189
+     */
190
+    public function execute() {
191
+        if ($this->systemConfig->getValue('log_query', false)) {
192
+            $params = [];
193
+            foreach ($this->getParameters() as $placeholder => $value) {
194
+                if (is_array($value)) {
195
+                    $params[] = $placeholder . ' => (\'' . implode('\', \'', $value) . '\')';
196
+                } else {
197
+                    $params[] = $placeholder . ' => \'' . $value . '\'';
198
+                }
199
+            }
200
+            if (empty($params)) {
201
+                $this->logger->debug('DB QueryBuilder: \'{query}\'', [
202
+                    'query' => $this->getSQL(),
203
+                    'app' => 'core',
204
+                ]);
205
+            } else {
206
+                $this->logger->debug('DB QueryBuilder: \'{query}\' with parameters: {params}', [
207
+                    'query' => $this->getSQL(),
208
+                    'params' => implode(', ', $params),
209
+                    'app' => 'core',
210
+                ]);
211
+            }
212
+        }
213
+
214
+        return $this->queryBuilder->execute();
215
+    }
216
+
217
+    /**
218
+     * Gets the complete SQL string formed by the current specifications of this QueryBuilder.
219
+     *
220
+     * <code>
221
+     *     $qb = $conn->getQueryBuilder()
222
+     *         ->select('u')
223
+     *         ->from('User', 'u')
224
+     *     echo $qb->getSQL(); // SELECT u FROM User u
225
+     * </code>
226
+     *
227
+     * @return string The SQL query string.
228
+     */
229
+    public function getSQL() {
230
+        return $this->queryBuilder->getSQL();
231
+    }
232
+
233
+    /**
234
+     * Sets a query parameter for the query being constructed.
235
+     *
236
+     * <code>
237
+     *     $qb = $conn->getQueryBuilder()
238
+     *         ->select('u')
239
+     *         ->from('users', 'u')
240
+     *         ->where('u.id = :user_id')
241
+     *         ->setParameter(':user_id', 1);
242
+     * </code>
243
+     *
244
+     * @param string|integer $key The parameter position or name.
245
+     * @param mixed $value The parameter value.
246
+     * @param string|null|int $type One of the IQueryBuilder::PARAM_* constants.
247
+     *
248
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
249
+     */
250
+    public function setParameter($key, $value, $type = null) {
251
+        $this->queryBuilder->setParameter($key, $value, $type);
252
+
253
+        return $this;
254
+    }
255
+
256
+    /**
257
+     * Sets a collection of query parameters for the query being constructed.
258
+     *
259
+     * <code>
260
+     *     $qb = $conn->getQueryBuilder()
261
+     *         ->select('u')
262
+     *         ->from('users', 'u')
263
+     *         ->where('u.id = :user_id1 OR u.id = :user_id2')
264
+     *         ->setParameters(array(
265
+     *             ':user_id1' => 1,
266
+     *             ':user_id2' => 2
267
+     *         ));
268
+     * </code>
269
+     *
270
+     * @param array $params The query parameters to set.
271
+     * @param array $types The query parameters types to set.
272
+     *
273
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
274
+     */
275
+    public function setParameters(array $params, array $types = array()) {
276
+        $this->queryBuilder->setParameters($params, $types);
277
+
278
+        return $this;
279
+    }
280
+
281
+    /**
282
+     * Gets all defined query parameters for the query being constructed indexed by parameter index or name.
283
+     *
284
+     * @return array The currently defined query parameters indexed by parameter index or name.
285
+     */
286
+    public function getParameters() {
287
+        return $this->queryBuilder->getParameters();
288
+    }
289
+
290
+    /**
291
+     * Gets a (previously set) query parameter of the query being constructed.
292
+     *
293
+     * @param mixed $key The key (index or name) of the bound parameter.
294
+     *
295
+     * @return mixed The value of the bound parameter.
296
+     */
297
+    public function getParameter($key) {
298
+        return $this->queryBuilder->getParameter($key);
299
+    }
300
+
301
+    /**
302
+     * Gets all defined query parameter types for the query being constructed indexed by parameter index or name.
303
+     *
304
+     * @return array The currently defined query parameter types indexed by parameter index or name.
305
+     */
306
+    public function getParameterTypes() {
307
+        return $this->queryBuilder->getParameterTypes();
308
+    }
309
+
310
+    /**
311
+     * Gets a (previously set) query parameter type of the query being constructed.
312
+     *
313
+     * @param mixed $key The key (index or name) of the bound parameter type.
314
+     *
315
+     * @return mixed The value of the bound parameter type.
316
+     */
317
+    public function getParameterType($key) {
318
+        return $this->queryBuilder->getParameterType($key);
319
+    }
320
+
321
+    /**
322
+     * Sets the position of the first result to retrieve (the "offset").
323
+     *
324
+     * @param integer $firstResult The first result to return.
325
+     *
326
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
327
+     */
328
+    public function setFirstResult($firstResult) {
329
+        $this->queryBuilder->setFirstResult($firstResult);
330
+
331
+        return $this;
332
+    }
333
+
334
+    /**
335
+     * Gets the position of the first result the query object was set to retrieve (the "offset").
336
+     * Returns NULL if {@link setFirstResult} was not applied to this QueryBuilder.
337
+     *
338
+     * @return integer The position of the first result.
339
+     */
340
+    public function getFirstResult() {
341
+        return $this->queryBuilder->getFirstResult();
342
+    }
343
+
344
+    /**
345
+     * Sets the maximum number of results to retrieve (the "limit").
346
+     *
347
+     * NOTE: Setting max results to "0" will cause mixed behaviour. While most
348
+     * of the databases will just return an empty result set, Oracle will return
349
+     * all entries.
350
+     *
351
+     * @param integer $maxResults The maximum number of results to retrieve.
352
+     *
353
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
354
+     */
355
+    public function setMaxResults($maxResults) {
356
+        $this->queryBuilder->setMaxResults($maxResults);
357
+
358
+        return $this;
359
+    }
360
+
361
+    /**
362
+     * Gets the maximum number of results the query object was set to retrieve (the "limit").
363
+     * Returns NULL if {@link setMaxResults} was not applied to this query builder.
364
+     *
365
+     * @return integer The maximum number of results.
366
+     */
367
+    public function getMaxResults() {
368
+        return $this->queryBuilder->getMaxResults();
369
+    }
370
+
371
+    /**
372
+     * Specifies an item that is to be returned in the query result.
373
+     * Replaces any previously specified selections, if any.
374
+     *
375
+     * <code>
376
+     *     $qb = $conn->getQueryBuilder()
377
+     *         ->select('u.id', 'p.id')
378
+     *         ->from('users', 'u')
379
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
380
+     * </code>
381
+     *
382
+     * @param mixed ...$selects The selection expressions.
383
+     *
384
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
385
+     */
386
+    public function select(...$selects) {
387
+        if (count($selects) === 1 && is_array($selects[0])) {
388
+            $selects = $selects[0];
389
+        }
390
+
391
+        $this->queryBuilder->select(
392
+            $this->helper->quoteColumnNames($selects)
393
+        );
394
+
395
+        return $this;
396
+    }
397
+
398
+    /**
399
+     * Specifies an item that is to be returned with a different name in the query result.
400
+     *
401
+     * <code>
402
+     *     $qb = $conn->getQueryBuilder()
403
+     *         ->selectAlias('u.id', 'user_id')
404
+     *         ->from('users', 'u')
405
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'u.id = p.user_id');
406
+     * </code>
407
+     *
408
+     * @param mixed $select The selection expressions.
409
+     * @param string $alias The column alias used in the constructed query.
410
+     *
411
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
412
+     */
413
+    public function selectAlias($select, $alias) {
414
+
415
+        $this->queryBuilder->addSelect(
416
+            $this->helper->quoteColumnName($select) . ' AS ' . $this->helper->quoteColumnName($alias)
417
+        );
418
+
419
+        return $this;
420
+    }
421
+
422
+    /**
423
+     * Specifies an item that is to be returned uniquely in the query result.
424
+     *
425
+     * <code>
426
+     *     $qb = $conn->getQueryBuilder()
427
+     *         ->selectDistinct('type')
428
+     *         ->from('users');
429
+     * </code>
430
+     *
431
+     * @param mixed $select The selection expressions.
432
+     *
433
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
434
+     */
435
+    public function selectDistinct($select) {
436
+
437
+        $this->queryBuilder->addSelect(
438
+            'DISTINCT ' . $this->helper->quoteColumnName($select)
439
+        );
440
+
441
+        return $this;
442
+    }
443
+
444
+    /**
445
+     * Adds an item that is to be returned in the query result.
446
+     *
447
+     * <code>
448
+     *     $qb = $conn->getQueryBuilder()
449
+     *         ->select('u.id')
450
+     *         ->addSelect('p.id')
451
+     *         ->from('users', 'u')
452
+     *         ->leftJoin('u', 'phonenumbers', 'u.id = p.user_id');
453
+     * </code>
454
+     *
455
+     * @param mixed ...$selects The selection expression.
456
+     *
457
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
458
+     */
459
+    public function addSelect(...$selects) {
460
+        if (count($selects) === 1 && is_array($selects[0])) {
461
+            $selects = $selects[0];
462
+        }
463
+
464
+        $this->queryBuilder->addSelect(
465
+            $this->helper->quoteColumnNames($selects)
466
+        );
467
+
468
+        return $this;
469
+    }
470
+
471
+    /**
472
+     * Turns the query being built into a bulk delete query that ranges over
473
+     * a certain table.
474
+     *
475
+     * <code>
476
+     *     $qb = $conn->getQueryBuilder()
477
+     *         ->delete('users', 'u')
478
+     *         ->where('u.id = :user_id');
479
+     *         ->setParameter(':user_id', 1);
480
+     * </code>
481
+     *
482
+     * @param string $delete The table whose rows are subject to the deletion.
483
+     * @param string $alias The table alias used in the constructed query.
484
+     *
485
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
486
+     */
487
+    public function delete($delete = null, $alias = null) {
488
+        $this->queryBuilder->delete(
489
+            $this->getTableName($delete),
490
+            $alias
491
+        );
492
+
493
+        return $this;
494
+    }
495
+
496
+    /**
497
+     * Turns the query being built into a bulk update query that ranges over
498
+     * a certain table
499
+     *
500
+     * <code>
501
+     *     $qb = $conn->getQueryBuilder()
502
+     *         ->update('users', 'u')
503
+     *         ->set('u.password', md5('password'))
504
+     *         ->where('u.id = ?');
505
+     * </code>
506
+     *
507
+     * @param string $update The table whose rows are subject to the update.
508
+     * @param string $alias The table alias used in the constructed query.
509
+     *
510
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
511
+     */
512
+    public function update($update = null, $alias = null) {
513
+        $this->queryBuilder->update(
514
+            $this->getTableName($update),
515
+            $alias
516
+        );
517
+
518
+        return $this;
519
+    }
520
+
521
+    /**
522
+     * Turns the query being built into an insert query that inserts into
523
+     * a certain table
524
+     *
525
+     * <code>
526
+     *     $qb = $conn->getQueryBuilder()
527
+     *         ->insert('users')
528
+     *         ->values(
529
+     *             array(
530
+     *                 'name' => '?',
531
+     *                 'password' => '?'
532
+     *             )
533
+     *         );
534
+     * </code>
535
+     *
536
+     * @param string $insert The table into which the rows should be inserted.
537
+     *
538
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
539
+     */
540
+    public function insert($insert = null) {
541
+        $this->queryBuilder->insert(
542
+            $this->getTableName($insert)
543
+        );
544
+
545
+        $this->lastInsertedTable = $insert;
546
+
547
+        return $this;
548
+    }
549
+
550
+    /**
551
+     * Creates and adds a query root corresponding to the table identified by the
552
+     * given alias, forming a cartesian product with any existing query roots.
553
+     *
554
+     * <code>
555
+     *     $qb = $conn->getQueryBuilder()
556
+     *         ->select('u.id')
557
+     *         ->from('users', 'u')
558
+     * </code>
559
+     *
560
+     * @param string $from The table.
561
+     * @param string|null $alias The alias of the table.
562
+     *
563
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
564
+     */
565
+    public function from($from, $alias = null) {
566
+        $this->queryBuilder->from(
567
+            $this->getTableName($from),
568
+            $this->quoteAlias($alias)
569
+        );
570
+
571
+        return $this;
572
+    }
573
+
574
+    /**
575
+     * Creates and adds a join to the query.
576
+     *
577
+     * <code>
578
+     *     $qb = $conn->getQueryBuilder()
579
+     *         ->select('u.name')
580
+     *         ->from('users', 'u')
581
+     *         ->join('u', 'phonenumbers', 'p', 'p.is_primary = 1');
582
+     * </code>
583
+     *
584
+     * @param string $fromAlias The alias that points to a from clause.
585
+     * @param string $join The table name to join.
586
+     * @param string $alias The alias of the join table.
587
+     * @param string $condition The condition for the join.
588
+     *
589
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
590
+     */
591
+    public function join($fromAlias, $join, $alias, $condition = null) {
592
+        $this->queryBuilder->join(
593
+            $this->quoteAlias($fromAlias),
594
+            $this->getTableName($join),
595
+            $this->quoteAlias($alias),
596
+            $condition
597
+        );
598
+
599
+        return $this;
600
+    }
601
+
602
+    /**
603
+     * Creates and adds a join to the query.
604
+     *
605
+     * <code>
606
+     *     $qb = $conn->getQueryBuilder()
607
+     *         ->select('u.name')
608
+     *         ->from('users', 'u')
609
+     *         ->innerJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
610
+     * </code>
611
+     *
612
+     * @param string $fromAlias The alias that points to a from clause.
613
+     * @param string $join The table name to join.
614
+     * @param string $alias The alias of the join table.
615
+     * @param string $condition The condition for the join.
616
+     *
617
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
618
+     */
619
+    public function innerJoin($fromAlias, $join, $alias, $condition = null) {
620
+        $this->queryBuilder->innerJoin(
621
+            $this->quoteAlias($fromAlias),
622
+            $this->getTableName($join),
623
+            $this->quoteAlias($alias),
624
+            $condition
625
+        );
626
+
627
+        return $this;
628
+    }
629
+
630
+    /**
631
+     * Creates and adds a left join to the query.
632
+     *
633
+     * <code>
634
+     *     $qb = $conn->getQueryBuilder()
635
+     *         ->select('u.name')
636
+     *         ->from('users', 'u')
637
+     *         ->leftJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
638
+     * </code>
639
+     *
640
+     * @param string $fromAlias The alias that points to a from clause.
641
+     * @param string $join The table name to join.
642
+     * @param string $alias The alias of the join table.
643
+     * @param string $condition The condition for the join.
644
+     *
645
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
646
+     */
647
+    public function leftJoin($fromAlias, $join, $alias, $condition = null) {
648
+        $this->queryBuilder->leftJoin(
649
+            $this->quoteAlias($fromAlias),
650
+            $this->getTableName($join),
651
+            $this->quoteAlias($alias),
652
+            $condition
653
+        );
654
+
655
+        return $this;
656
+    }
657
+
658
+    /**
659
+     * Creates and adds a right join to the query.
660
+     *
661
+     * <code>
662
+     *     $qb = $conn->getQueryBuilder()
663
+     *         ->select('u.name')
664
+     *         ->from('users', 'u')
665
+     *         ->rightJoin('u', 'phonenumbers', 'p', 'p.is_primary = 1');
666
+     * </code>
667
+     *
668
+     * @param string $fromAlias The alias that points to a from clause.
669
+     * @param string $join The table name to join.
670
+     * @param string $alias The alias of the join table.
671
+     * @param string $condition The condition for the join.
672
+     *
673
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
674
+     */
675
+    public function rightJoin($fromAlias, $join, $alias, $condition = null) {
676
+        $this->queryBuilder->rightJoin(
677
+            $this->quoteAlias($fromAlias),
678
+            $this->getTableName($join),
679
+            $this->quoteAlias($alias),
680
+            $condition
681
+        );
682
+
683
+        return $this;
684
+    }
685
+
686
+    /**
687
+     * Sets a new value for a column in a bulk update query.
688
+     *
689
+     * <code>
690
+     *     $qb = $conn->getQueryBuilder()
691
+     *         ->update('users', 'u')
692
+     *         ->set('u.password', md5('password'))
693
+     *         ->where('u.id = ?');
694
+     * </code>
695
+     *
696
+     * @param string $key The column to set.
697
+     * @param string $value The value, expression, placeholder, etc.
698
+     *
699
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
700
+     */
701
+    public function set($key, $value) {
702
+        $this->queryBuilder->set(
703
+            $this->helper->quoteColumnName($key),
704
+            $this->helper->quoteColumnName($value)
705
+        );
706
+
707
+        return $this;
708
+    }
709
+
710
+    /**
711
+     * Specifies one or more restrictions to the query result.
712
+     * Replaces any previously specified restrictions, if any.
713
+     *
714
+     * <code>
715
+     *     $qb = $conn->getQueryBuilder()
716
+     *         ->select('u.name')
717
+     *         ->from('users', 'u')
718
+     *         ->where('u.id = ?');
719
+     *
720
+     *     // You can optionally programatically build and/or expressions
721
+     *     $qb = $conn->getQueryBuilder();
722
+     *
723
+     *     $or = $qb->expr()->orx();
724
+     *     $or->add($qb->expr()->eq('u.id', 1));
725
+     *     $or->add($qb->expr()->eq('u.id', 2));
726
+     *
727
+     *     $qb->update('users', 'u')
728
+     *         ->set('u.password', md5('password'))
729
+     *         ->where($or);
730
+     * </code>
731
+     *
732
+     * @param mixed ...$predicates The restriction predicates.
733
+     *
734
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
735
+     */
736
+    public function where(...$predicates) {
737
+        call_user_func_array(
738
+            [$this->queryBuilder, 'where'],
739
+            $predicates
740
+        );
741
+
742
+        return $this;
743
+    }
744
+
745
+    /**
746
+     * Adds one or more restrictions to the query results, forming a logical
747
+     * conjunction with any previously specified restrictions.
748
+     *
749
+     * <code>
750
+     *     $qb = $conn->getQueryBuilder()
751
+     *         ->select('u')
752
+     *         ->from('users', 'u')
753
+     *         ->where('u.username LIKE ?')
754
+     *         ->andWhere('u.is_active = 1');
755
+     * </code>
756
+     *
757
+     * @param mixed ...$where The query restrictions.
758
+     *
759
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
760
+     *
761
+     * @see where()
762
+     */
763
+    public function andWhere(...$where) {
764
+        call_user_func_array(
765
+            [$this->queryBuilder, 'andWhere'],
766
+            $where
767
+        );
768
+
769
+        return $this;
770
+    }
771
+
772
+    /**
773
+     * Adds one or more restrictions to the query results, forming a logical
774
+     * disjunction with any previously specified restrictions.
775
+     *
776
+     * <code>
777
+     *     $qb = $conn->getQueryBuilder()
778
+     *         ->select('u.name')
779
+     *         ->from('users', 'u')
780
+     *         ->where('u.id = 1')
781
+     *         ->orWhere('u.id = 2');
782
+     * </code>
783
+     *
784
+     * @param mixed ...$where The WHERE statement.
785
+     *
786
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
787
+     *
788
+     * @see where()
789
+     */
790
+    public function orWhere(...$where) {
791
+        call_user_func_array(
792
+            [$this->queryBuilder, 'orWhere'],
793
+            $where
794
+        );
795
+
796
+        return $this;
797
+    }
798
+
799
+    /**
800
+     * Specifies a grouping over the results of the query.
801
+     * Replaces any previously specified groupings, if any.
802
+     *
803
+     * <code>
804
+     *     $qb = $conn->getQueryBuilder()
805
+     *         ->select('u.name')
806
+     *         ->from('users', 'u')
807
+     *         ->groupBy('u.id');
808
+     * </code>
809
+     *
810
+     * @param mixed ...$groupBys The grouping expression.
811
+     *
812
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
813
+     */
814
+    public function groupBy(...$groupBys) {
815
+        if (count($groupBys) === 1 && is_array($groupBys[0])) {
816
+            $groupBys = $groupBys[0];
817
+        }
818
+
819
+        call_user_func_array(
820
+            [$this->queryBuilder, 'groupBy'],
821
+            $this->helper->quoteColumnNames($groupBys)
822
+        );
823
+
824
+        return $this;
825
+    }
826
+
827
+    /**
828
+     * Adds a grouping expression to the query.
829
+     *
830
+     * <code>
831
+     *     $qb = $conn->getQueryBuilder()
832
+     *         ->select('u.name')
833
+     *         ->from('users', 'u')
834
+     *         ->groupBy('u.lastLogin');
835
+     *         ->addGroupBy('u.createdAt')
836
+     * </code>
837
+     *
838
+     * @param mixed ...$groupBy The grouping expression.
839
+     *
840
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
841
+     */
842
+    public function addGroupBy(...$groupBys) {
843
+        if (count($groupBys) === 1 && is_array($groupBys[0])) {
844
+            $$groupBys = $groupBys[0];
845
+        }
846
+
847
+        call_user_func_array(
848
+            [$this->queryBuilder, 'addGroupBy'],
849
+            $this->helper->quoteColumnNames($groupBys)
850
+        );
851
+
852
+        return $this;
853
+    }
854
+
855
+    /**
856
+     * Sets a value for a column in an insert query.
857
+     *
858
+     * <code>
859
+     *     $qb = $conn->getQueryBuilder()
860
+     *         ->insert('users')
861
+     *         ->values(
862
+     *             array(
863
+     *                 'name' => '?'
864
+     *             )
865
+     *         )
866
+     *         ->setValue('password', '?');
867
+     * </code>
868
+     *
869
+     * @param string $column The column into which the value should be inserted.
870
+     * @param string $value The value that should be inserted into the column.
871
+     *
872
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
873
+     */
874
+    public function setValue($column, $value) {
875
+        $this->queryBuilder->setValue(
876
+            $this->helper->quoteColumnName($column),
877
+            $value
878
+        );
879
+
880
+        return $this;
881
+    }
882
+
883
+    /**
884
+     * Specifies values for an insert query indexed by column names.
885
+     * Replaces any previous values, if any.
886
+     *
887
+     * <code>
888
+     *     $qb = $conn->getQueryBuilder()
889
+     *         ->insert('users')
890
+     *         ->values(
891
+     *             array(
892
+     *                 'name' => '?',
893
+     *                 'password' => '?'
894
+     *             )
895
+     *         );
896
+     * </code>
897
+     *
898
+     * @param array $values The values to specify for the insert query indexed by column names.
899
+     *
900
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
901
+     */
902
+    public function values(array $values) {
903
+        $quotedValues = [];
904
+        foreach ($values as $key => $value) {
905
+            $quotedValues[$this->helper->quoteColumnName($key)] = $value;
906
+        }
907
+
908
+        $this->queryBuilder->values($quotedValues);
909
+
910
+        return $this;
911
+    }
912
+
913
+    /**
914
+     * Specifies a restriction over the groups of the query.
915
+     * Replaces any previous having restrictions, if any.
916
+     *
917
+     * @param mixed ...$having The restriction over the groups.
918
+     *
919
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
920
+     */
921
+    public function having(...$having) {
922
+        call_user_func_array(
923
+            [$this->queryBuilder, 'having'],
924
+            $having
925
+        );
926
+
927
+        return $this;
928
+    }
929
+
930
+    /**
931
+     * Adds a restriction over the groups of the query, forming a logical
932
+     * conjunction with any existing having restrictions.
933
+     *
934
+     * @param mixed ...$having The restriction to append.
935
+     *
936
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
937
+     */
938
+    public function andHaving(...$having) {
939
+        call_user_func_array(
940
+            [$this->queryBuilder, 'andHaving'],
941
+            $having
942
+        );
943
+
944
+        return $this;
945
+    }
946
+
947
+    /**
948
+     * Adds a restriction over the groups of the query, forming a logical
949
+     * disjunction with any existing having restrictions.
950
+     *
951
+     * @param mixed ...$having The restriction to add.
952
+     *
953
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
954
+     */
955
+    public function orHaving(...$having) {
956
+        call_user_func_array(
957
+            [$this->queryBuilder, 'orHaving'],
958
+            $having
959
+        );
960
+
961
+        return $this;
962
+    }
963
+
964
+    /**
965
+     * Specifies an ordering for the query results.
966
+     * Replaces any previously specified orderings, if any.
967
+     *
968
+     * @param string $sort The ordering expression.
969
+     * @param string $order The ordering direction.
970
+     *
971
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
972
+     */
973
+    public function orderBy($sort, $order = null) {
974
+        $this->queryBuilder->orderBy(
975
+            $this->helper->quoteColumnName($sort),
976
+            $order
977
+        );
978
+
979
+        return $this;
980
+    }
981
+
982
+    /**
983
+     * Adds an ordering to the query results.
984
+     *
985
+     * @param string $sort The ordering expression.
986
+     * @param string $order The ordering direction.
987
+     *
988
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
989
+     */
990
+    public function addOrderBy($sort, $order = null) {
991
+        $this->queryBuilder->addOrderBy(
992
+            $this->helper->quoteColumnName($sort),
993
+            $order
994
+        );
995
+
996
+        return $this;
997
+    }
998
+
999
+    /**
1000
+     * Gets a query part by its name.
1001
+     *
1002
+     * @param string $queryPartName
1003
+     *
1004
+     * @return mixed
1005
+     */
1006
+    public function getQueryPart($queryPartName) {
1007
+        return $this->queryBuilder->getQueryPart($queryPartName);
1008
+    }
1009
+
1010
+    /**
1011
+     * Gets all query parts.
1012
+     *
1013
+     * @return array
1014
+     */
1015
+    public function getQueryParts() {
1016
+        return $this->queryBuilder->getQueryParts();
1017
+    }
1018
+
1019
+    /**
1020
+     * Resets SQL parts.
1021
+     *
1022
+     * @param array|null $queryPartNames
1023
+     *
1024
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1025
+     */
1026
+    public function resetQueryParts($queryPartNames = null) {
1027
+        $this->queryBuilder->resetQueryParts($queryPartNames);
1028
+
1029
+        return $this;
1030
+    }
1031
+
1032
+    /**
1033
+     * Resets a single SQL part.
1034
+     *
1035
+     * @param string $queryPartName
1036
+     *
1037
+     * @return \OCP\DB\QueryBuilder\IQueryBuilder This QueryBuilder instance.
1038
+     */
1039
+    public function resetQueryPart($queryPartName) {
1040
+        $this->queryBuilder->resetQueryPart($queryPartName);
1041
+
1042
+        return $this;
1043
+    }
1044
+
1045
+    /**
1046
+     * Creates a new named parameter and bind the value $value to it.
1047
+     *
1048
+     * This method provides a shortcut for PDOStatement::bindValue
1049
+     * when using prepared statements.
1050
+     *
1051
+     * The parameter $value specifies the value that you want to bind. If
1052
+     * $placeholder is not provided bindValue() will automatically create a
1053
+     * placeholder for you. An automatic placeholder will be of the name
1054
+     * ':dcValue1', ':dcValue2' etc.
1055
+     *
1056
+     * For more information see {@link http://php.net/pdostatement-bindparam}
1057
+     *
1058
+     * Example:
1059
+     * <code>
1060
+     * $value = 2;
1061
+     * $q->eq( 'id', $q->bindValue( $value ) );
1062
+     * $stmt = $q->executeQuery(); // executed with 'id = 2'
1063
+     * </code>
1064
+     *
1065
+     * @license New BSD License
1066
+     * @link http://www.zetacomponents.org
1067
+     *
1068
+     * @param mixed $value
1069
+     * @param mixed $type
1070
+     * @param string $placeHolder The name to bind with. The string must start with a colon ':'.
1071
+     *
1072
+     * @return IParameter the placeholder name used.
1073
+     */
1074
+    public function createNamedParameter($value, $type = IQueryBuilder::PARAM_STR, $placeHolder = null) {
1075
+        return new Parameter($this->queryBuilder->createNamedParameter($value, $type, $placeHolder));
1076
+    }
1077
+
1078
+    /**
1079
+     * Creates a new positional parameter and bind the given value to it.
1080
+     *
1081
+     * Attention: If you are using positional parameters with the query builder you have
1082
+     * to be very careful to bind all parameters in the order they appear in the SQL
1083
+     * statement , otherwise they get bound in the wrong order which can lead to serious
1084
+     * bugs in your code.
1085
+     *
1086
+     * Example:
1087
+     * <code>
1088
+     *  $qb = $conn->getQueryBuilder();
1089
+     *  $qb->select('u.*')
1090
+     *     ->from('users', 'u')
1091
+     *     ->where('u.username = ' . $qb->createPositionalParameter('Foo', IQueryBuilder::PARAM_STR))
1092
+     *     ->orWhere('u.username = ' . $qb->createPositionalParameter('Bar', IQueryBuilder::PARAM_STR))
1093
+     * </code>
1094
+     *
1095
+     * @param mixed $value
1096
+     * @param integer $type
1097
+     *
1098
+     * @return IParameter
1099
+     */
1100
+    public function createPositionalParameter($value, $type = IQueryBuilder::PARAM_STR) {
1101
+        return new Parameter($this->queryBuilder->createPositionalParameter($value, $type));
1102
+    }
1103
+
1104
+    /**
1105
+     * Creates a new parameter
1106
+     *
1107
+     * Example:
1108
+     * <code>
1109
+     *  $qb = $conn->getQueryBuilder();
1110
+     *  $qb->select('u.*')
1111
+     *     ->from('users', 'u')
1112
+     *     ->where('u.username = ' . $qb->createParameter('name'))
1113
+     *     ->setParameter('name', 'Bar', IQueryBuilder::PARAM_STR))
1114
+     * </code>
1115
+     *
1116
+     * @param string $name
1117
+     *
1118
+     * @return IParameter
1119
+     */
1120
+    public function createParameter($name) {
1121
+        return new Parameter(':' . $name);
1122
+    }
1123
+
1124
+    /**
1125
+     * Creates a new function
1126
+     *
1127
+     * Attention: Column names inside the call have to be quoted before hand
1128
+     *
1129
+     * Example:
1130
+     * <code>
1131
+     *  $qb = $conn->getQueryBuilder();
1132
+     *  $qb->select($qb->createFunction('COUNT(*)'))
1133
+     *     ->from('users', 'u')
1134
+     *  echo $qb->getSQL(); // SELECT COUNT(*) FROM `users` u
1135
+     * </code>
1136
+     * <code>
1137
+     *  $qb = $conn->getQueryBuilder();
1138
+     *  $qb->select($qb->createFunction('COUNT(`column`)'))
1139
+     *     ->from('users', 'u')
1140
+     *  echo $qb->getSQL(); // SELECT COUNT(`column`) FROM `users` u
1141
+     * </code>
1142
+     *
1143
+     * @param string $call
1144
+     *
1145
+     * @return IQueryFunction
1146
+     */
1147
+    public function createFunction($call) {
1148
+        return new QueryFunction($call);
1149
+    }
1150
+
1151
+    /**
1152
+     * Used to get the id of the last inserted element
1153
+     * @return int
1154
+     * @throws \BadMethodCallException When being called before an insert query has been run.
1155
+     */
1156
+    public function getLastInsertId() {
1157
+        if ($this->getType() === \Doctrine\DBAL\Query\QueryBuilder::INSERT && $this->lastInsertedTable) {
1158
+            // lastInsertId() needs the prefix but no quotes
1159
+            $table = $this->prefixTableName($this->lastInsertedTable);
1160
+            return (int) $this->connection->lastInsertId($table);
1161
+        }
1162
+
1163
+        throw new \BadMethodCallException('Invalid call to getLastInsertId without using insert() before.');
1164
+    }
1165
+
1166
+    /**
1167
+     * Returns the table name quoted and with database prefix as needed by the implementation
1168
+     *
1169
+     * @param string $table
1170
+     * @return string
1171
+     */
1172
+    public function getTableName($table) {
1173
+        if ($table instanceof IQueryFunction) {
1174
+            return (string) $table;
1175
+        }
1176
+
1177
+        $table = $this->prefixTableName($table);
1178
+        return $this->helper->quoteColumnName($table);
1179
+    }
1180
+
1181
+    /**
1182
+     * Returns the table name with database prefix as needed by the implementation
1183
+     *
1184
+     * @param string $table
1185
+     * @return string
1186
+     */
1187
+    protected function prefixTableName($table) {
1188
+        if ($this->automaticTablePrefix === false || strpos($table, '*PREFIX*') === 0) {
1189
+            return $table;
1190
+        }
1191
+
1192
+        return '*PREFIX*' . $table;
1193
+    }
1194
+
1195
+    /**
1196
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
1197
+     *
1198
+     * @param string $column
1199
+     * @param string $tableAlias
1200
+     * @return string
1201
+     */
1202
+    public function getColumnName($column, $tableAlias = '') {
1203
+        if ($tableAlias !== '') {
1204
+            $tableAlias .= '.';
1205
+        }
1206
+
1207
+        return $this->helper->quoteColumnName($tableAlias . $column);
1208
+    }
1209
+
1210
+    /**
1211
+     * Returns the column name quoted and with table alias prefix as needed by the implementation
1212
+     *
1213
+     * @param string $alias
1214
+     * @return string
1215
+     */
1216
+    public function quoteAlias($alias) {
1217
+        if ($alias === '' || $alias === null) {
1218
+            return $alias;
1219
+        }
1220
+
1221
+        return $this->helper->quoteColumnName($alias);
1222
+    }
1223 1223
 }
Please login to merge, or discard this patch.