blacktie24
blacktie24

Reputation: 5075

Where should I be using data mappers while still keeping controllers thin in MVC?

If i'm trying to keep with my controllers thin, and my models unaware of the details of their persistance, where should I be saving/accessing my models? I can't put it in the controller, and I can't put it in the domain object, is there supposed to be some other layer/object which handles this type of processing? Thanks!

Upvotes: 0

Views: 92

Answers (1)

Galen
Galen

Reputation: 30170

I use table gateways in my controllers

$userTableGateway = new UserTableGateway();
$userTableGateway->getUser( 5 ); // returns a user object
$userTableGateway->insert( $user ); // Adds a new user
$userTableGateway->save( $user ); // Saves a user

Upvotes: 1

Related Questions