我正在尝试从数据透视表中获取数据,但是我没有运气找到有关如何检索数据的任何信息。 当我看上去时,我总是会去那些有Laravel的地方,但是我想用纯PHP做到这一点。
所以我想做的就是抓住用户购买的物品。 例如
User 3
order_date: 24 Feb 2018
items bought:
2
5
1
user 5
order_date: 05 May 2018
items bought:
3
user 2
order_date: 18 Oct 2018
items bought:
6
4
这是我的物品表
id| name |description
1 | item 1 | item 1 description
2 | item 2 | item 2 description
3 | item 3 | item 3 description
4 | item 4 | item 4 description
5 | item 5 | item 5 description
6 | item 6 | item 6 description
我的数据透视表
id| item_id | order_id
1 | 2 | 1
2 | 5 | 1
3 | 1 | 1
4 | 3 | 2
5 | 6 | 3
6 | 4 | 3
和我的订单
id| order_date | user_id
1 | 2018-02-24 | 3
2 | 2018-05-05 | 5
3 | 2018-10-18 | 2
答案 0 :(得分:0)
感谢@Dharman,他发布了重复问题的链接。我设法解决了我的问题