Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Symfony2 Doctrine: syntax error, unexpected 'function', expecting 'identifier'

I'm working with symfony2 and I'm using Doctrine to create entities from an existing Database. It seems like everything goes fine except this Syntax Error:

syntax error, unexpected 'function', expecting 'identifier'

I've been searching for a solution and it seems most of the time a typo is the cause. But this code is all being generated by Doctrine and I'm not seeing any typo's ... Here is the class where the error is showing up, specifically at '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;


}
like image 765
Matthias Avatar asked Jun 20 '26 12:06

Matthias


1 Answers

Actually thanks to quoting, you can use it regardless of it being a reserved word: http://doctrine-orm.readthedocs.org/en/latest/reference/basic-mapping.html#quoting-reserved-words

/**
 * Function
 *
 * @ORM\Table(name="`Function`")
 * @ORM\Entity
 */
 class Function
 {
like image 182
Diego Ferri Avatar answered Jun 23 '26 01:06

Diego Ferri



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!