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(); |
|
|
|
|
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
|
|
|
|