Completed
Push — master ( 4d101c...278637 )
by Lukas
18:49 queued 06:10
created

MySqlTools   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
dl 0
loc 21
rs 10
c 0
b 0
f 0
wmc 4
lcom 0
cbo 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A supports4ByteCharset() 0 14 4
1
<?php
2
/**
3
 * @author Thomas Müller <[email protected]>
4
 *
5
 * @copyright Copyright (c) 2017, ownCloud GmbH
6
 * @license AGPL-3.0
7
 *
8
 * This code is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License, version 3,
10
 * as published by the Free Software Foundation.
11
 *
12
 * This program is distributed in the hope that it will be useful,
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
 * GNU Affero General Public License for more details.
16
 *
17
 * You should have received a copy of the GNU Affero General Public License, version 3,
18
 * along with this program.  If not, see <http://www.gnu.org/licenses/>
19
 *
20
 */
21
22
namespace OC\DB;
23
24
use OCP\IDBConnection;
25
26
/**
27
* Various MySQL specific helper functions.
28
*/
29
class MySqlTools {
30
31
	/**
32
	 * @param Connection $connection
33
	 * @return bool
34
	 */
35
	public function supports4ByteCharset(IDBConnection $connection) {
36
		foreach (['innodb_file_format' => 'Barracuda', 'innodb_large_prefix' => 'ON', 'innodb_file_per_table' => 'ON'] as $var => $val) {
37
			$result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'");
38
			$rows = $result->fetch();
39
			$result->closeCursor();
40
			if ($rows === false) {
41
				return false;
42
			}
43
			if (strcasecmp($rows['Value'], $val) !== 0) {
44
				return false;
45
			}
46
		}
47
		return true;
48
	}
49
}
50