Ok so i'll try and explain this as best as I can.
I have a User class, and a Person class which extends / inherits from the User class, and possibly others which then further extend the Person class. I also have a Company class which extends the User class..
So a User can be a Person or Company and they each have different fields associated with them depending on the type.
The User class is a pretty generic class with basically login credentials in. The Person class contains your standard 'person' information like title, firstname etc etc.
Each of these map to a seperate MySQL table in my database.
In my Users class i've got a function called get_users_by_params which takes an array of parameters (fields) that I could potentially query.
The same applies with the Person class; I have a get_persons_by_params. This is where my question is relevant. I need to get the associated user data in this same function, so i'm returning a fully populated Person object ie with the 'User credentials etc'. I'd like to keep all the User logic in the User class, and the Person logic in the Person class. So Ideally I'd want to call my get_users_by_params function from my Person class, and pass it my list of People to get the Userdata for.
Can someone make some suggestions on what would be the best way of doing so ? I don't want to have to run an individual query for each 'Person' to get the User data because the list of people i'm returning could be massive. E.g. If i passed the User function 500 people, it would then need to run another query to get each of those peoples' user data thus resulting in a lot of queries - not good practice i'd imagine.