-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsqlquery.php
32 lines (28 loc) · 870 Bytes
/
sqlquery.php
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
<?php
use Symfony\Component\HttpFoundation\Request;
class Controller
{
/**
* @var \Doctrine\DBAL\Connection
*/
protected $connection;
public function sqlQuery1(Request $request)
{
$userId = $request->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]);
}
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]);
}
}
?>