Smarty Forum Index Smarty
The discussions here are for Smarty, a template engine for the PHP programming language.

Insertion du PHP dans smarty

 
Post new topic   Reply to topic    Smarty Forum Index -> Language: French
View previous topic :: View next topic  
Author Message
talalabd
Smarty n00b


Joined: 29 Sep 2015
Posts: 1

PostPosted: Tue Sep 29, 2015 5:00 pm    Post subject: Insertion du PHP dans smarty Reply with quote

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 &agrave; : '.$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
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Smarty Forum Index -> Language: French All times are GMT
Page 1 of 1

 
Jump to:  
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
Protected by Anti-Spam ACP