[ADOdb] a foreign key constraint fails
Bonjour,
J'utilise ADOdb.
J'ai une table définie comme suit :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| CREATE TABLE `article` (
`article_id` int(11) NOT NULL AUTO_INCREMENT,
`title` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`slug` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`keywords` varchar(255) COLLATE utf8_unicode_ci DEFAULT NULL,
`body` mediumtext COLLATE utf8_unicode_ci NOT NULL,
`parent_id` int(11) DEFAULT NULL,
`template` varchar(255) COLLATE utf8_unicode_ci NOT NULL,
`publication_date` date NOT NULL,
`expiration_date` date DEFAULT NULL,
`is_published` int(11) NOT NULL DEFAULT '0',
`created_at` date NOT NULL,
`updated_at` date NOT NULL,
PRIMARY KEY (`article_id`),
KEY `parent_id` (`parent_id`),
CONSTRAINT `article_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `article` (`article_id`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci; |
La colonne parent_id est supposée accepter des valeurs NULL :
Code:
`parent_id` int(11) DEFAULT NULL,
D'autre part j'ai indiqué à ADOdb de forcer la valeur à NULL pour les chaînes vides :
Code:
$ADODB_FORCE_TYPE=1;
Or la requête suivante provoque une erreur :
Citation:
(mysql): INSERT INTO article ( TITLE, SLUG, KEYWORDS, BODY, PARENT_ID, TEMPLATE, PUBLICATION_DATE, EXPIRATION_DATE, IS_PUBLISHED, CREATED_AT, UPDATED_AT ) VALUES ( 'Article de test 3', 'article_de_test_3', '', 'Ceci est un test', 0, 'article_show_blue.tpl.html', '2010-12-12', null, 1, '2011-05-15 17:08:37', '2011-05-15 17:08:37' )
Citation:
1452: Cannot add or update a child row: a foreign key constraint fails (`bluebird`.`article`, CONSTRAINT `article_ibfk_1` FOREIGN KEY (`parent_id`) REFERENCES `article` (`article_id`))
Comme la documentation de ADOdb est vague, quelqu'un sait-il comment il faut positionner la valeur $ADODB_FORCE_TYPE ?