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

  • Home
  • SEARCH
  • 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 6100535
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T13:23:52+00:00 2026-05-23T13:23:52+00:00

i finally set up my mapping for my two tables, i can now join

  • 0

i finally set up my mapping for my two tables, i can now join tables via the querybuilder..

however, i cant add data to the join column, its keeps saying null.

my account entity:

namespace Entities\Users;

/**
 * @Entity(repositoryClass="\Entities\Users\Account")
 * @Table(name="account")
 * @HasLifecycleCallbacks
 */
class Account extends \Entities\AbstractEntity {

    /**
     * @Id @Column(name="accid", type="bigint",length=15)
     * @GeneratedValue(strategy="AUTO")
     */
    protected $accid;

    /** @Column(name="name", type="string", length=255) */
    protected $name;  

    /** @Column(name="profileid", type="integer", length=255) */
    protected $profileid; 


    /** @Column(name="acc_added_date", type="datetime", columnDefinition="datetime", nullable=true) */
    private $acc_added_date;

    /**
     * @ManyToOne(targetEntity="Profiledetails")
     * @JoinColumn(name="profileid", referencedColumnName="pid") 
     */
    private $account;

and my profiledetails entity:

namespace Entities\Users;

/**
 * @Entity(repositoryClass="\Entities\Users\Profiledetails")
 * @Table(name="profiledetails")
 * @HasLifecycleCallbacks
 */
class Profiledetails extends \Entities\AbstractEntity {

    /**
     * @Id @Column(name="pid", type="bigint",length=15)
     * @GeneratedValue(strategy="AUTO")
     */
    protected $accid;
    /** @Column(name="name", type="string", length=255) */
    protected $name;
    /** @Column(name="profileid", type="integer", length=255) */
    protected $profileid;
    /** @Column(name="acc_added_date", type="datetime", columnDefinition="datetime", nullable=true) */
    private $acc_added_date;
    /**
     * @OneToMany(targetEntity="Account", mappedBy="account")
     * @JoinColumn(name="pid", referencedColumnName="pid")
     */
    private $stances;

i use to use :

    $postdata array ('name'=>'jason');
    $entity =new \Entities\Users\Account;
    $obj->setData($postdata);

    $this->_doctrine->persist($obj);
    $this->_doctrine->flush();
    $this->_doctrine->clear();

and it doesnt add.. what the way to add data to the parent table where all linked tables get updated? because before i could enter a profileid and now its null because i used it as a the joined column..

  • 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-23T13:23:53+00:00Added an answer on May 23, 2026 at 1:23 pm

    Linked objects can be “updated” if you setup cascade=[persist] in your relationship definitions. You also need @mappedBy and @inversedBy to be set for both sides of the relations. Basically @mappedBy is set to the oneToMany side (called inverse side) and @inversedBy to the manyToOne side (called owning side)

    http://www.doctrine-project.org/docs/orm/2.0/en/reference/association-mapping.html#one-to-many-bidirectional

    The proper way is basically

    //assume $this->_doctrine is instance of EntityManager
    $user = new User();
    $user->setEmail('john@example.com');
    $account = new Account();
    $account->setName('john');
    $account->setUser($user);
    $user->addAccount($account); //if no cascade set
    $this->_doctrine->persist($account); 
    $this->_doctrine->persist($user); //if no cascade set
    $this->_doctrine->flush();
    

    http://www.doctrine-project.org/docs/orm/2.0/en/reference/working-with-associations.html#establishing-associations

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

Sidebar

Related Questions

I'm finally set up to be able to work from home via VPN (using
After many problems, I have finally set up Roo with a simple example. Now
How can I set the column's type to nvarchar(160)? I'm having a hard time
I finally let windows nag me into upgrading from IE6 to 8. Now in
I'm finally getting my team to embrace source code management now that we're working
Given the following mapping <class name=com.domain.Season table=cm.pub.jsn_mstr> <id name=seasonCode column=season_code length=1/> <property name=name type=string
In any programming environment,what ever the data type I am going to choose finally
I am trying to set up try/catch/finally to behave like if/else. I am not
I finally solved one problem but now i have another. I found out how
I recently posted about issues with encrypting large data with RSA, I am finally

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.