$this->connection->executeUpdate('UPDATE users SET pseudo = :username, email = :email, commentaire = :comment WHERE id = :id',[
$this->connection->executeUpdate('UPDATE users SET pseudo = :username, email = :email, commentaire = :comment, cumul = :cumul, total = :total WHERE id = :id',[
'username'=>$command->getUsername(),
'email'=>$command->getEmail(),
'comment'=>$command->getComment(),
'id'=>$command->getId(),
'total'=>$command->getTotal(),
'cumul'=>$command->getCumul(),
]);
}
...
...
@@ -95,7 +97,7 @@ class UserHandler
$user_id=(int)$user_id;
$total=$this->connection->executeQuery('SELECT SUM(somme) AS total FROM dons WHERE user_id = :user_id AND STATUS IN (1, 102)',[
'user_id'=>$user_id
])->fetchColumn();
])->fetchAll(\PDO::FETCH_COLUMN)[0];
// Let's compute the cumul too
// quoi = 'hoopie' somme = 250
...
...
@@ -105,7 +107,7 @@ class UserHandler
$spent=$this->connection->executeQuery(
"SELECT sum(IF(quoi = 'hoopie',250,0)) + sum(IF(quoi = 'pishirt', 100, 0)) + sum(IF(quoi = 'pibag', 50, 0)) + sum(IF(quoi = 'piplome', 30, 0)) AS spent FROM contreparties WHERE user_id = :user_id",
['user_id'=>$user_id]
)->fetchColumn();
)->fetchAll(\PDO::FETCH_COLUMN)[0];
$this->connection->executeUpdate('UPDATE users SET total = :total, cumul = :cumul WHERE id = :user_id',['total'=>(int)$total,'cumul'=>(int)$total-(int)$spent,'user_id'=>$user_id]);