-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconn.php
116 lines (91 loc) · 2.93 KB
/
conn.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
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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<?php
class connec
{
public $username="root";
public $password="";
public $server_name="localhost";
public $db_name="movie_ticket_booking";
public $conn;
function __construct()
{
$this->conn=new mysqli($this->server_name,$this->username,$this->password,$this->db_name);
if($this->conn->connect_error)
{
die("Connection Failed");
}
// else
// {
// echo "connected";
// }
}
function select_all($table_name)
{
$sql = "SELECT * FROM $table_name";
$result=$this->conn->query($sql);
return $result;
}
function select_by_query($query)
{
$result=$this->conn->query($query);
return $result;
}
function select_show_dt()
{
$sql="SELECT movie_ticket_booking.show.id, movie_ticket_booking.show.show_date, movie_ticket_booking.show.ticket_price, movie_ticket_booking.show.no_seat,movie_ticket_booking.show.movie_id, movie.name AS 'movie_name', show_time.time, cinema.name FROM movie_ticket_booking.show, movie,show_time, cinema where movie_ticket_booking.show.movie_id=movie.id AND movie_ticket_booking.show.show_time_id =show_time.id AND movie_ticket_booking.show.cinema_id=cinema.id;";
$result=$this->conn->query($sql);
return $result;
}
function select_movie($table_name,$date)
{ if($date=="commingsoon")
{
$sql = "SELECT * FROM $table_name Where rel_date > now()";
$result=$this->conn->query($sql);
return $result;
}
else
{
$sql = "SELECT * FROM $table_name Where rel_date < now()";
$result=$this->conn->query($sql);
return $result;
}
}
function select($table_name,$id)
{
$sql = "SELECT * FROM $table_name where id=$id";
$result=$this->conn->query($sql);
return $result;
}
function select_login($table_name,$email)
{
$sql = "SELECT * FROM $table_name where email='$email'";
$result=$this->conn->query($sql);
return $result;
}
function insert($query,$msg)
{
if($this->conn->query($query)===TRUE)
{
echo '<script> alert("'.$msg.'");</script>' ;
//echo "inserted";
}
else
{
echo '<script> alert("'.$this->conn->error.'");</script>' ;
// echo $this->conn->error;
}
}
function insert_lastid($query)
{
$last_id;
if($this->conn->query($query)===TRUE)
{
$last_id=$this->conn->insert_id;
}
else
{
echo '<script> alert("'.$this->conn->error.'");</script>' ;
}
return $last_id;
}
}
?>