projects
/
cinaest
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (from parent 1:
25564c4
)
Catalog plugin: store and retrieve the date field for watched movies
author
Philipp Zabel
<philipp.zabel@gmail.com>
Sun, 11 Jul 2010 13:08:59 +0000
(15:08 +0200)
committer
Philipp Zabel
<philipp.zabel@gmail.com>
Sun, 11 Jul 2010 13:08:59 +0000
(15:08 +0200)
src/plugins/catalog-sqlite.vala
patch
|
blob
|
history
diff --git
a/src/plugins/catalog-sqlite.vala
b/src/plugins/catalog-sqlite.vala
index
c2bfbbc
..
509b47a
100644
(file)
--- a/
src/plugins/catalog-sqlite.vala
+++ b/
src/plugins/catalog-sqlite.vala
@@
-58,10
+58,17
@@
class CatalogSqlite : Object {
}
public int add_movie (string table, Movie movie) {
}
public int add_movie (string table, Movie movie) {
- string sql = "INSERT INTO %s(Title, Year, Rating, Genres) VALUES (\"%s\", %d, %d, %d);".printf (table, movie.title, movie.year, movie.rating, movie.genres.field);
+ var sql = new StringBuilder ();
int rc;
int rc;
+ sql.append_printf ("INSERT INTO %s(Title, Year, Rating, Genres", table);
+ if (table == "Watched")
+ sql.append_printf (", Date) VALUES (\"%s\", %d, %d, %d, %u);",
+ movie.title, movie.year, movie.rating, movie.genres.field, movie.julian_date);
+ else
+ sql.append_printf (") VALUES (\"%s\", %d, %d, %d);",
+ movie.title, movie.year, movie.rating, movie.genres.field);
- rc = db.exec (sql, callback, null);
+ rc = db.exec (sql.str, callback, null);
if (rc != Sqlite.OK) {
stderr.printf ("Failed to insert movie \"%s\" (%d): %d, %s\n", movie.title, movie.year, rc, db.errmsg ());
return 1;
if (rc != Sqlite.OK) {
stderr.printf ("Failed to insert movie \"%s\" (%d): %d, %s\n", movie.title, movie.year, rc, db.errmsg ());
return 1;
@@
-250,6
+257,8
@@
class CatalogSqlite : Object {
movie.title = stmt.column_text (0);
movie.rating = stmt.column_int (2);
movie.genres.field = stmt.column_int (3);
movie.title = stmt.column_text (0);
movie.rating = stmt.column_int (2);
movie.genres.field = stmt.column_int (3);
+ if (table == "Watched")
+ movie.julian_date = stmt.column_int (4);
// TODO - depending on settings, this could be something else, like director info or runtime
movie.secondary = movie.genres.to_string ();
result.append (movie);
// TODO - depending on settings, this could be something else, like director info or runtime
movie.secondary = movie.genres.to_string ();
result.append (movie);