SqlGeneratorInterface.php 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. <?php
  2. /**
  3. * CakePHP(tm) : Rapid Development Framework (http://cakephp.org)
  4. * Copyright (c) Cake Software Foundation, Inc. (http://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. (http://cakefoundation.org)
  11. * @link http://cakephp.org CakePHP(tm) Project
  12. * @since 3.5.0
  13. * @license http://www.opensource.org/licenses/mit-license.php MIT License
  14. */
  15. namespace Cake\Database\Schema;
  16. use Cake\Database\Connection;
  17. /**
  18. * An interface used by TableSchema objects.
  19. */
  20. interface SqlGeneratorInterface
  21. {
  22. /**
  23. * Generate the SQL to create the Table.
  24. *
  25. * Uses the connection to access the schema dialect
  26. * to generate platform specific SQL.
  27. *
  28. * @param \Cake\Database\Connection $connection The connection to generate SQL for.
  29. * @return array List of SQL statements to create the table and the
  30. * required indexes.
  31. */
  32. public function createSql(Connection $connection);
  33. /**
  34. * Generate the SQL to drop a table.
  35. *
  36. * Uses the connection to access the schema dialect to generate platform
  37. * specific SQL.
  38. *
  39. * @param \Cake\Database\Connection $connection The connection to generate SQL for.
  40. * @return array SQL to drop a table.
  41. */
  42. public function dropSql(Connection $connection);
  43. /**
  44. * Generate the SQL statements to truncate a table
  45. *
  46. * @param \Cake\Database\Connection $connection The connection to generate SQL for.
  47. * @return array SQL to truncate a table.
  48. */
  49. public function truncateSql(Connection $connection);
  50. /**
  51. * Generate the SQL statements to add the constraints to the table
  52. *
  53. * @param \Cake\Database\Connection $connection The connection to generate SQL for.
  54. * @return array SQL to add the constraints.
  55. */
  56. public function addConstraintSql(Connection $connection);
  57. /**
  58. * Generate the SQL statements to drop the constraints to the table
  59. *
  60. * @param \Cake\Database\Connection $connection The connection to generate SQL for.
  61. * @return array SQL to drop a table.
  62. */
  63. public function dropConstraintSql(Connection $connection);
  64. }