Bonjour,

Voici mon code pour ma classe qui accède à ma table :
Code : 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
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
 
<?php
	class tarifs
	{
		private $insert;
		private $update;
		private $SelectOneMontant;
		private $selectAll;
 
		public function __construct($db)
		{
			$this-> insert = $db->prepare("insert into scf_grille_tarif (Type_Tarif, Montant) 
												                values (:Type_Tarif, :Montant)");
			$this-> selectAll = $db->prepare("select * from scf_grille_tarif where idSaison = :idSaison");
			$this-> SelectOneMontant = $db->prepare("select Montant from scf_grille_tarif where Type_Tarif = :Type_Tarif");
			$this-> update = $db->prepare("update scf_grille_tarif set Montant = :Montant where Type_Tarif = :Type_Tarif");
		}
 
		public function insert($Type_Tarif, $Montant)
		{
			$this -> insert -> execute(array(':Type_Tarif' => $Type_Tarif, 
											 ':Montant' => $Montant));
			return $this->insert->rowCount();
		}
 
		public function selectAll()
		{
			$this -> selectAll -> execute();
			return $this->selectAll->fetchAll();
		}
 
		public function SelectOneMontant($Type_Tarif)
		{
			$this -> SelectOneMontant -> execute(array(':Type_Tarif' => $Type_Tarif));
			return $this->SelectOneMontant->fetch();
		}
 
		public function update($Type_Tarif, $Montant)
		{
			echo " (dans class_Montant. Type_Tarif : $Type_Tarif - Montant : $Montant)";
			$this -> update -> execute(array(':Montant' => $Montant, ':Type_Tarif' => $Type_Tarif));
			return $this->update->rowCount();
		}
	}
?>
Lorque j'appelle ma fonction update, la fonction renvoie 0 row.
Voici comment je l'appelle :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
$nb = $Tarifs->update($cle, $valeur);
L'insert se fait sans pb.

Voici les traces :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
Poste : 1 - UnTarif : 125.00 - MAJ du poste 1 avec la valeur 125.00 (dans class_Montant. Type_Tarif : 1 - Montant : 125.00)
Ca a échoué car la variable nb=0!
Arrêt du traitement
Savez-vous pourquoi ?

Merci pour votre aide.

Eddy