简体   繁体   English

语义错误-找不到常量X,类…错误

[英]Semantical Error - Couldn't find constant X, class… ERROR

I am trying to implement category and subcategory structure entity, but I end up with this error when generating entity with command php app/console generate:doctrine:entities RFQIronilBundle : 我正在尝试实现类别和子类别结构实体,但是在使用命令php app/console generate:doctrine:entities RFQIronilBundle生成实体时,我最终遇到此错误:

  [Doctrine\Common\Annotations\AnnotationException]                            
  [Semantical Error] Couldn't find constant production, class RFQ\IronilBundl  
  e\Entity\ProductionType.

My created ProductionType entity: 我创建的ProductionType实体:

<?php

namespace RFQ\IronilBundle\Entity;

use Doctrine\ORM\Mapping as ORM;

/**
 * ProductionType
 *
 * @ORM\Table(production-type)
 * @ORM\Entity
 */
class ProductionType
{
    /**
     * @var integer
     *
     * @ORM\Column(name="id", type="integer")
     * @ORM\Id
     * @ORM\GeneratedValue(strategy="AUTO")
     */
    private $id;

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

    /**
     * @ORM\OneToMany(targetEntity="ProductionType", mappedBy="parent")
     **/
    protected $children;

    /**
     * @ORM\ManyToOne(targetEntity="ProductionType", inversedBy="children")
     * @ORM\JoinColumn(name="parent_id", referencedColumnName="id")
     **/
    protected $parent;

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

How to generate my entity and what could causes this error? 如何生成我的实体,什么会导致此错误? Thank you! 谢谢!

I think it's because you aren't using speech marks around your table name. 我认为这是因为您没有在表名周围使用语音标记。

@ORM\Table(production-type) // meant (constant) production minus (constant) type

where as you should use 应该在哪里使用

@ORM\Table("production-type")

And it may make more sense to use production_type to stop the need to quotation marks around the table name in MySQL statements. 而且,使用production_type停止在MySQL语句中在表名两边加上引号的需求可能更有意义。

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

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