khanat-opennel-code/code/ryzom/tools/server/ryzom_ams/ams_lib/autoload/ticket.php
2013-07-08 09:40:48 +02:00

67 lines
No EOL
2.2 KiB
PHP

<?php
class Ticket{
private $tId;
private $timestamp;
private $title;
private $status;
private $queue;
private $ticket_category;
private $author;
private $db;
public function __construct($db_data) {
$this->db = $db_data;
}
//Set ticket object
public function set($t,$s,$q,$t_c,$a){
$this->title = $t;
$this->status = $s;
$this->queue = $q;
$this->ticket_category = $t_c;
$this->author = $a;
}
//create ticket by writing private data to DB.
public function create(){
$dbl = new DBLayer($this->db);
$query = "INSERT INTO ticket (Timestamp, Title, Status, Queue, Ticket_Category, Author) VALUES (now(), :title, :status, :queue, :tcat, :author)";
$values = Array('title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author);
$this->tId = $dbl->executeReturnId($query, $values); ;
}
//return constructed element based on TId
public function load_With_TId( $id) {
$dbl = new DBLayer($this->db);
$statement = $dbl->execute("SELECT * FROM ticket WHERE TId=:id", array('id' => $id));
$row = $statement->fetch();
$this->tId = $row['TId'];
$this->timestamp = $row['Timestamp'];
$this->title = $row['Title'];
$this->status = $row['Status'];
$this->queue = $row['Queue'];
$this->ticket_category = $row['Ticket_Category'];
$this->author = $row['Author'];
}
//update private data to DB.
public function update(){
$dbl = new DBLayer($this->db);
$query = "UPDATE ticket SET Timestamp = :timestamp, Title = :title, Status = :status, Queue = :queue, Ticket_Category = :tcat, Author = :author WHERE TId=:id";
$values = Array('id' => $this->tId, 'timestamp' => $this->timestamp, 'title' => $this->title, 'status' => $this->status, 'queue' => $this->queue, 'tcat' => $this->ticket_category, 'author' => $this->author);
$statement = $dbl->execute($query, $values);
}
//Getters
public function getTId(){
return $this->tId;
}
//setters
public function setTId($id){
$this->tId = $id;
}
}