I'm writing my own PHP MVC framework and I was wondering which is the most appropriate place to code persistent data objects like User for instance. Without persistent storage like $_SESSION, APC, memcached,... someone could retrieve user data from the database every http request, which is a bad idea in terms of performance. (M)odel seems like a good choice. Is something like this a good start:
class UserModel extends Model
{
public function getEmail()
{
$user = Session::get('User');
if(isset($user))
{
return $user->Email;
}
return null;
}
}
Probably not, as it is not returning db data which is most Models do. Should I create an independent class? Is there any pattern for this? I wouldn't like to make it global, who is the owner/manager for such objects?