duange051858 2017-06-11 05:17
浏览 25
已采纳

Symfony 3.3模式验证错误

I have two entities as follows:

<?php
// src/coreBundle/Entity/model.php
namespace coreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use coreBundle\Entity\brand;

/**
*@ORM\Entity
*@ORM\Table(name="model")
*/
class model
{
    /**
    * @ORM\ManyToOne(targetEntity="coreBundle\Entity\brand", inversedBy="models")
    * @ORM\JoinColumn(name="brand_id", referencedColumnName="id")
    */
    private $brands;


    /**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
    public $id;

/**
    *@ORM\Column(type="integer")
    */
    public $brand_id;


    /**
    *@ORM\Column(type="string", length=100)
    */
    private $name;

    /**
    *@ORM\Column(type="string", length=100)
    */
    private $image_url;

    /**
    *@ORM\Column(type="string", length=200)
    */
    private $comment;

    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set brandId
     *
     * @param integer $brandId
     *
     * @return model
     */
    public function setBrandId($brandId)
    {
        $this->brand_id = $brandId;

        return $this;
    }

    /**
     * Get brandId
     *
     * @return integer
     */
    public function getBrandId()
    {
        return $this->brand_id;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return model
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * Set imageUrl
     *
     * @param string $imageUrl
     *
     * @return model
     */
    public function setImageUrl($imageUrl)
    {
        $this->image_url = $imageUrl;

        return $this;
    }

    /**
     * Get imageUrl
     *
     * @return string
     */
    public function getImageUrl()
    {
        return $this->image_url;
    }

    /**
     * Set comment
     *
     * @param string $comment
     *
     * @return model
     */
    public function setComment($comment)
    {
        $this->comment = $comment;

        return $this;
    }

    /**
     * Get comment
     *
     * @return string
     */
    public function getComment()
    {
        return $this->comment;
    }



    /**
     * Set brands
     *
     * @param \coreBundle\Entity\brand $brands
     *
     * @return model
     */
    public function setBrands(\coreBundle\Entity\brand $brands = null)
    {
        $this->brands = $brands;

        return $this;
    }

    /**
     * Get brands
     *
     * @return \coreBundle\Entity\brand
     */
    public function getBrands()
    {
        return $this->brands;
    }
}

And Second one is as follows:

<?php
// src/coreBundle/Entity/brand.php
namespace coreBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
use coreBundle\Entity\model;
use Doctrine\Common\Collections\ArrayCollection;

/**
*@ORM\Entity
*@ORM\Table(name="brand")
*/
class brand
{
    /**
     * ORM\OneToMany(targetEntity="coreBundle\Entity\model", mappedBy="brands")
     */
    private $models;
    public function __construct()
    {
        $this->models = new ArrayCollection();
    }

    /**
* @ORM\Column(type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
public $id;

    /**
    *@ORM\Column(type="string", length=100)
    */
    private $name;



    /**
     * Get id
     *
     * @return integer
     */
    public function getId()
    {
        return $this->id;
    }

    /**
     * Set name
     *
     * @param string $name
     *
     * @return brand
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }

    /**
     * Get name
     *
     * @return string
     */
    public function getName()
    {
        return $this->name;
    }
}

"model" has a ManyToOne relationship with "brand"

I am having issues of schema validation,

*The association coreBundle\Entity\model#brands refers to the inverse side field coreBundle\Entity\brand#models which does not exist

Can you tell what am I doing wrong, Thanks in advance.

  • 写回答

1条回答 默认 最新

  • doushu0591 2017-06-11 08:18
    关注

    In case your still wondering after 3 hours of agony, your missing the @ in @ORM\OneToMany (brand.php).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂
  • ¥15 wordpress 产品图片 GIF 没法显示
  • ¥15 求三国群英传pl国战时间的修改方法
  • ¥15 matlab代码代写,需写出详细代码,代价私
  • ¥15 ROS系统搭建请教(跨境电商用途)
  • ¥15 AIC3204的示例代码有吗,想用AIC3204测量血氧,找不到相关的代码。