2014-07-24 39 views
2

我想实现类别和子类别结构实体,但命令php app/console generate:doctrine:entities RFQIronilBundle发电实体,当我结束了这个错误:语义错误 - 找不到固定X,类...错误

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

我创建的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; 
    } 
} 

如何生成我的实体以及可能导致此错误的原因是什么? 谢谢!

回答

3

我认为这是因为您没有在表名称周围使用语音标记。

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

哪里,你应该使用

@ORM\Table("production-type") 

而且它可能更合理使用production_type停止需要周围的表名引号在MySQL语句。

+0

是的,那是我愚蠢的错误!有时我看不到语法错误,但我很高兴有程序员可以帮忙。谢谢! – RydelHouse

+0

新鲜的眼睛,就是这样。 – qooplmao