Doctrine - many to one; Populating many, can't use the constant "ones" on the DB. How to insert manually the FKs? <p>I have the following model:</p> <pre><code> class Word{ ........... /** * @ManyToOne(targetEntity="Language", cascade={"persist"}) * @JoinColumn(name="language_id", referencedColumnName="id") */ protected $language; .......................... } class Language{ /** * @Id * @Column(type="integer", nullable=false) * @GeneratedValue(strategy="AUTO") */ protected $id; /** * @Column(type="string", unique=true, nullable=false) */ protected $language; ........ } </code></pre> <p>I have 3 records in the database for 3 different languages. A language is unique. </p> <p>I fail to create a new word and link it to one of the existing languages. I.e. I would like to know how to set the FK of Word to the PK of the language. And since FKs in the model don't exists as int IDs but rather object references, I am confused on how to implement it. I tried to use a Doctrine_Query::create()-> ... but I also failed with that. </p> <p>I have tried this:</p> <pre><code> $this-&gt;em = $this-&gt;doctrine-&gt;em; $w = $this-&gt;input-&gt;post('word'); $d = $this-&gt;input-&gt;post('description'); $desclan = $this-&gt;input-&gt;post('desclan'); //language is selected from a drop down //list populated from the DB $wordlan = $this-&gt;input-&gt;post('wordlan'); $word = new Entity\Word; $description = new Entity\Description; $language = new Entity\Language; $language-&gt;setLanguage($wordlan); $language-&gt;setLanguageId($lanId); // assuming that $lanId is obtained from DB $word-&gt;setWord($w); $word-&gt;setLanguage($language); $description-&gt;setDescription($d); $word-&gt;setDescrp($description); $this-&gt;em-&gt;persist($word); $this-&gt;em-&gt;flush(); </code></pre> <p>The language is chosen by a drop-down-list. This code of course spits that the language already exists in the database. How do I simply get the ID of the language and put it as a FK language_id in the 'word' table in the database, through Doctrine code?</p> <p>Thank you in advance!</p>