-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSQLHandleScratch.php
More file actions
101 lines (85 loc) · 2.58 KB
/
SQLHandleScratch.php
File metadata and controls
101 lines (85 loc) · 2.58 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
<?php
/**
*
* Handle as a Go-between for MySQL as a "REST" inteface
*
*@author Zachary higgs
*
*/
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(E_ALL);
<<<<<<< HEAD
$username = $_POST['username'];
$password = $_POST['password'];
$Database = $_POST['db'];
$Method = $_POST['method'];
$data = $_POST['data'];
if($Method == ''){
$o = new SQLHandle($username, $password, $Database);
} else{
$o = new SQLHandle($username, $password, $Database, $Method, $data);
}
=======
$username = $_GET['username'];
$password = $_GET['password'];
//This points to the Overarching Database name
$Database = $_GET['db'];
echo $username . $password . $Database;
$o = new SQLHandle($username, $password, $Database);
>>>>>>> 425964aa3e51eec169fdb671e6e7d23ab88f3de1
class SQLHandle {
private $conn;
private $data;
<<<<<<< HEAD
public function __construct($username, $password, $db, $method = 0, $data = ""){
$this->conn = mysqli_connect("172.16.176.104", $username, $password, $db);
=======
public function __construct($username, $password, $db){
$this->conn = mysqli_connect("localhost", $username, $password, $db);
>>>>>>> 425964aa3e51eec169fdb671e6e7d23ab88f3de1
if(mysqli_connect_errno($this->conn)){
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
//Run a test function, you can replace this internally with a 'Enum'-based function
<<<<<<< HEAD
if($method == 0){
$this->testFunc();
} else if ($method == 1){
insertData($data);
}
=======
$this->testFunc();
>>>>>>> 425964aa3e51eec169fdb671e6e7d23ab88f3de1
}
/**
* Safely destroy this Class
*
*/
public function __destruct(){
mysqli_close($this->conn);
}
public function testFunc(){
<<<<<<< HEAD
$result = mysqli_query($this->conn, "SELECT * FROM players;");
//This is a strange Multi assositive array
$row = mysqli_fetch_array($result);
$this->data = json_encode($row);
echo $this->data;
}
public function insertData($data){
mysqli_stmt_execute("INSERT INTO CARDS(cardJson) VALUES(" . $data . ");");
}
=======
$result = mysqli_query($this->conn, "SELECT * FROM test;");
//This is a strange Multi assositive array
$row = mysqli_fetch_array($result);
$this->data = $row[0];
print_r($row);
echo $this->data;
}
>>>>>>> 425964aa3e51eec169fdb671e6e7d23ab88f3de1
public function closeConnection(){
mysqli_close($this->con);
}
}