Cart.php 608 B

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