Each object represents one row in the database. Example:
admins table
id, first_name, last_name
1, 'John', 'Doe'
$admin object (pseudo)
class admin extends base {
protected $id;
protected $first_name;
protected $last_name;
public function setter() { }
public function getter() { }
/* ETC */
}
This part is really clear to me, I can set, get and save (this function is located in base class) the data.
Now what should I do when I create a table that has multiple rows that are related to another table. Example:
admin_preveleges table
id, admin_id, privilege, value
1, 1, 'read_reports', 1
2, 1, 'delete_news', 1
3, 1, 'delete_users', 1
What would the object look? Would one object contain all 3 rows for our John Doe admin? Or would I create 3 objects for John Doe?
How can I connect these to the admin object?
If I create 3 separate objects and connect them to the $admin object, how could I check if this admin has the privilege do delete users? Would I have to loop through all objects and check if one of them is 'delete_users' and then break the loop?
Or should I forget about making the privilege table an object and just create a handler for it inside $admin object?