Passed
Push — master ( 078ac9...e21d65 )
by Roeland
11:50 queued 11s
created

MySqlExpressionBuilder::neq()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 2
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

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

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

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