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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T01:32:37+00:00 2026-06-18T01:32:37+00:00

In a Doctrine 1.2 project we’ve got a User User: columns: id: type: integer(4)

  • 0

In a Doctrine 1.2 project we’ve got a User

User:
  columns:
    id:
      type: integer(4)
      autoincrement: true
      primary: true
    payment_method:
      type: integer(4)
  relations:
    DefaultPaymentMethod:
      class: PaymentMethod
      local: payment_method
      foreignAlias: Users
      foreign: id
      type: one

with his PaymentMethods

PaymentMethod:
  actAs:
    BS_Db_Template_SoftDelete:
  columns:
    id:
      type: integer(4)
      primary: true
      autoincrement: true
    user:
      type: integer(4)
  relations:
    User:
      local: user
      foreign: id
      foreignAlias: PaymentMethods
      type: one

If I try setting one of his payment method and his default payment method…

$user = new User();

$paymentMethod = new PaymentMethod();
$paymentMethod->set('User',$user);

$user->set('DefaultPaymentMethod',$paymentMethod);

$user->save();

…this line

$user->set('DefaultPaymentMethod',$paymentMethod);

…deletes his payment method (so User of PaymentMethod isn’t set), when I try to save it.

Am I doing something wrong (logical issue) or is this a Doctrine bug?

  • 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-18T01:32:38+00:00Added an answer on June 18, 2026 at 1:32 am

    Why did you define the payment method twice?

    Your foreign key to PaymentMethod is payment_method. So, if you define it once, it’s ok.

    You can try that:

    $user = new User();
    
    $paymentMethod = new PaymentMethod();
    $paymentMethod->setUser($user);
    $paymentMethod->save();
    
    $user->setDefaultPaymentMethod($paymentMethod);
    $user->save();
    

    set method use the relation name to define the relation.

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

Sidebar

Related Questions

From this page: http://www.doctrine-project.org/documentation/manual/1_2/en/working-with-models#dealing-with-relations:creating-related-records You can see that it says $obj['property']; is the recommended
I'm trying to add user to my database through Doctrine 2.1 project and I'm
I have a Doctrine entity with array type field: /** * @ORM\Table() */ class
although I read through the manual here: http://www.doctrine-project.org/documentation/manual/1_2/hu/hierarchical-data I couldn't find a way to
We are using Doctrine 2 for a new project and have run into an
i am develping a project using symfony1.4.16 and Doctrine and for authentication i am
I have a Zend Framework project using version 1.10.8 with Doctrine 1.2.4.I use Zend_Auth
I have a Symfony2 project with a MySQL db: #app/config/config.yml doctrine: dbal: driver: %database_driver%
i wonder if Doctrine 2 is stable enough to use for a production project?
I'm currently working on a project with symfony 1.4 and Doctrine 1.2. I'm looking

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.