-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmodel.php
67 lines (59 loc) · 2.28 KB
/
model.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
<?php
class Model
{
// For connection with Database starts.
function __construct()
{
require_once 'db_connection.php';
$this->DB=new DB_Con();
}//__construct()
// For connection with Database ends.
/* INSERT STATEMENT STARTS */
function insert($param1,$param2,$param3,$param4)
{
$timestamp=time();
$qry = "INSERT INTO `TABLE_NAME`(`param1`,`pram2`,`pram3`,`param4`) VALUES (:param1,:param2,:param3,:param4)";
$prepared_statement=$this->DB->prepare($qry);
$prepared_statement -> bindValue(':param1', $param1);
$prepared_statement -> bindValue(':param2', $param2);
$prepared_statement -> bindValue(':param3', $param3);
$prepared_statement -> bindValue(':param4', $param4);
$exe_status = $prepared_statement -> execute();
return $exe_status;
}//insert
/* INSERT STATEMENT ENDS */
/* SELECT STATEMENT STARTS */
function select_data($param1)
{
$qry="SELECT * FROM TABLE_NAME WHERE param1=:pram1";
$prepared_statement=$this->DB->prepare($qry);
$prepared_statement->bindValue(':param1',$pram1);
$prepared_statement->execute();
return $result_set = $prepared_statement->fetch();
}//select()
/* SELECT STATEMENT ENDS */
/* UPDATE STATEMENTS STARTS */
public function update_data($param1,$company,$address,$phone)
{
$timestamp=time();
$qry = "UPDATE `TABLE_NAME` SET `param1`=:param1,`param2`=:param2 WHERE `param3` = :param3 ";
$prepared_statement=$this->DB->prepare($qry);
$prepared_statement -> bindValue(':param1', $param1);
$prepared_statement -> bindValue(':param2', $param2);
$prepared_statement -> bindValue(':param3', $param3);
$exe_status = $prepared_statement -> execute();
return $exe_status;
}//update()
/* UPDATE STATEMENTS ENDS */
/* DELETE STATEMENTS STARTS */
public function delete($param1)
{
$qry = "DELETE FROM `TABLE_NAME` WHERE `field1` = :param1";
$prepared_statement=$this->DB->prepare($qry);
$prepared_statement -> bindValue(':param1', $param1);
$exe_status = $prepared_statement -> execute();
return $exe_status;
}//delete()
/* DELETE STATEMENTS ENDS */
}
?>