Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 787307
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T21:10:50+00:00 2026-05-14T21:10:50+00:00

i cant fully understand the ORM models in MVC. so i am using symfony

  • 0

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.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T21:10:51+00:00Added an answer on May 14, 2026 at 9:10 pm

    does this mean that i don’t have to
    create any models? are the doctrine
    models the only models i need?

    This depends on your definition of a model. In terms of Symfony – Doctrine classes are your model and are termed as such in the docs. In general terms though models arent just classes that deal with data persistence. They can be any domain specific classes that contain you business rules/logic. So for example your user session class apps/yourapp/lib/myUser.class.php could be called amodel, through you wont find it termed as such in Symfony.

    where should i put the code that uses the doctrine models:

    It depends on what youre doing. IT might be in the controller, or it could be in another model whether we are talking a Doctrine based class, or some other model class not based on Doctrine. Definitely not in the view though 🙂

    and where should i validate these fields (check if it exists in
    database, that email is email etc)?

    Well normally in Symfony this happens in the form classes. For every model class generated it gets an associated form and filter class. Forms have fields and fields have validators attached. You generally set up the form in the controller then give it data and it validates and handles errors. In terms of checking if an item exists – you generally dont to do that. You try the operation, and then you catch the error and do something appropriate. If you try to add a record that already exists there will be an exception thrown (from the duplicate key error generated by your db).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 393k
  • Answers 393k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer I only know 2 ways to read/write to the disk… May 15, 2026 at 2:01 am
  • Editorial Team
    Editorial Team added an answer EDIT: Corrected version. $(function() { var $all = $('.someclass'); //… May 15, 2026 at 2:01 am
  • Editorial Team
    Editorial Team added an answer config needs to be capitalized. May 15, 2026 at 2:01 am

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.