MysqlDialectTrait.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (https://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  5. *
  6. * Licensed under The MIT License
  7. * For full copyright and license information, please see the LICENSE.txt
  8. * Redistributions of files must retain the above copyright notice.
  9. *
  10. * @copyright Copyright (c) Cake Software Foundation, Inc. (https://cakefoundation.org)
  11. * @link https://cakephp.org CakePHP(tm) Project
  12. * @since 3.0.0
  13. * @license https://opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Database\Dialect;
  16. use Cake\Database\Schema\MysqlSchema;
  17. use Cake\Database\SqlDialectTrait;
  18. /**
  19. * Contains functions that encapsulates the SQL dialect used by MySQL,
  20. * including query translators and schema introspection.
  21. *
  22. * @internal
  23. */
  24. trait MysqlDialectTrait
  25. {
  26. use SqlDialectTrait;
  27. /**
  28. * String used to start a database identifier quoting to make it safe
  29. *
  30. * @var string
  31. */
  32. protected $_startQuote = '`';
  33. /**
  34. * String used to end a database identifier quoting to make it safe
  35. *
  36. * @var string
  37. */
  38. protected $_endQuote = '`';
  39. /**
  40. * The schema dialect class for this driver
  41. *
  42. * @var \Cake\Database\Schema\MysqlSchema
  43. */
  44. protected $_schemaDialect;
  45. /**
  46. * Get the schema dialect.
  47. *
  48. * Used by Cake\Database\Schema package to reflect schema and
  49. * generate schema.
  50. *
  51. * @return \Cake\Database\Schema\MysqlSchema
  52. */
  53. public function schemaDialect()
  54. {
  55. if (!$this->_schemaDialect) {
  56. $this->_schemaDialect = new MysqlSchema($this);
  57. }
  58. return $this->_schemaDialect;
  59. }
  60. /**
  61. * {@inheritDoc}
  62. */
  63. public function disableForeignKeySQL()
  64. {
  65. return 'SET foreign_key_checks = 0';
  66. }
  67. /**
  68. * {@inheritDoc}
  69. */
  70. public function enableForeignKeySQL()
  71. {
  72. return 'SET foreign_key_checks = 1';
  73. }
  74. }