Address.php 930 B

12345678910111213141516171819202122232425262728
  1. <?php
  2. namespace Entity;
  3. class Address extends ModelBase
  4. {
  5. protected function install()
  6. {
  7. $dbPrefix = $this->getDbPrefix();
  8. $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}address` (
  9. `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
  10. `user_id` INTEGER(11) UNSIGNED NULL,
  11. `addressName` VARCHAR(255) NOT NULL,
  12. `fullName` VARCHAR(255) NOT NULL,
  13. `streetAddress` TEXT NOT NULL,
  14. `city` VARCHAR(128) NOT NULL,
  15. `zipCode` VARCHAR(16) NOT NULL,
  16. `country` VARCHAR(128) NOT NULL,
  17. `lastUsed` DATETIME NOT NULL,
  18. FOREIGN KEY (`user_id`) REFERENCES `{$dbPrefix}user`(id),
  19. UNIQUE(`user_id`, `addressName`)
  20. )");
  21. if ($result === false)
  22. throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
  23. return true;
  24. }
  25. }