Impossible de créer des tables liées via php ?
Bonjours, j'ai un problème étrange...
Voilà, j'ai un système de module dans mon appli php. Quand j'ajoute un module, j'exécute un fichier contenant les tables sql à créer.
Les tables sans clés étrangères ne pause pas de problème, mais vous l'aurez deviné, c'est pas le cas avec.
Pourtant dans phpMyAdmin, tout ce passe nickel , avec ou sans clés.
voici les tables et la commande:
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25
|
CREATE TABLE IF NOT EXISTS `text_template` (
`id_text_template` varchar(20) NOT NULL,
`label` varchar(200) NOT NULL,
PRIMARY KEY (`id_text_template`)
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `text_panel` (
`id_panel` int(11) NOT NULL,
`id_text_template` varchar(20) NULL,
`content` longtext NOT NULL,
PRIMARY KEY (`id_panel`),
FOREIGN KEY (`id_panel`) REFERENCES `panel` (`id_panel`) ON DELETE CASCADE,
FOREIGN KEY (`id_text_template`) REFERENCES `text_template` (`id_text_template`) ON UPDATE CASCADE
) ENGINE=InnoDB;
CREATE TABLE IF NOT EXISTS `text_component` (
`id_text_component` int(1) NOT NULL,
`id_text_template` varchar(20) NULL,
`sound` varchar(300) NULL,
`mute` tinyint(1) NOT NULL,
PRIMARY KEY (`id_text_component`),
FOREIGN KEY (`id_text_template`) REFERENCES `text_template` (`id_text_template`) ON UPDATE CASCADE
) ENGINE=InnoDB; |
Code:
$this->exec(file_get_contents('component/text/install.txt'));
Une idée du pourquoi php ou mysql refuse de créer les tables??