简体   繁体   English

关系ManyToMany,多余的字段被忽略

[英]Relationship ManyToMany, the extra field ignored

I have a problem certainly very stupid . 我的问题肯定很愚蠢。

I have 3 entities : activity , category and categorieActivite which the following codes : 我有3个实体:activity,category和categorieActivite,其中以下代码:

/**
 * Class Activite
 * @ORM\Entity
 * @ORM\Table(name="activite")
 */
 class Activite{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
* @ORM\Column(type="string",length=255)
*/
protected $nom;

/**
 * @ORM\OneToMany(targetEntity="CategorieActivite",mappedBy="activite")
 */
protected $categorieList;

 }


 class Categorie{
/**
 * @ORM\Id
 * @ORM\Column(type="integer")
 * @ORM\GeneratedValue(strategy="AUTO")
 */
protected $id;
/**
 * @ORM\Column(type="string",length=255)
 */
protected $nom;

/**
 * @ORM\OneToMany(targetEntity="CategorieActivite",mappedBy="categorie")
 */
protected $activiteList;
}


class CategorieActivite{


/**
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Categorie",inversedBy="activiteList")
 * @ORM\JoinColumn(name="categorie_id", referencedColumnName="id", nullable=false)
 */
protected $categorie;

/**
 * @ORM\Id
 * @ORM\ManyToOne(targetEntity="Activite",inversedBy="categorieList")
 * @ORM\JoinColumn(name="activite_id", referencedColumnName="id", nullable=false)
*/
protected $activite;

/**
 * ORM\Column(type="string",length=50)
 * @Assert\Choice(choices = {"Intense", "Douce", "Moyenne"}, message = "Veuillez choisir une valeur")
 * @Assert\NotNull()
 */
protected $intensite;

} }

So far all working properly. 到目前为止,一切工作正常。 But the problem is that the intensity of CategorieActivite entity does not appear in the database , there are only foreign keys that appear. 但是问题是CategorieActivite实体的强度没有出现在数据库中,只有外键出现。 Do you have an idea of the problem? 你对这个问题有想法吗?

Thank you in advance for your help. 预先感谢您的帮助。

Thibault. 蒂博。

On your $intensite property 在您的$ intensite属性上

* ORM\Column(type="string",length=50)

Should be: 应该:

* @ORM\Column(type="string",length=50)

Pretty sure that'll fix it for you. 可以肯定会为您解决。 You'll need to run a doctrine:migrations:diff once you fix the annotation. 修复注释后,您需要运行doctrine:migrations:diff。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM