Bonjour,
Je comprends le message d'erreur mais je ne trouve pas où elle est.Le var_dump() de la ligne 5 donne:
Code php : 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 function insertBook(array $data): false|string { $db = dbConnect(); extract($data); var_dump($data); $sql = <<<SQL INSERT IGNORE INTO dat_books (title, id_author, id_publisher, id_theme, id_public, id_place, format, comment) VALUES(:title, :author, :publisher, :theme, :public, :place, :format, :comment) SQL; $params = [':title'=>$title, ':author'=>$author, ':publisher'=>$publisher, ':theme'=>$theme, ':public'=>$public, ':place'=>$place, ':format'=>$format, 'comment:'=>$comment, ]; $stmt = $db->prepare($sql); $stmt->execute($params); return $db->lastInsertId(); }array (size=8) 'title' => string 'Coucou' (length=6) 'author' => string '1' (length=1) 'publisher' => string '1' (length=1) 'theme' => string '' (length=0) 'public' => string '' (length=0) 'place' => string '' (length=0) 'format' => string '' (length=0) 'comment' => string '' (length=0)
Code SQL : 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 CREATE TABLE IF NOT EXISTS `dat_books` ( `id` int(10) UNSIGNED NOT NULL AUTO_INCREMENT, `title` varchar(50) NOT NULL, `id_author` int(10) UNSIGNED DEFAULT NULL, `id_publisher` int(10) UNSIGNED DEFAULT NULL, `id_place` int(10) UNSIGNED DEFAULT NULL, `id_public` int(10) UNSIGNED DEFAULT NULL, `id_theme` int(10) UNSIGNED DEFAULT NULL, `format` varchar(30) DEFAULT NULL, `comment` text NOT NULL, `update_date` datetime NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP, PRIMARY KEY (`id`), KEY `id_auteur` (`id_author`), KEY `id_editeur` (`id_publisher`), KEY `id_place` (`id_place`), KEY `id_theme` (`id_theme`), KEY `id_public` (`id_public`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Partager