MySqlTools.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @author Thomas Müller <thomas.mueller@tmit.eu>
  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. namespace OC\DB;
  22. use OCP\IDBConnection;
  23. /**
  24. * Various MySQL specific helper functions.
  25. */
  26. class MySqlTools {
  27. /**
  28. * @param Connection $connection
  29. * @return bool
  30. */
  31. public function supports4ByteCharset(IDBConnection $connection) {
  32. foreach (['innodb_file_format' => 'Barracuda', 'innodb_large_prefix' => 'ON', 'innodb_file_per_table' => 'ON'] as $var => $val) {
  33. $result = $connection->executeQuery("SHOW VARIABLES LIKE '$var'");
  34. $rows = $result->fetch();
  35. $result->closeCursor();
  36. if ($rows === false) {
  37. return false;
  38. }
  39. if (strcasecmp($rows['Value'], $val) !== 0) {
  40. return false;
  41. }
  42. }
  43. return true;
  44. }
  45. }