DesignerTable.php 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. <?php
  2. /* vim: set expandtab sw=4 ts=4 sts=4: */
  3. /**
  4. * Holds the PhpMyAdmin\Database\Designer\DesignerTable class
  5. *
  6. * @package PhpMyAdmin-Designer
  7. */
  8. namespace PhpMyAdmin\Database\Designer;
  9. use PhpMyAdmin\Util;
  10. /**
  11. * Common functions for Designer
  12. *
  13. * @package PhpMyAdmin-Designer
  14. */
  15. class DesignerTable
  16. {
  17. private $tableName;
  18. private $databaseName;
  19. private $tableEngine;
  20. private $displayField;
  21. /**
  22. * Create a new DesignerTable
  23. *
  24. * @param string $databaseName The database name
  25. * @param string $tableName The table name
  26. * @param string $tableEngine The table engine
  27. * @param string|null $displayField The display field if available
  28. */
  29. public function __construct(
  30. string $databaseName,
  31. string $tableName,
  32. string $tableEngine,
  33. ?string $displayField
  34. ) {
  35. $this->databaseName = $databaseName;
  36. $this->tableName = $tableName;
  37. $this->tableEngine = $tableEngine;
  38. $this->displayField = $displayField;
  39. }
  40. /**
  41. * The table engine supports or not foreign keys
  42. *
  43. * @return bool
  44. */
  45. public function supportsForeignkeys(): bool
  46. {
  47. return Util::isForeignKeySupported($this->tableEngine);
  48. }
  49. /**
  50. * Get the database name
  51. *
  52. * @return string
  53. */
  54. public function getDatabaseName(): string
  55. {
  56. return $this->databaseName;
  57. }
  58. /**
  59. * Get the table name
  60. *
  61. * @return string
  62. */
  63. public function getTableName(): string
  64. {
  65. return $this->tableName;
  66. }
  67. /**
  68. * Get the table engine
  69. *
  70. * @return string
  71. */
  72. public function getTableEngine(): string
  73. {
  74. return $this->tableEngine;
  75. }
  76. /**
  77. * Get the displayed field
  78. *
  79. * @return string
  80. */
  81. public function getDisplayField()
  82. {
  83. return $this->displayField;
  84. }
  85. /**
  86. * Get the db and table separated with a dot
  87. *
  88. * @return string
  89. */
  90. public function getDbTableString(): string
  91. {
  92. return $this->databaseName . '.' . $this->tableName;
  93. }
  94. }