Category.php 583 B

1234567891011121314151617181920
  1. <?php
  2. namespace Entity;
  3. class Category extends ModelBase
  4. {
  5. protected function install()
  6. {
  7. $dbPrefix = $this->getDbPrefix();
  8. $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}category` (
  9. `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  10. `parent_id` INTEGER(11) UNSIGNED NULL,
  11. FOREIGN KEY (`parent_id`) REFERENCES `{$dbPrefix}category`(id)
  12. )");
  13. if ($result === false)
  14. throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
  15. return true;
  16. }
  17. }