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
:
[Doctrine\Common\Annotations\AnnotationException]
[Semantical Error] Couldn't find constant production, class RFQ\IronilBundl
e\Entity\ProductionType.
My created ProductionType entity:
<?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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With