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 9120959
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T05:44:54+00:00 2026-06-17T05:44:54+00:00

Problem I’m setting up a database by using Symfony2 and Doctrine2 (annotation). I followed

  • 0

Problem

I’m setting up a database by using Symfony2 and Doctrine2 (annotation). I followed the examples perfectly (Doctrine2 relationship documentation), but somehow when I update my schema (doctrine:schema:update --force) it creates two additional tables.

My two entities are Article and District, the code is below.

Code

Article entity:

/**
 *
 * @var \Doctrine\Common\Collections\ArrayCollection $districts
 *
 * @ORM\ManyToMany(targetEntity="District", inversedBy="articles")
 * @ORM\JoinTable(name="articles_districts",
 *     joinColumns={@ORM\JoinColumn(name="article_id", referencedColumnName="id")},
 *     inverseJoinColumns={@ORM\JoinColumn(name="district_id", referencedColumnName="id")}
 * )
 */
protected $districts;

District entity:

/**
 *
 * @var \Doctrine\Common\Collections\ArrayCollection $articles
 * @ORM\ManyToMany(targetEntity="Article", inversedBy="districts")
 */
protected $articles;

Question

The two extra tables that are being created are: articles_districts (the one I specified in the JoinTable section) and article_district (the other one that somehow gets created automatically).

The articles_districts table works as expected and ID’s are inserted when a new entry is made. The article_district remains empty, and thus, is pretty useless. How do I get rid of it?

  • 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-06-17T05:44:55+00:00Added an answer on June 17, 2026 at 5:44 am

    Your district entity should use the mappedBy annotation:

    /**
     *
     * @var \Doctrine\Common\Collections\ArrayCollection $articles
     * @ORM\ManyToMany(targetEntity="Article", mappedBy="districts")
     */
    protected $articles;
    

    At the moment you are trying to have two owning sides to your entity relationship: http://docs.doctrine-project.org/en/2.0.x/reference/association-mapping.html#many-to-many-bidirectional

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

Sidebar

Related Questions

Problem: Check box value display null in controller.cs. but it is working perfectly according
Problem: I have a table that prints out vertical but I would like it
Problem: I am trying to build a recursive tree using a function and data
Problem: I'm streaming my video from a php file with stream_get_contents(); using Flowplayer as
Problem Using Director 11.5 and Windows 7, with MouseWheel Xtra (wheelmouse.zip), I have the
Problem: I'm attempting to disable a radio button by using the code below. This
Problem I have a Silverlight 5 application using the treeview from the SDK. Now
Problem Hi, Im working with a friend on a Symfony2 project. He's working on
Problem I need to construct a 2D grid using a set of candidate positions
Problem I'm trying to build a minimal example where I create a many-to-many relationship

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.