| 12345678910111213141516171819202122232425262728 |
- <?php
- namespace Entity;
- class Address extends ModelBase
- {
- protected function install()
- {
- $dbPrefix = $this->getDbPrefix();
- $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}address` (
- `id` INTEGER(11) UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
- `user_id` INTEGER(11) UNSIGNED NULL,
- `addressName` VARCHAR(255) NOT NULL,
- `fullName` VARCHAR(255) NOT NULL,
- `streetAddress` TEXT NOT NULL,
- `city` VARCHAR(128) NOT NULL,
- `zipCode` VARCHAR(16) NOT NULL,
- `country` VARCHAR(128) NOT NULL,
- `lastUsed` DATETIME NOT NULL,
- FOREIGN KEY (`user_id`) REFERENCES `{$dbPrefix}user`(id),
- UNIQUE(`user_id`, `addressName`)
- )");
- if ($result === false)
- throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
- return true;
- }
- }
|