OOPHP - How do I create multiple objects from an array of database rows?

koewurzyck

New Member
I'm new to "Object Oriented" PHP, but have managed to figure most things out so far. I'm building a website where users can register an account and then add, let's say, hobbies onto their profile.I've managed to figure out creating the class, object, storing a single user in the database, and retrieving a single user from the database - creating a new object from the associative array that is returned from the SQL "select" query.Where I am now getting stuck is when I need it to return multiple rows (records) from the database. For example, a user may have 7 hobbies; the SQL query returns all 7 rows into an associative array (with fields e.g. hobby_id, hobby_name, hobby_created), but how then do I make each one of those rows/hobby records into its own object?I have tried searching all sorts of terms but I don't know if I'm just missing the buzz word that I need to search for. If anyone could please let me know the best way to go about this I would be eternally greatful.Many thanks,Steve
 
Back
Top