diff options
author | Sebastian Reichel <sre@ring0.de> | 2012-05-16 22:02:52 +0200 |
---|---|---|
committer | Sebastian Reichel <sre@ring0.de> | 2012-05-16 22:02:52 +0200 |
commit | 6a05385a77201c7c2d6cd9d7c10fec3891ba82e0 (patch) | |
tree | 0808b411e37c8ce6a68e5f9b2c0dbadd1bd49c41 | |
parent | 40db69e78d55eceeb0d6ea851ff756e2508bd618 (diff) | |
download | serial-barcode-scanner-6a05385a77201c7c2d6cd9d7c10fec3891ba82e0.tar.bz2 |
add timestamp to purchases
-rw-r--r-- | db.vala | 5 |
1 files changed, 4 insertions, 1 deletions
@@ -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(); |