summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSebastian Reichel <sre@ring0.de>2012-05-16 22:02:52 +0200
committerSebastian Reichel <sre@ring0.de>2012-05-16 22:02:52 +0200
commit6a05385a77201c7c2d6cd9d7c10fec3891ba82e0 (patch)
tree0808b411e37c8ce6a68e5f9b2c0dbadd1bd49c41
parent40db69e78d55eceeb0d6ea851ff756e2508bd618 (diff)
downloadserial-barcode-scanner-6a05385a77201c7c2d6cd9d7c10fec3891ba82e0.tar.bz2
add timestamp to purchases
-rw-r--r--db.vala5
1 files changed, 4 insertions, 1 deletions
diff --git a/db.vala b/db.vala
index 5679eb7..a02cfca 100644
--- a/db.vala
+++ b/db.vala
@@ -3,7 +3,7 @@ public class Database {
private Sqlite.Statement insert_stmt;
private Sqlite.Statement product_stmt;
uint64 user = 0;
- private static string insert_query = "INSERT INTO purchases ('user', 'product') VALUES (?, ?)";
+ private static string insert_query = "INSERT INTO purchases ('user', 'product', 'timestamp') VALUES (?, ?, ?)";
private static string product_query = "SELECT name FROM products WHERE id = ?";
public Database(string file) {
@@ -37,9 +37,12 @@ public class Database {
public bool buy(uint64 article) {
if(is_logged_in()) {
+ int64 timestamp = (new DateTime.now_utc()).to_unix();
+
this.insert_stmt.reset();
this.insert_stmt.bind_text(1, "%llu".printf(user));
this.insert_stmt.bind_text(2, "%llu".printf(article));
+ this.insert_stmt.bind_text(3, "%llu".printf(timestamp));
int rc = this.insert_stmt.step();