将购物车详细信息保存到数据库中 [英] Saving cart details into database

查看:286
本文介绍了将购物车详细信息保存到数据库中的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个购物车表与我正在使用的产品表相关联,以将用户的购物车详细信息保存到数据库。但是我有一个问题,如何节省产品数量?



我的意思是像298的2x(这是产品的id)?

解决方案

product_to_cart

  + ---- ----- + ------------ + ----- + 
| cart_id | product_id |数量|
+ --------- + ------------ + ----- +
| x | x | x |

...

复合主键包含 cart_id product_id


I have a cart table which has a relation to a product table that i am using to save user's cart details to db. But i have a problem how can i save quantity of products?

I mean something like 2x of 298 (which is a id of a product)?

解决方案

product_to_cart

+---------+------------+-----+
| cart_id | product_id | qty |
+---------+------------+-----+
| x       | x          | x   |

...

With a compound primary key comprising cart_id and product_id ?

这篇关于将购物车详细信息保存到数据库中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆