Ryd*_*use 4 php entity-framework symfony doctrine-orm
我正在尝试实现类别和子类别结构实体,但在使用命令生成实体时最终出现此错误php app/console generate:doctrine:entities RFQIronilBundle:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] Couldn't find constant production, class RFQ\IronilBundl
e\Entity\ProductionType.
Run Code Online (Sandbox Code Playgroud)
我创建的 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;
}
}
Run Code Online (Sandbox Code Playgroud)
如何生成我的实体以及可能导致此错误的原因?谢谢!
我认为这是因为您没有在表格名称周围使用语音标记。
@ORM\Table(production-type) // meant (constant) production minus (constant) type
Run Code Online (Sandbox Code Playgroud)
你应该在哪里使用
@ORM\Table("production-type")
Run Code Online (Sandbox Code Playgroud)
并且production_type在 MySQL 语句中使用停止需要在表名周围加上引号可能更有意义。