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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T08:11:26+00:00 2026-06-07T08:11:26+00:00

I’m sure there’s a simple solution to this, but I can’t fathom what’s going

  • 0

I’m sure there’s a simple solution to this, but I can’t fathom what’s going on. I have an entity called a Payment and two other entities called User and Household.

A User has many Payments and and a Household has many Payments. This is all mapped as unidirectional manyToOne relationships of the Payment using YAML, like this (hopefully this is in line with the guidance at http://docs.doctrine-project.org/projects/doctrine-orm/en/2.1/reference/association-mapping.html#many-to-one-unidirectional) –

Payment:
  type: entity
  table: payments
  id:
    _id:
      type: integer
      column: payment_id
      generator:
        strategy: AUTO
    manyToOne:
    _user:
      targetEntity: Application_Model_User
      joinColumn:
        name: user_id
        referencedColumnName: payment_id
    _household:
      targetEntity: Application_Model_Household
      joinColumn:
        name: household_id
        referencedColumnName: payment_id

Database wise, I have three tables, users, payments and households. The payments table has (in addition to it’s primary key) two columns called user_id and household_id, which correspond the to primary keys of the other two tables.

The problem is that when I try to persist a new Payment I get an error back from mySql telling me that the user_id column of payments cannot be null. Some digging has established that doctrine is supplying null for both user_id and household_id in the INSERT statement. The object graph is definitely correct.

In addition, I get the following warnings:

Notice: Undefined index: payment_id in [..]/library/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 511

Notice: Undefined index: in [..]/library/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 511

Notice: Undefined index: payment_id in [..]/library/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 511

Notice: Undefined index: in [..]/library/Doctrine/ORM/Persisters/BasicEntityPersister.php on line 511

I’ve established that the payment_id in question is coming from the referencedColumnNames in my mapping, and that the index is undefined because the array doctrine is searching contains the fields from the opposite side of the relationship, i.e. the Household or the User. But surely it shouldn’t be? I think I’ve followed the guide, but I can’t make it work.

I’m using Zend Framework, if it helps, but there’s nothing special going on my code. I’m pretty sure it’s a mapping problem.

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-06-07T08:11:29+00:00Added an answer on June 7, 2026 at 8:11 am

    I’ve only worked with Doctrine + Symfony2, but I think your referencedColumnName should just be “id”, not payment_id, because you need to explain the foreign key relationship.

    payment.household_id –references–> household.id.

    In Symfony2 there is an ‘inversedBy’ property for Doctrine, which is used to map the column in the other table that would represent the payment_id.

    A snippet of code from a Symfony2 Mapping:

    /**
    * @ORM\ManyToOne(targetEntity="kurtfunai\WalkthroughBundle\Entity\Group", inversedBy="members")
    * @ORM\JoinColumn(name="fk_group_id", referencedColumnName="id")
    */
    protected $group;
    

    In your case it would need altered to something like this:

    _user:
      targetEntity: Application_Model_User
      joinColumn:
        name: user_id
        referencedColumnName: <USERS_TABLE_PRIMARY_KEY_COLUMN_NAME>
    _household:
      targetEntity: Application_Model_Household
      joinColumn:
        name: household_id
        referencedColumnName: <HOUSEHOLDS_TABLE_PRIMARY_KEY_COLUMN_NAME>
    

    (Replace with the appropriate column names)

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

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
This could be a duplicate question, but I have no idea what search terms
I have just tried to save a simple *.rtf file with some websites and
I have a jquery bug and I've been looking for hours now, I can't
this is what i have right now Drawing an RSS feed into the php,
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I know there's a lot of other questions out there that deal with this
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the 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.