-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdbConnector.php
More file actions
55 lines (38 loc) · 1.28 KB
/
Copy pathdbConnector.php
File metadata and controls
55 lines (38 loc) · 1.28 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
<?php
class DbConnector {
var $theQuery;
var $link;
function DbConnector(){
// Get the main settings from the array we just loaded
// $host = 'localhost';
// $db = 'Famous_db';
// $user = 'root';
// $pass = 'RC1135351';
$host = 'localhost';
$db = 'Famous_db';
$user = 'root';
$pass = 'RC1135351';
// // Connect to the database
// $this->link = mysqli_connect($servername, $username, $password);
// mysqli_select_db($db);
// register_shutdown_function(array(&$this, 'close'));
// Connect to the database
$this->link = mysqli_connect($host, $user, $pass);
mysqli_select_db($db);
register_shutdown_function(array(&$this, 'close'));
}
//*** Function: query, Purpose: Execute a database query ***
function query($query) {
$this->theQuery = $query;
return mysqli_query($query, $this->link);
}
//*** Function: fetchArray, Purpose: Get array of query results ***
function fetchArray($result) {
return mysqli_fetch_array($result);
}
//*** Function: close, Purpose: Close the connection ***
function close() {
mysqli_close($this->link);
}
}
?>