Use medium blobs for invoces

Change-Id: I09d38b78f6a811b0296092f6ac9f26ee88396e72
diff --git a/create_user_table.sql b/create_user_table.sql
index 51b916a..ae935dc 100644
--- a/create_user_table.sql
+++ b/create_user_table.sql
@@ -24,6 +24,7 @@
     total_due decimal(10,2) not null default 0.00,
     registered_at timestamp default '0000-00-00 00:00:00', 
     updated_at timestamp default now() on update now(),
-    invoice BLOB,
+    invoice MEDIUMBLOB,
+    invoice_reference varchar(32) not null default '',
   primary key (`id`)
 ) engine=innodb AUTO_INCREMENT=100;
diff --git a/db_backend.php b/db_backend.php
index 6876558..182a1c7 100644
--- a/db_backend.php
+++ b/db_backend.php
@@ -65,6 +65,17 @@
         }
     }
 
+    function updateInvoice($user) {
+        $this->log->debug("updateInvoice");
+        $sql = "UPDATE person SET invoice = :invoice WHERE id = :id;";
+        $stmt = $this->pdo->prepare($sql);
+
+        $stmt->bindParam(':invoice', $user->invoice, PDO::PARAM_LOB);
+        $stmt->bindParam(':id', $user->id);
+
+        return $stmt->execute();
+    }
+
     function mail_count($email)
     {
         $sql = "SELECT COUNT(*) FROM person WHERE email = :email";