I'm writing at the moment a fixture loader command, where i generate a mysql-database with orm.yml-files and loading database fixture afterwards. At the moment the loader command is working fine for tables with a simple primary key. But now I have a table, which consists of a composited primary key (of three columns). Two Columns ("id" and "language") are foreign keys to another tables (with a 1:n relationship).
I'm getting this error message, when I make the fixture loader command call:
Message: An exception occurred while executing 'INSERT INTO xyzInt (id, language, name, text, update, userID, complete) VALUES (?, ?, ?, ?, ?, ?, ?)' with params [null, "com", "peter", "text", "2017-03-06 18:00:00", 1, 0]:
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 'update, userID, complete) VALUES (NULL, 'com', 'peter', 'text', '2017-03-' at line 1
And my xyzInt.orm.yml looks like this:
Entity\Xyzint:
type: entity
table: xyzInt
id:
id: { type: integer, options: { default: 0, unsigned: true }, generator: { strategy: NONE } }
language: { type: string, length: 2, options: { default: '' }, generator: { strategy: NONE } }
name: { type: string, length: 30, options: { default: '' }, generator: { strategy: NONE } }
fields:
...
manyToOne:
Abc:
targetEntity: Abc
inversedBy: Xyzint
joinColumn:
name: id
referencedColumnName: abcID
And now i've got two questions:
- why is field "id" not set correctly (it remains null)?
- Is the manyToOne-correlation made correctly for a composite primary key? Or must i use "joinColumns" instead of "joinColumn"? And when i have to use "joinColumns" can you give me a short example, how the orm.yml-configuration should look like? I couldn't find the correct answer in google until now.
Thanxs for your help.