4
我正嘗試將多對一關聯添加到供應商捆綁中的現有實體。使用yml配置向現有供應商捆綁實體添加新字段
這是我在廠商捆綁實體: -
class Post
{
private $id;
private $title;
private $accroche;
private $article;
private $categories;
private $comments;
private $created;
private $updated;
private $publied;
}
而且,這是在供應商捆綁的後實體的ORM映射文件: -
Mv\BlogBundle\Entity\AdminBlog\Post:
type: entity
table: null
repositoryClass: Mv\BlogBundle\Entity\AdminBlog\PostRepository
id:
id:
type: integer
generator:
strategy: AUTO
fields:
title:
type: string
length: 150
accroche:
type: text
article:
type: text
created:
type: datetime
gedmo:
timestampable:
on: create
updated:
type: datetime
gedmo:
timestampable:
on: update
publied:
type: datetime
manyToMany:
categories:
targetEntity: Mv\BlogBundle\Entity\AdminBlog\Category
inversedBy: posts
joinTable:
name: post_category
joinColumns:
post_id:
referencedColumnName: id
onDelete: CASCADE
inverseJoinColumns:
category_id:
referencedColumnName: id
onDelete: RESTRICT
oneToMany:
comments:
targetEntity: Mv\BlogBundle\Entity\AdminBlog\Comment
mappedBy: post
我創建的子束我供應商捆綁。我研究了mappedSuperclass並嘗試了其他繼承方法。但他們沒有一個人只是將一個關聯添加到「發佈」實體。
我只是希望能有類似如下(嘗試添加它ORM映射文件,但不工作): -
manyToOne:
user:
targetEntity: TP\Bundle\MainBundle\Entity\User
joinColumns:
user_id:
referencedColumnName: id