-
Notifications
You must be signed in to change notification settings - Fork 0
/
Note.php
102 lines (88 loc) · 2.53 KB
/
Note.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
<?php
include_once("functions.php");
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
* Description of Note
*
* @author kamil
*/
class Note {
private $title, $note, $owner, $added_on, $status, $link;
private $table = "notes";
public function __construct($title) {
$this->title = $title;
}
public function get_title() {
return $this->title;
}
public function get_note() {
return $this->note;
}
public function get_owner_id() {
return $this->owner;
}
public function get_added_on() {
return $this->added_on;
}
public function get_status() {
return $this->status;
}
public function get_link() {
return $this->link;
}
public function set_title($title) {
$this->title = $title;
return $this;
}
public function set_note($note) {
$this->note = $note;
return $this;
}
public function set_owner_id($owner) {
$this->owner = $owner;
return $this;
}
public function set_added_on($added_on) {
$this->added_on = $added_on;
return $this;
}
public function set_status($status) {
$this->status = $status;
return $this;
}
public function set_link($link) {
$this->link = $link;
return $this;
}
public function save() {
$conn = get_connection_handle();
$stmt = $conn->prepare("insert into $this->table(title,note,owner,"
. "added_on, status, link_id) values(?,?,?,?,?,?)");
$stmt->bind_param("ssssis", $this->title,$this->note,$this->owner,
$this->added_on,$this->status,$this->link);
$stmt->execute();
$rows = $conn->affected_rows;
if($rows == 1){
return true;
}
return FALSE;
}
public function update($user){
$conn = get_connection_handle();
$d = new DateTime();
$date = $d->format("Y-m-d h:i:sa");
$stmt = $conn->prepare("UPDATE $this->table SET title = ?,note = ?,"
. "status = ?, added_on = ?, link_id = ?, owner = ? where id = ?");
$stmt->bind_param("sssssi", $this->title,$this->note,$this->status,$this->added_on,
$this->link, $this->owner, $id);
$stmt->execute();
if($conn->affected_rows == 1){
return $conn->affected_rows;
}
return FALSE;
}
}