Symfony2 Doctrine:语法错误,意外 'function',预期 'identifier'
Symfony2 Doctrine: syntax error, unexpected 'function', expecting 'identifier'
我正在使用 symfony2,我正在使用 Doctrine 从现有数据库创建实体。似乎一切正常,除了这个语法错误:
语法错误,意外 'function',预期 'identifier'
我一直在寻找解决方案,但似乎大部分时间都是拼写错误造成的。但是这段代码都是由 Doctrine 生成的,我没有看到任何错字......
这是出现错误的 class,特别是 'Class Function':
<?php
namespace IntoPeople\DatabaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Function
*
* @ORM\Table(name="Function")
* @ORM\Entity
*/
class Function
{
/**
* @var string
*
* @ORM\Column(name="Name", type="string", length=250, nullable=false)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="Id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
}
好的,我不允许使用 'Function' 作为 table 名称。更改它,现在一切正常。
其实多亏了引用,不管是不是保留字都可以使用:http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words
/**
* Function
*
* @ORM\Table(name="`Function`")
* @ORM\Entity
*/
class Function
{
我正在使用 symfony2,我正在使用 Doctrine 从现有数据库创建实体。似乎一切正常,除了这个语法错误:
语法错误,意外 'function',预期 'identifier'
我一直在寻找解决方案,但似乎大部分时间都是拼写错误造成的。但是这段代码都是由 Doctrine 生成的,我没有看到任何错字...... 这是出现错误的 class,特别是 'Class Function':
<?php
namespace IntoPeople\DatabaseBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Function
*
* @ORM\Table(name="Function")
* @ORM\Entity
*/
class Function
{
/**
* @var string
*
* @ORM\Column(name="Name", type="string", length=250, nullable=false)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="Id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
}
好的,我不允许使用 'Function' 作为 table 名称。更改它,现在一切正常。
其实多亏了引用,不管是不是保留字都可以使用:http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words
/**
* Function
*
* @ORM\Table(name="`Function`")
* @ORM\Entity
*/
class Function
{