sql - sonata admin bundle for an entity with keywords columns -


i used sonata admin bundle generate office entity have 2 columns sql keywords : from , to , forms , entities generated , works fine except adding new entity cos sql generated cannot accept from , to syntax in insert sql.

is there way avoid problem without changing columns names ?

here mapping

 /**  * @var \datetime  *  * @orm\column(name="`from`", type="datetime", nullable=false)  */ private $from;  /**  * @var \datetime  *  * @orm\column(name="`to`", type="datetime", nullable=false)  */ private $to; 

and here snippet code configureformfields method

        ->add('from', 'datetime', array('label' => 'du'))         ->add('to', 'datetime', array('label' => 'au')) 

the error :

an exception occurred while executing 'insert event (titre, ville, description, from, to, lat, lng, adresse, total, votes, isactive, refsouscategorie) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' params ["dfdfdf", "titre", "dfdfdf", "2009-01-01 00:00:00", "2009-01-01 00:00:00", "0", "0", "dddfgsgs", 0, 0, 1, 1]: 

sqlstate[42000]: syntax error or access violation: 1064 have error in sql syntax; check manual corresponds mysql server version right syntax use near 'from, to, lat, lng, adresse, total, votes, isactive, refsouscategorie) values ('' @ line 1

if using doctrine symfony can escape them using back-ticks around column names in entity

/**  * yourentity  *  * @orm\table(name="your_table")  * @orm\entity  */ class yourentity {  /**  * @var string  *  * @orm\column(name="`to`", type="string", length=25)  */ private $to;   /**  * @var string  *  * @orm\column(name="`from`", type="string", length=25)  */ private $from;  } 

note better if can alter schema , entity definition change names of column prevent usage of reserved keywords

identifier quoting not work join column names or discriminator column names unless using custom quotestrategy.

quoting reserved words


Comments

Popular posts from this blog

javascript - how to protect a flash video from refresh? -

visual studio 2010 - Connect to informix database windows form application -

android - Associate same looper with different threads -