Close prepared statements
authorRichard Whitehouse <richardwhiuk@richardwhiuk.com>
Fri, 4 Feb 2011 23:25:51 +0000 (23:25 +0000)
committerRichard Whitehouse <richardwhiuk@richardwhiuk.com>
Fri, 4 Feb 2011 23:25:51 +0000 (23:25 +0000)
index.php

index bfa8b08b80141fc497770eabc0bebc34836a52af..11384b4edb9b5608c8c087ccce75fadcb17ed51f 100644 (file)
--- a/index.php
+++ b/index.php
@@ -208,6 +208,7 @@ class Ticket {
                if($stmt->fetch() == null){
                        throw new Exception('No rows for count!');
                }
+               $stmt->close();
                return $count;
        }
 
@@ -225,9 +226,11 @@ class Ticket {
                }
                $ticket = new Ticket($id, $type, $status);
                $query = 'UPDATE `ticket` SET `status` = 1 WHERE `id` = ?';
+               $stmt->close();
                $stmt = Ticketing::Get()->database()->prepare($query);
                $stmt->bind_param('i', $id);
                $stmt->execute();
+               $stmt->close();
                return $ticket;
        }
 
@@ -256,6 +259,7 @@ class Purchase {
                $stmt->bind_param('iiis', $order->id(), $ticket->id(), $type->price(), $name);
                $stmt->execute();
                $purchase = new Purchase($stmt->insert_id, $order->id(), $ticket->id(), $type->price(), $name);
+               $stmt->close();
        } 
 
 
@@ -324,6 +328,7 @@ class Order {
                        $stmt->bind_param('si', $user, $time);
                        $stmt->execute();
                        $order = new Order($stmt->insert_id, $user, $time, 0);
+                       $stmt->close();
                }
                return $order;
        }
@@ -338,6 +343,7 @@ class Order {
                while($stmt->fetch()){
                        $orders[$id] = new Order($id, $user, $time, $status);
                }
+               $stmt->close();
                $order = array_shift($orders);
                foreach($orders as $o){
                        $order->merge($o);
@@ -352,6 +358,7 @@ class Order {
                $time = time();
                $stmt->bind_param('ii', $time, $this->id); 
                $stmt->execute();
+               $stmt->close();
        }
 
        private function merge(){