I am working with Cakephp 3 and I would like to have a column called "before" in my Model.
Unfortunately, when I try to create and save an Entity, I got this error:
[PDOException] SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'before, after, created_at) VALUES (1047, 'blabla', 'toto', ' at line 1
What I did to create this entity is as usual:
$this->save(
$this->newEntity([
'tracker_id' => $trackerEntity->get('id'),
'before' => 'blabla',
'after' => $after,
'created_at' => new \DateTime(),
])
);
If I rename my column "before" to another name like "toto", it's working. A MYSQL function "before" exists, so I guess that's why PDO doesn't like it...
Has anyone a trick to still use a column with this name? Like a way to escape the function?
Thanks