Add Ticket::Get
authorRichard Whitehouse <richardwhiuk@richardwhiuk.com>
Fri, 4 Feb 2011 23:40:10 +0000 (23:40 +0000)
committerRichard Whitehouse <richardwhiuk@richardwhiuk.com>
Fri, 4 Feb 2011 23:40:10 +0000 (23:40 +0000)
index.php

index fc38e794a28533318f7937ce1365b188788c60b4..d8fb1651a789ac2412e5c18b7f37a4de8b244116 100644 (file)
--- a/index.php
+++ b/index.php
@@ -212,6 +212,20 @@ class Ticket {
                return $count;
        }
 
+       public static function Get($id){
+               $query = 'SELECT `id`,`type`,`status` FROM `ticket` WHERE `id` = ? LIMIT 1';
+               $stmt = Ticketing::Get()->database()->prepare($query);
+               $stmt->bind_param('i', $type);
+               $stmt->execute();
+               $stmt->bind_result($id, $type, $status);
+               $ticket = null;
+               if($stmt->fetch()){
+                       $ticket = new Ticket($id, $type, $status);;
+               }
+               $stmt->close();
+               return $ticket;
+       }
+
        public static function Allocate_Available($type){
                if($type instanceof Type){
                        $type = $type->id();