Bonjour et meilleurs vœux à tous.
J'ai la fonction suivante:avec la structure de table suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 function insertMarriage(array $data): string|false { $db = dbConnect(); $sql = <<<SQL INSERT IGNORE INTO dat_marriages (id_m, id_f, marriageyear, marriagemonth, marriageday, marriageplace, divorceyear, divorcemonth, divorceday, divorceplace, marriage_order_m, marriage_order_f) VALUES(:id_m, :id_f, :marriageyear, :marriagemonth, :marriageday, :marriageplace, :divorceyear, :divorcemonth, :divorceday, :divorceplace, :marriage_order_m, :marriage_order_f) SQL; $stmt = $db->prepare($sql); $stmt->execute($data); return $db->lastInsertId(); }Qui me retourne l'erreur suivante:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 `dat_marriages` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT 'marriagekey', `id_m` int(10) UNSIGNED NOT NULL COMMENT 'man''s key', `id_f` int(10) UNSIGNED NOT NULL COMMENT 'woman''s key', `marriageyear` char(4) DEFAULT NULL, `marriagemonth` char(2) DEFAULT NULL, `marriageday` char(2) DEFAULT NULL, `marriageplace` char(40) DEFAULT NULL, `divorceyear` char(4) DEFAULT NULL, `divorcemonth` char(2) DEFAULT NULL, `divorceday` char(2) DEFAULT NULL, `divorceplace` varchar(40) DEFAULT NULL, `marriage_order_m` tinyint(2) DEFAULT NULL COMMENT 'lit M', `marriage_order_f` tinyint(2) DEFAULT NULL COMMENT 'lit F', `create_date` datetime DEFAULT CURRENT_TIMESTAMP, `update_date` datetime DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), UNIQUE KEY `clefsCjts` (`id_m`,`id_f`), KEY `clefM` (`id_m`), KEY `clefF` (`id_f`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; ALTER TABLE `dat_marriages` ADD CONSTRAINT `dat_marriages_ibfk_1` FOREIGN KEY (`id_f`) REFERENCES `dat_persons` (`id`) ON DELETE CASCADE ON UPDATE CASCADE, ADD CONSTRAINT `dat_marriages_ibfk_2` FOREIGN KEY (`id_m`) REFERENCES `dat_persons` (`id`) ON DELETE CASCADE ON UPDATE CASCADE;
J'ai tout vérifié: le contenu des deux tableaux du message d'erreur que j'ai comparé avec la structure de la table et je ne vois pas d'erreur. Est-ce que quelqu'un y verrait plus clair que moi?( ! ) Fatal error: Uncaught PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp64\www\proginet\appGenealium\model\model.php on line 315 ( ! ) PDOException: SQLSTATE[HY093]: Invalid parameter number: parameter was not defined in C:\wamp64\www\proginet\appGenealium\model\model.php on line 315 Call Stack # Time Memory Function Location 1 0.0023 378520 {main}( ) ...\formHandler.php:0 2 0.0085 400360 insertMarriage( $data = ['man' => '1613', 'woman' => '238', 'marriageday' => NULL, 'marriagemonth' => NULL, 'marriageyear' => NULL, 'marriageplace' => 'Strasbourg', 'divorceday' => NULL, 'divorcemonth' => NULL, 'divorceyear' => NULL, 'divorceplace' => NULL, 'marriage_order_m' => NULL, 'marriage_order_f' => NULL] ) ...\formHandler.php:219 3 0.0233 447232 execute( $params = ['man' => '1613', 'woman' => '238', 'marriageday' => NULL, 'marriagemonth' => NULL, 'marriageyear' => NULL, 'marriageplace' => 'Strasbourg', 'divorceday' => NULL, 'divorcemonth' => NULL, 'divorceyear' => NULL, 'divorceplace' => NULL, 'marriage_order_m' => NULL, 'marriage_order_f' => NULL] ) ...\model.php:315
Partager