-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathpost.php
More file actions
39 lines (39 loc) · 1005 Bytes
/
post.php
File metadata and controls
39 lines (39 loc) · 1005 Bytes
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
<?php
require_once('db.php');
class Post {
protected $msg;
protected $parent;
protected $id;
protected $date;
function __construct($msg,$parent,$id=NULL,$date=NULL){
$this->setMessage($msg);
$this->setParent($parent);
if($id!=NULL)$this->setId($id);
if($date!=NULL)$this->setDate($date);
}
function save(){
return DB::getInstance()->addPost($this);
}
function setParent($parent){
if(is_numeric($parent) && !is_float($parent) && $parent >=0)
$this->parent=$parent;
else
throw new Exception("Parent has to non-numeric value", '100');
}
function setMessage($msg){
$this->msg=$msg;
}
function setId($id){
if(is_numeric($id) && !is_float($id) && $id >=0)
$this->id=$id;
else
throw new Exception("ID has to non-numeric value", '100');
}
function setDate($date){
$this->date=$date;
}
function getParent(){return $this->parent;}
function getMessage(){return $this->msg;}
function getId(){return $this->id;}
function getDate(){return strtotime($this->date);}
}