|
Smarty
WARNING: All discussion is moving to https://reddit.com/r/smarty, please go there! This forum will be closing soon. |
|
View previous topic :: View next topic |
Author |
Message |
talalabd Smarty n00b
Joined: 29 Sep 2015 Posts: 1
|
Posted: Tue Sep 29, 2015 5:00 pm Post subject: Insertion du PHP dans smarty |
|
|
Bonjour,
Je souhaite inserer du code PHP dans mon fichier tpl et je sais pas comment faire, des pistes SVP
Voila mon code
----
<?php
try {
$conn= new PDO("mysql:dbname=counter;host=localhost" , "root", "",array(PDO::ATTR_ERRMODE,PDO::ERRMODE_EXCEPTION));
$find_counts = null;
$find_counts = $conn->query('SELECT counts FROM user_count');
echo '<br>DEBUT WHILE';
//cas d'un retour vide
if (!is_null($find_counts) && $find_counts !== FALSE) {
$row = $find_counts->fetch();
}
echo '<br>Compteur à : '.$row['counts'];
$update_count = "UPDATE user_count SET counts= counts + 1";
$stmt = $conn->prepare($update_count);
if (!$stmt->execute()) {
echo '<br>ERREUR';
throw PDOException('ERREUR PDO TUTU',100);
} else {
echo '<br>Compteur modifie';
}
echo '<br>FIN WHILE';
} catch(PDOException $pdoE) {
//CATCH ERREURS PDO
die('Erreur:' .$pdoE->getMessage());
} catch(Exception $e) {
//CATCH TOUTE ERREURS
die('Erreur:' .$e->getMessage());
}
?>
----
Merci d'avance |
|
Back to top |
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|