understanding the ORM models in MVC
- by fayer
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.