understanding the ORM models in MVC
Posted
by fayer
on Stack Overflow
See other posts from Stack Overflow
or by fayer
Published on 2010-05-09T04:41:24Z
Indexed on
2010/05/09
5:08 UTC
Read the original article
Hit count: 179
i cant fully understand the ORM models in MVC.
so i am using symfony with doctrine. the doctrine models are created.
does this mean that i don't have to create any models? are the doctrine models the only models i need?
where should i put the code that uses the doctrine models:
eg.
$phoneIds = array();
$phone1 = new Phonenumber();
$phone1['phonenumber'] = '555 202 7890';
$phone1->save();
$phoneIds[] = $phone1['id'];
$phone2 = new Phonenumber();
$phone2['phonenumber'] = '555 100 7890';
$phone2->save();
$phoneIds[] = $phone2['id'];
$user = new User();
$user['username'] = 'jwage';
$user['password'] = 'changeme';
$user->save();
$user->link('Phonenumbers', $phoneIds);
should this code be in the controller or in another model?
and where should i validate these fields (check if it exists in database, that email is email etc)?
could someone please shed a light on this.
thanks.
© Stack Overflow or respective owner