3

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;


}
2
  • how about trying some other class name? 'function' is reserved word in php and by definition you shouldn't use those as class name Commented Jul 22, 2015 at 8:43
  • Ok that was the reason! Solved it. Thanks for help. Commented Jul 22, 2015 at 9:01

2 Answers 2

2

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
 {
Sign up to request clarification or add additional context in comments.

Comments

0

Ok I wasn't allowed to use 'Function' as a table name .. Changed it and everything working now.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.