2014-09-09 07:57:02 -04:00
|
|
|
<?php
|
2024-05-23 03:26:56 -04:00
|
|
|
|
2014-09-09 07:57:02 -04:00
|
|
|
/**
|
2024-05-23 03:26:56 -04:00
|
|
|
* SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
|
|
|
|
|
* SPDX-FileCopyrightText: 2016 ownCloud, Inc.
|
|
|
|
|
* SPDX-License-Identifier: AGPL-3.0-only
|
2014-09-09 07:57:02 -04:00
|
|
|
*/
|
|
|
|
|
namespace OC\DB;
|
|
|
|
|
|
|
|
|
|
class AdapterMySQL extends Adapter {
|
2016-10-18 05:37:49 -04:00
|
|
|
/** @var string */
|
2021-08-31 15:01:27 -04:00
|
|
|
protected $collation;
|
2016-10-18 05:37:49 -04:00
|
|
|
|
2016-05-19 06:34:40 -04:00
|
|
|
/**
|
|
|
|
|
* @param string $tableName
|
|
|
|
|
*/
|
|
|
|
|
public function lockTable($tableName) {
|
|
|
|
|
$this->conn->executeUpdate('LOCK TABLES `' .$tableName . '` WRITE');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public function unlockTable() {
|
|
|
|
|
$this->conn->executeUpdate('UNLOCK TABLES');
|
|
|
|
|
}
|
|
|
|
|
|
2014-09-09 07:57:02 -04:00
|
|
|
public function fixupStatement($statement) {
|
2021-08-31 15:01:27 -04:00
|
|
|
$statement = str_replace(' ILIKE ', ' COLLATE ' . $this->getCollation() . ' LIKE ', $statement);
|
2014-09-09 07:57:02 -04:00
|
|
|
return $statement;
|
|
|
|
|
}
|
2016-10-18 05:37:49 -04:00
|
|
|
|
2021-08-31 15:01:27 -04:00
|
|
|
protected function getCollation(): string {
|
|
|
|
|
if (!$this->collation) {
|
2016-10-18 05:37:49 -04:00
|
|
|
$params = $this->conn->getParams();
|
2021-08-31 15:01:27 -04:00
|
|
|
$this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8') . '_general_ci');
|
2016-10-18 05:37:49 -04:00
|
|
|
}
|
|
|
|
|
|
2021-08-31 15:01:27 -04:00
|
|
|
return $this->collation;
|
2016-10-18 05:37:49 -04:00
|
|
|
}
|
2014-09-09 07:57:02 -04:00
|
|
|
}
|