Php 条令分配错误:无法将条令\ORM\PersistentCollection分配给属性
我有一个上传,我想从那里显示数据库中的所有类别,但我不断得到EntityType的错误,我不知道以前为什么工作 这是错误:Php 条令分配错误:无法将条令\ORM\PersistentCollection分配给属性,php,symfony,doctrine-orm,Php,Symfony,Doctrine Orm,我有一个上传,我想从那里显示数据库中的所有类别,但我不断得到EntityType的错误,我不知道以前为什么工作 这是错误:无法将条令\ORM\PersistentCollection分配给属性App\Entity\Category::$posts of type条令\Common\Collections\ArrayCollection $this->$posts[]=$posts 看起来这行应该是: $this->$posts[]=$post经过一番挖掘,a找到了答案,将ArrayCollect
无法将条令\ORM\PersistentCollection分配给属性App\Entity\Category::$posts of type条令\Common\Collections\ArrayCollection
$this->$posts[]=$posts代码>
看起来这行应该是:
$this->$posts[]=$post代码>经过一番挖掘,a找到了答案,将ArrayCollection更改为Collection修复了我的问题
change:
/**
* @ORM\OneToMany(targetEntity=Post::class, mappedBy="Category_id")
*/
private \Doctrine\Common\Collections\ArrayCollection $posts;
to:
/**
* @ORM\OneToMany(targetEntity=Post::class, mappedBy="Category_id")
*/
private \Doctrine\Common\Collections\Collection $posts;
是的,谢谢,但还是一样的错误