setTContentId($id); return $instance; } ////////////////////////////////////////////Methods//////////////////////////////////////////////////// /** * A constructor. * Empty constructor */ public function __construct() { } /** * creates a new 'tickt_content' entry. * this method will use the object's attributes for creating a new 'ticket_content' entry in the database. */ public function create() { $dbl = new DBLayer("lib"); $query = "INSERT INTO ticket_content (Content) VALUES (:content)"; $values = Array('content' => $this->content); $this->tContentId = $dbl->executeReturnId($query, $values); ; } /** * loads the object's attributes. * loads the object's attributes by giving a ticket_content's id, * @param $id the id of the ticket_content entry that should be loaded */ public function load_With_TContentId( $id) { $dbl = new DBLayer("lib"); $statement = $dbl->execute("SELECT * FROM ticket_content WHERE TContentId=:id", array('id' => $id)); $row = $statement->fetch(); $this->tContentId = $row['TContentId']; $this->content = $row['Content']; } /** * update the object's attributes to the database. */ public function update(){ $dbl = new DBLayer("lib"); $query = "UPDATE ticket_content SET Content = :content WHERE TContentId=:id"; $values = Array('id' => $this->tContentId, 'content' => $this->content); $statement = $dbl->execute($query, $values); } ////////////////////////////////////////////Getters//////////////////////////////////////////////////// /** * get content attribute of the object. */ public function getContent(){ if ($this->content == ""){ $this->load_With_TContentId($this->tContentId); } return $this->content; } /** * get tContentId attribute of the object. */ public function getTContentId(){ return $this->tContentId; } ////////////////////////////////////////////Setters//////////////////////////////////////////////////// /** * set content attribute of the object. * @param $c content of a reply */ public function setContent($c){ $this->content = $c; } /** * set tContentId attribute of the object. * @param $c integer id of ticket_content entry */ public function setTContentId($c){ $this->tContentId = $c; } }