Symfony2 Doctrine: syntax error, unexpected "function" expecting "id"

I am working with symfony2 and I am using Doctrine to create entities from an existing database. Everything seems to be going fine except for this syntax error:

syntax error, unexpected "function" expecting "identifier"

I have been looking for a solution and it seems to be causing a typo most of the time. But this code is generated by Doctrine and I don't see any typos ... Here is the class where the error appears, specifically in "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;


}

      

+3


source to share


2 answers


In fact, thanks to quoting, you can use it regardless of what it is 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
 {

      

+2


source


OK I was not allowed to use a Function as a table name. Changed this and everything that works now.



0


source







All Articles