| 1234567891011121314151617181920212223 |
- <?php
- namespace Entity;
- class CartProduct extends ModelBase
- {
- protected function install()
- {
- $dbPrefix = $this->getDbPrefix();
- $result = self::$dbo->exec("CREATE TABLE IF NOT EXISTS `{$dbPrefix}cart_product` (
- `cart_id` INTEGER(11) UNSIGNED NOT NULL,
- `product_id` INTEGER(11) UNSIGNED NULL,
- `quantity` INTEGER(10) UNSIGNED NOT NULL,
- FOREIGN KEY (`cart_id`) REFERENCES `{$dbPrefix}cart`(id),
- FOREIGN KEY (`product_id`) REFERENCES `{$dbPrefix}product`(id),
- UNIQUE(`cart_id`, `product_id`)
- )");
- if ($result === false)
- throw new \Exception(get_class().": ".self::$dbo->errorInfo()[2]);
- return true;
- }
- }
|