Unidirectional OneToMany in Doctrine 2

Posted by darja on Stack Overflow See other posts from Stack Overflow or by darja
Published on 2010-04-14T10:56:01Z Indexed on 2010/04/20 1:03 UTC
Read the original article Hit count: 303

Filed under:
|

I have two Doctrine entities looking like that:

/**
 * @Entity
 * @Table(name = "Locales")
 */
class Locale
{
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /** @Column(length=2, name="Name", type="string") */
    private $code;
}

/**
 * @Entity
 * @Table(name = "localized")
 */
class LocalizedStrings
{
    /**
     * @Id @Column(type="integer")
     * @GeneratedValue(strategy="IDENTITY")
     */
    private $id;

    /** @Column(name="Locale", type="integer") */
    private $locale;

    /** @Column(name="SomeText", type="string", length=300) */
    private $someText;
}

I'd like to create reference between these entities. LocalizedStrings needs reference to Locale but Locale doesn't need reference to LocalizedStrings. How to write such mapping via Doctrine 2?

© Stack Overflow or respective owner

Related posts about php

Related posts about doctrine