Morning,
I'm having some trouble creating tables/loading fixtures.
(symfony 1.4.6 with the bundled Doctrine 1.2.3(?))
Tables (simplified):
Horseman:
tableName: Horseman
actAs: { Timestampable: ~ }
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
name: { type: string(100), notnull: true }
Stable:
tableName: Stable
actAs: { Timestampable: ~ }
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
info: { type: clob }
id_owner: { type: integer(4), unsigned: true }
relations:
Horseman: { local: id_owner, foreign: id }
Horses:
tableName: Horses
actAs: { Timestampable: ~ }
columns:
id: { type: integer(4), primary: true, autoincrement: true, unsigned: true }
name: { type: string(100), notnull: true }
id_owner: { type: integer(4), unsigned: true }
id_stable: { type: integer(4), unsigned: true }
relations:
Horseman: { local: id_owner, foreign: id }
Stable: { local: id_stable, foreign: id }
"Horseman" doesn't have any dependencies
"Stable" has one "Horseman"
"Horses" has one "Horseman" and one "Stable"
demirbaşlar:
Horseman:
Hector:
name: Hector
Stable:
StableA:
info: Lorem Ipsum Dolor Sit Amet
id_owner: Hector
Horses:
Ed:
name: Ed
id_owner: Hector
id_stable: StableA
When Inserting the demirbaşlar:
$ php symfony doctrine:build --all --and-load
i bir kısıtlama ihlali olsun:
SQLSTATE[23000]: Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails (`issuetracker/Stable`, CONSTRAINT `Stable_id_owner_Horseman_id` FOREIGN KEY (`id_owner`) REFERENCES `Horseman` (`id`))
The "Horseman" entry gets inserted without a problem.
Inserting the other two entries by hand is not a problem either:
INSERT INTO Stable (id,info,id_owner,created_at,updated_at) VALUES (null,"foo",1,NOW(),NOW())
INSERT INTO Horses (id,name,id_owner,id_stable,created_at,updated_at) VALUES (null,"foo",1,1,NOW(),NOW())
(Does symfony save the created insert statements somewhere?)
If i get it right, Doctrine should take care of inserting orders by itself(?) Since I'm giving the correct order anyways that shouldn't be the problem..
In the hope that i just didn't see or didn't get a small thing, would one of you nice guys tell me why i get that constraint violation and/or how to fix it, pretty please..
Thanks.