Fatal error
Fermé
papyclic
Messages postés
446
Date d'inscription
mercredi 5 novembre 2014
Statut
Membre
Dernière intervention
18 octobre 2016
-
26 nov. 2014 à 19:37
papyclic Messages postés 446 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 18 octobre 2016 - 27 nov. 2014 à 00:02
papyclic Messages postés 446 Date d'inscription mercredi 5 novembre 2014 Statut Membre Dernière intervention 18 octobre 2016 - 27 nov. 2014 à 00:02
3 réponses
jordane45
Messages postés
38472
Date d'inscription
mercredi 22 octobre 2003
Statut
Modérateur
Dernière intervention
5 mai 2025
4 744
26 nov. 2014 à 23:10
26 nov. 2014 à 23:10
Bonsoir,
Tu pourrais mettre la fonction _construct de ta class et nous indiquer si tu fais un EXTEND de PDO ?
Tu pourrais mettre la fonction _construct de ta class et nous indiquer si tu fais un EXTEND de PDO ?
papyclic
Messages postés
446
Date d'inscription
mercredi 5 novembre 2014
Statut
Membre
Dernière intervention
18 octobre 2016
3
26 nov. 2014 à 23:45
26 nov. 2014 à 23:45
Bonjour
Voici ma class
Merci
Voici ma class
class Database extends PDO { public function __construct() { try { parent::__construct('mysql:host=' . Config::HOTE . ';dbname=' . Config::DBNAME, Config::USERNAME, Config::PASSWORD); $this->exec("SET CHARACTER SET utf8"); $this->setAttribute(PDO::ATTR_DEFAULT_FETCH_MODE, PDO::FETCH_ASSOC); $this->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_WARNING); } catch(Exception $e) { echo 'Impossible de se connecter à la base de donnée</br>'; echo 'Erreur : ' . $e->getMessage() . '<br />'; echo 'N° : ' . $e->getCode(); } } }
Merci
papyclic
Messages postés
446
Date d'inscription
mercredi 5 novembre 2014
Statut
Membre
Dernière intervention
18 octobre 2016
3
Modifié par papyclic le 27/11/2014 à 00:03
Modifié par papyclic le 27/11/2014 à 00:03
Dans ma class User
je me demande si je ne dois pas appeler la fonction init comme ceci
private static $db; public function __construct($id_adherent = null) { self::init(); if(is_int($id_adherent)) { try { $this->load($id_adherent); } catch(Exception $e) { throw $e; } } } public function init() { if(self::$db == null) self::$db = new Database(); } private function load($id_adherent) { $req = self::$db->prepare('SELECT * FROM tb_adherent WHERE id_adherent = :id_adherent'); $req->bindParam(':id_adherent', $id_adherent, PDO::PARAM_INT); $req->execute(); $donnees = $req->fetch(PDO::FETCH_ASSOC); if(empty($donnees)) throw new Exception('Utilisateur introuvable'); $this->setUserDatas($donnees); }
je me demande si je ne dois pas appeler la fonction init comme ceci
public static function NewPass($id_adherent, $passActuel, $newPassUn, { $newPassDe) { self::init(); $req = self::$db->prepare('SELECT id_adherent FROM tb_adherent WHERE username = :username');