0

I'm trying to get data from a pivot table, but I haven't had any luck finding any information on how to retrieve the data. When I look I always land up going to places that has Laravel, but I would like to do it in pure PHP.

So what I would like to do is grab the items that the user bought. For example

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

Here is my items table

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        

My pivot table

id| item_id   | order_id         
1 | 2         |  1        
2 | 5         |  1        
3 | 1         |  1        
4 | 3         |  2        
5 | 6         |  3        
6 | 4         |  3        

and my orders

id| order_date   | user_id
1 | 2018-02-24   | 3 
2 | 2018-05-05   | 5  
3 | 2018-10-18   | 2
Dharman
  • 30,962
  • 25
  • 85
  • 135
Isis
  • 189
  • 4
  • 16

1 Answers1

0

Thanks to @Dharman who posted the link to the duplicate question. I managed to solve my issue

Isis
  • 189
  • 4
  • 16