Completed
Push — master ( 58d53e...73f4ae )
by Lukas
13:40
created

MySqlExpressionBuilder::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
nc 2
nop 1
dl 0
loc 6
rs 9.4285
c 1
b 0
f 0
1
<?php
2
/**
3
 * @copyright Copyright (c) 2016, ownCloud, Inc.
4
 *
5
 * @author Joas Schilling <[email protected]>
6
 * @author Thomas Müller <[email protected]>
7
 *
8
 * @license AGPL-3.0
9
 *
10
 * This code is free software: you can redistribute it and/or modify
11
 * it under the terms of the GNU Affero General Public License, version 3,
12
 * as published by the Free Software Foundation.
13
 *
14
 * This program is distributed in the hope that it will be useful,
15
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
 * GNU Affero General Public License for more details.
18
 *
19
 * You should have received a copy of the GNU Affero General Public License, version 3,
20
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
21
 *
22
 */
23
24
namespace OC\DB\QueryBuilder\ExpressionBuilder;
25
26
27
use OC\DB\Connection;
28
use OCP\IDBConnection;
29
30
class MySqlExpressionBuilder extends ExpressionBuilder {
31
32
	/** @var string */
33
	protected $charset;
34
35
	/**
36
	 * @param \OCP\IDBConnection|Connection $connection
37
	 */
38
	public function __construct(IDBConnection $connection) {
39
		parent::__construct($connection);
40
41
		$params = $connection->getParams();
0 ignored issues
show
Bug introduced by
The method getParams() does not seem to exist on object<OCP\IDBConnection>.

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
42
		$this->charset = isset($params['charset']) ? $params['charset'] : 'utf8';
43
	}
44
45
	/**
46
	 * @inheritdoc
47
	 */
48
	public function iLike($x, $y, $type = null) {
49
		$x = $this->helper->quoteColumnName($x);
50
		$y = $this->helper->quoteColumnName($y);
51
		return $this->expressionBuilder->comparison($x, ' COLLATE ' . $this->charset . '_general_ci LIKE', $y);
52
	}
53
54
}
55