I am trying to plan out php class structure for an order processing project. I've used classes before but I'm still not an expert on OOP yet. I've been searching for hours and can't seem to find the answer to this particular scenario, despite it being very common.
One of the main objects will be an
Order. As such, that class will have methods to handle getting and setting of all the properties of the
Order instance. (It will also have properties containing other objects such as arrays of
My question is what happens when I need a filtered set of orders from the DB? Making a method in
Order that returns an array of.. itself?... definitely isn't right. Is making an
Orders class that has methods to handle a single
Order as well as an array of
Order objects the recommended way to handle this? Or is there another design pattern that is better suited?
A couple of other options would be to return a raw array and let the calling function handle it. Or create an
OrderModel that just has a bunch of public properties of an order and the
Order class can return that object or an array of