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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T14:49:05+00:00 2026-05-22T14:49:05+00:00

Say you have the following relations (altered for simplicity): Dog: columns: id: { type:

  • 0

Say you have the following relations (altered for simplicity):

Dog:
  columns:
    id:         { type: integer, notnull: true, primary: true }
    name:       { type: string,  notnull: true }

AwardType:
  columns:
    id:         { type: integer, notnull: true, primary: true }
    name:       { type: string,  notnull: true }

Award:
  columns:
    dog_id:     { type: integer, notnull: true, primary: true }
    award_id:   { type: integer, notnull: true, primary: true }
    is_granted: { type: boolean, notnull: true, default: false }
  relations:
    Dog:
      local:        dog_id
      foreign:      id
      type:         one
      foreignType:  many
      foreignAlias: Awards
    AwardType:
      local:        award_id
      foreign:      id
      type:         one
      foreignType:  many
      foreignAlias: Awards

With the above setup I can add a new dog and manually add Awards to that dog. I can also edit awards already granted to a dog.

When I call $myDog->getAwards() I want the set to include all granted awards (Award.is_granted==true && Award.dog_id==$myDog()->getId()) pluss all awards that have not been granted to that dog yet.

Is there an option that can be set in a model somewhere to make this happen? If not, what would be the best way to achieve it?

I’m using Symfony 1.4 and the bundled Doctrine 1.2 ORM.

[ Edit 1 ]
I realize I didn’t explain the whole award thing properly, so I’ll try to expand on it. Say you have the following AwardTypes:

  • 1: Bone for not molesting postman
  • 2: Collar for not biting Miss Molly
  • 3: Bigger bone for chasing milkman (who we all know is evil)

Dog1 is already registered and has been granted AwardTypes 1 and 3. When editing that Dog the form should display AwardTypes 1 and 3 with a checked checkbox and AwardType 2 with an unchecked checkbox. This works great if Dog 1 has one entry in the Award table for each of the AwardTypes. Two with is_granted == true and one is_granted == false. So far so good.

When the user enters a new Dog the form should display all the AwardTypes, but with no checked checkboxes. When saving the new Dog a total of 3 rows should appear in the Awards table with the is_granted-flag set according to the checked-state of the checkboxes.

I know I can get all AwardTypes and check that against the AwardTypes a Dog has been granted already (showing all unchecked for new dogs, granted checked + not yet granted unchecked for existing dogs). What I am asking here is wether or not Doctrine has some magic that will give me compound sets as described above.

  • 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-22T14:49:06+00:00Added an answer on May 22, 2026 at 2:49 pm

    Ok you have a problem modeling your data. It should probably look like this:

    Dog:
      columns:
        id:         { type: integer, notnull: true, primary: true }
        name:       { type: string,  notnull: true, unique: true }
      relations:
        Awards:
          class: Award
          foreignType: many
          type: many
          refClass: DogAward
          local: dog_id
          foreign: award_id
    
    Award:
      columns:
        id:         { type: integer, notnull: true, primary: true }
        name:       { type: string,  notnull: true, unique: true }
    
    DogAward:
      columns:
        dog_id:     { type: integer, notnull: true, primary: true }
        award_id:   { type: integer, notnull: true, primary: true }
    

    I have used a many-to-many relations, and added some constraint that I think might be useful in your case.
    Symfony should generate a form looking like what you want, tell us if it is not the case.

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

Sidebar

Related Questions

Lets say i have following class public class abc { int id; string name;
Let us say I have the following string: my ., .,dog. .jumps. , .and..he.
Say I have the following chef role: name test description role for test run_list
Say I have the following: string fromTime = 8:00am; string someDate = 06/01/2012; I
Let say I have 3 models: A, B and C with the following relations.
Let's say I have following POJO's using Hibernate. public class User { private String
Let's say I have following string: string test = False; I can't loop the
Say I have a class, User: public class User { private String name; private
Say I have the following many to many with jobs and users Assignment: columns:
Let's say I have following models: class Worker { int Id; string firstname; string

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.