-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgetData.php.EXAMPLE
48 lines (46 loc) · 1.93 KB
/
getData.php.EXAMPLE
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
46
47
48
<?php
header('Expires: Thu, 01-Jan-70 00:00:01 GMT');
header('Last-Modified: ' . gmdate('D, d M Y H:i:s') . ' GMT');
header('Cache-Control: no-store, no-cache, must-revalidate');
header('Cache-Control: post-check=0, pre-check=0', false);
header('Pragma: no-cache');
$dsn = "mysql:host=localhost;dbname=db_name;charset=utf8";
$username = "username"; // I made this user read only so need for password
$pdo = new PDO($dsn, $username);
$rows = array();
if(isset($_GET['Residues'])) {
$query = "SELECT * FROM " . $_GET['Residues'];
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['SpeciesTable'])) {
$stmt = $pdo->prepare("SELECT * FROM SpeciesTables WHERE SS_Table = ?");
$stmt->execute(array($_GET['SpeciesTable']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['FetchMapList'])){
$query = "SELECT Species_Name, Species_Abr, Subunit,DataSetName, MapType, SS_Table FROM SpeciesTables";
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['TextLabels'])) {
$query = "SELECT * FROM " . $_GET['TextLabels'];
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['LineLabels'])) {
$query = "SELECT * FROM " . $_GET['LineLabels'];
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['BasePairs'])) {
$query = "SELECT * FROM " . $_GET['BasePairs'];
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['FullTable'])) {
$query = "SELECT * FROM " . $_GET['FullTable'];
$stmt = $pdo->query($query);
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
} else if(isset($_GET['ProtBasePairs'])) {
$query = "SELECT * FROM " . $_GET['ProtBasePairs'];
$stmt = $pdo->prepare($query . " WHERE ProteinName = ?");
$stmt->execute(array($_GET['ProtChain']));
$rows = $stmt->fetchAll(PDO::FETCH_ASSOC);
}
echo json_encode($rows);
?>