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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T01:26:59+00:00 2026-06-17T01:26:59+00:00

I’m creating a website which will contain multiple pages and multiple images. The relationship

  • 0

I’m creating a website which will contain multiple pages and multiple images. The relationship is that many pages can have many images. Therefore, I would usually create a join table called page_images which contain the page_id and the image_id. I would also need a position field in the join table so that the images for each page can be ordered.

I’ve been looking at Doctrine today and using Symfony2 entities to create the database. I tried using a many to many relationship using the metadata however this created the join table for me which only consisted of page_id and image_id. I wasn’t sure how to add the position field or any other field, is that possible?

The alternative I assume would be to create a one to many relationship from the page table to the page_images table and also from the images table to the page_images table meaning I would also need a PageImage Entity class.

Can someone please advise what would be the best practice for this scenario? I’ve been looking at http://docs.doctrine-project.org/en/latest/reference/working-with-associations.html but the documentation doesn’t mention if you can add additional fields to the join table.

More info:

class Image {

/**
 *
 * @ORM\OneToMany(targetEntity="PageImage", mappedBy="image")
 */
private $page_images;

}

class Page {

/**
 *
 * @ORM\OneToMany(targetEntity="PageImage", mappedBy="page")
 */
private $page_images;

}

class PageImage {

/**
 * @var integer
 *
 * @ORM\ManyToOne(targetEntity="Page", inversedBy="page_images")
 * @ORM\JoinColumn(name="page_id", referencedColumnName="id")
 */
private $page;

}
  • 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-17T01:27:00+00:00Added an answer on June 17, 2026 at 1:27 am

    You already have the response : you need to have 2 ManyToOne relations from PageImage entity.
    Then you will be able to add extra fields in this entity.

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

Sidebar

Related Questions

I used javascript for loading a picture on my website depending on which small
I have a jquery bug and I've been looking for hours now, I can't
I have a small JavaScript validation script that validates inputs based on Regex. I
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have an autohotkey script which looks up a word in a bilingual dictionary
I have an array which has BIG numbers and small numbers in it. I
I have a text area in my form which accepts all possible characters from
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I need a function that will clean a strings' special characters. I do NOT

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.