From 66d95c17762ac28155b173193f2461426db6ffb9 Mon Sep 17 00:00:00 2001 From: Christophe H <65390576+christophe-havard-sonarsource@users.noreply.github.com> Date: Tue, 22 Feb 2022 10:57:47 +0100 Subject: [PATCH 1/3] Create sqlquery.php --- sqlquery.php | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 sqlquery.php diff --git a/sqlquery.php b/sqlquery.php new file mode 100644 index 00000000..5a0df193 --- /dev/null +++ b/sqlquery.php @@ -0,0 +1,13 @@ +get('id'); + $sql = "SELECT email FROM user WHERE id='$userId'"; + $statement = $this->connection->prepare($sql); + $statement->execute(); + $username = $statement->fetchColumn(); + return $this->json(['email' => $username]); + } + +?> From dbb57deb0fddd3be4af8804403d2664f6b35ed84 Mon Sep 17 00:00:00 2001 From: Christophe H <65390576+christophe-havard-sonarsource@users.noreply.github.com> Date: Tue, 22 Feb 2022 11:02:25 +0100 Subject: [PATCH 2/3] Update sqlquery.php --- sqlquery.php | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sqlquery.php b/sqlquery.php index 5a0df193..069d9a25 100644 --- a/sqlquery.php +++ b/sqlquery.php @@ -1,6 +1,15 @@ -get('id'); $sql = "SELECT email FROM user WHERE id='$userId'"; @@ -9,5 +18,5 @@ public function sqlQuery1(Request $request) $username = $statement->fetchColumn(); return $this->json(['email' => $username]); } - +} ?> From 247704049f1c1f98f9da4971dd9032317a2c8636 Mon Sep 17 00:00:00 2001 From: Christophe H <65390576+christophe-havard-sonarsource@users.noreply.github.com> Date: Thu, 31 Mar 2022 10:31:42 +0200 Subject: [PATCH 3/3] Update sqlquery.php --- sqlquery.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sqlquery.php b/sqlquery.php index 069d9a25..8bda29fc 100644 --- a/sqlquery.php +++ b/sqlquery.php @@ -18,5 +18,15 @@ public function sqlQuery1(Request $request) $username = $statement->fetchColumn(); return $this->json(['email' => $username]); } + + public function anotherSqlQuery1(Request $request) + { + $userId = $request->get('name'); + $sql = "SELECT username FROM user WHERE id='$userId'"; + $statement = $this->connection->prepare($sql); + $statement->execute(); + $username = $statement->fetchColumn(); + return $this->json(['email' => $username]); + } } ?>