【问题标题】:Semantical Error: Class Entity has no field or association named语义错误:类实体没有名为的字段或关联
【发布时间】:2017-04-16 07:16:27
【问题描述】:

我想在我的数据库中添加新字段,并在我的 Doctrine 实体中使用它。我使用了另一个字段,但是我不能在我的选择查询中使用新的字段。这是我的表的字段:

Food (food_id, food_status, food_name)

我添加了新字段(food_sort -integer 10 unsigned)

这是我的实体:(我在我的实体中添加了新字段)

class Food extends BaseEntity
{

 .
 .
 .
     * @var integer
     *
     * @ORM\Column(name="food_sort" , type="integer",  nullable=false)
     */
    protected $foodSort;

    /**
     * Get foodSort
     *
     * @return integer
     */
    public function getFoodSort():int
    {
        return $this->foodSort;
    }

    /**
     * Set foodSort
     *
     * @param integer $foodSort
     *
     * @return Foods
     */
    public function setFoodSort(int $foodSort)
    {
        $this->foodSort = $foodSort;

        return $this;
    }
.
.
.    

}

实际上,当我想选择餐桌时,我遇到了语义错误。

[语义错误]错误:App\Core\Model\Entities\Food 类没有名为 foodSort 的字段或关联

每当我从我的选择中删除此字段时,都可以。

有什么解决办法吗?

【问题讨论】:

  • 你好,你更新你的架构了吗? php bin/console doctrine:schema:update --force ?

标签: mysql symfony doctrine-orm


【解决方案1】:

在 laravel 中解决

php artisan doctrine:clear:metadata:cache

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-09-15
    • 1970-01-01
    • 2013-04-24
    • 2014-05-31
    • 1970-01-01
    相关资源
    最近更新 更多