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 26 27
| try {
$sql_1 = "
INSERT INTO `t_diaporama` (`fichier`, `legende`, `active`, `etablissement_id`, `datetime_creation`, `login_creation`)
VALUES (:fichier, :legende, :active, :etablissement_id, :datetime_creation, :login_creation)
";
$sql_2 = "
INSERT INTO `t_diaporama` (`fichier`, `legende`, `active`, `etablissement_id`, `datetime_creation`, `login_creation`)
VALUES (:fichier, :legende, FALSE, :etablissement_id, :datetime_creation, :login_creation)
";
$sth = $cnxPDO->prepare($sql_1);
$sth->bindParam(':fichier', $fichier, PDO::PARAM_STR, 40);
$sth->bindParam(':legende', $legende, PDO::PARAM_STR, 100);
$sth->bindParam(':active', FALSE, PDO::PARAM_BOOL);
$sth->bindParam(':etablissement_id', $etablissement_id, PDO::PARAM_INT);
$sth->bindParam(':datetime_creation', date("Y-m-d H:i:s"));
$sth->bindParam(':login_creation', $session_login);
$success = $sth->execute();
if ($success === FALSE) {
die("<p>ERREUR : L'ajout a retourné une erreur.</p>");
} else {
echo("<p>OK</p>");
}
} catch (PDOException $e) {
die("<p>ERREUR : Erreur PDO pendant l'ajout :<br />" . $e->getMessage() ."</p>");
} |
Partager