AdapterMySQL.php 935 B

1234567891011121314151617181920212223242526272829303132333435363738
  1. <?php
  2. /**
  3. * SPDX-FileCopyrightText: 2016-2024 Nextcloud GmbH and Nextcloud contributors
  4. * SPDX-FileCopyrightText: 2016 ownCloud, Inc.
  5. * SPDX-License-Identifier: AGPL-3.0-only
  6. */
  7. namespace OC\DB;
  8. class AdapterMySQL extends Adapter {
  9. /** @var string */
  10. protected $collation;
  11. /**
  12. * @param string $tableName
  13. */
  14. public function lockTable($tableName) {
  15. $this->conn->executeUpdate('LOCK TABLES `' .$tableName . '` WRITE');
  16. }
  17. public function unlockTable() {
  18. $this->conn->executeUpdate('UNLOCK TABLES');
  19. }
  20. public function fixupStatement($statement) {
  21. $statement = str_replace(' ILIKE ', ' COLLATE ' . $this->getCollation() . ' LIKE ', $statement);
  22. return $statement;
  23. }
  24. protected function getCollation(): string {
  25. if (!$this->collation) {
  26. $params = $this->conn->getParams();
  27. $this->collation = $params['collation'] ?? (($params['charset'] ?? 'utf8') . '_general_ci');
  28. }
  29. return $this->collation;
  30. }
  31. }