From fc3dabe7c80b56e26fc4dd07c6e89b1339df943a Mon Sep 17 00:00:00 2001 From: Okhin Date: Thu, 13 Dec 2018 15:21:27 +0100 Subject: [PATCH] Fixing some small typos --- db/migrations/20181213125806_add_parent_field.php | 6 ++---- src/LQDN/Handler/UserHandler.php | 2 +- 2 files changed, 3 insertions(+), 5 deletions(-) diff --git a/db/migrations/20181213125806_add_parent_field.php b/db/migrations/20181213125806_add_parent_field.php index 4b00615..c962bcb 100644 --- a/db/migrations/20181213125806_add_parent_field.php +++ b/db/migrations/20181213125806_add_parent_field.php @@ -33,10 +33,8 @@ class AddParentField extends AbstractMigration public function change() { $table = $this->table('contreparties'); - if (!$table->hasColumn('parent')) { - $table->addColumn('parent', 'integer'); - $table->update(); - } + $table->addColumn('parent', 'integer'); + $table->update(); $builder = $this->getQueryBuilder(); $stmt = $builder->update('contreparties') ->set('parent', 'id') diff --git a/src/LQDN/Handler/UserHandler.php b/src/LQDN/Handler/UserHandler.php index e9a4cbb..0ae0a0d 100644 --- a/src/LQDN/Handler/UserHandler.php +++ b/src/LQDN/Handler/UserHandler.php @@ -106,7 +106,7 @@ class UserHandler // quoi = 'pibag' somme = 50 // quoi = 'piplome' somme = 30 $spent = $this->connection->executeQuery( - "SELECT sum(IF(quoi = 'hoodie',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 AND contreparties.id = contreparties.parent", + "SELECT sum(IF(quoi = 'hoodie',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 AND id = parent", [ 'user_id' => $user_id] )->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]); -- GitLab