I have developed a scheduling application where I have one table and dm class called "users" where i so far have stored all information about all users in the system. All users are internal users.
Now I need to implement login functionality for external users (customers) too.
My question: I would now like to use my table users and just add an enum field 'user_type' (internal/external).
I would then like to create a datamapper object called internal_user and another one called exernal_user.
when i run
$external_user = new External_user();
$external_user->get();
I only want to get the rows in my user table where user_type = external. Is that possible to achieve in a nice way using datamapper?
UPDATE:
I solved the problem by overriding the get method in the Datamapper class like this:
class Internal_user(){
[...]
function get()
{
$this->where('type', 'internal');
return parent::get();
}
}
Now this line:
$internal_user->get();
only returns the records with the value internal in my user_type field.