开发者

doctrine 2 manytoone relationship with custom field name

开发者 https://www.devze.com 2023-02-18 05:03 出处:网络
I\'m using Doctrine 2 to connect to and generate objects from a mysql database that is a shared backend to a filemaker application. As such, i cannot let Doctrine completely automate the table generat

I'm using Doctrine 2 to connect to and generate objects from a mysql database that is a shared backend to a filemaker application. As such, i cannot let Doctrine completely automate the table generation and need to customise the mapping from class property to db table fields. The following annotation, by default, maps to the table field 'pubofficeid_id'. I need it to map to 'pubofficeid'. Is this possible开发者_如何学运维? I can change anything in the annotation or the class property name.

/**
 * @ManyToOne (targetEntity="Hs_Profile_Staff", inversedBy="staffPubRelation", cascade={"persist"})
 */
public $pubofficeid;


The One-To-Many, Bidirectional example in the documentation spells it out pretty clearly.

class Feature
{
    // ...
    /**
     * @ManyToOne(targetEntity="Product", inversedBy="features")
     * @JoinColumn(name="product_id", referencedColumnName="id")
     */
    private $product;
    // ...
}
0

精彩评论

暂无评论...
验证码 换一张
取 消