[rygel] core: add existence check for object to db
- From: Zeeshan Ali Khattak <zeeshanak src gnome org>
- To: svn-commits-list gnome org
- Subject: [rygel] core: add existence check for object to db
- Date: Thu, 25 Jun 2009 15:47:25 +0000 (UTC)
commit 5aa6973ab4354dcfc1feafed77b98108346e6e13
Author: Jens Georg <mail jensge org>
Date: Wed Jun 24 23:13:20 2009 +0200
core: add existence check for object to db
src/rygel/rygel-media-db.vala | 28 +++++++++++++++++++++++++++-
1 files changed, 27 insertions(+), 1 deletions(-)
---
diff --git a/src/rygel/rygel-media-db.vala b/src/rygel/rygel-media-db.vala
index 1241358..bb20fb7 100644
--- a/src/rygel/rygel-media-db.vala
+++ b/src/rygel/rygel-media-db.vala
@@ -117,7 +117,10 @@ public class Rygel.MediaDB : Object {
"SELECT uri FROM Uri WHERE Uri.object_fk = ?";
private const string CHILDREN_COUNT_STRING =
- "SELECT count(upnp_id) from Object where Object.parent = ?";
+ "SELECT COUNT(upnp_id) FROM Object WHERE Object.parent = ?";
+
+ private const string OBJECT_EXISTS_STRING =
+ "SELECT COUNT(upnp_id) FROM Object WHERE Object.upnp_id = ?";
private void open_db (string name) {
var dirname = Path.get_dirname (name);
@@ -464,6 +467,29 @@ public class Rygel.MediaDB : Object {
return count;
}
+ public bool exists (string object_id) {
+ Statement statement;
+ bool exists = false;
+ var rc = db.prepare_v2 (OBJECT_EXISTS_STRING,
+ -1,
+ out statement,
+ null);
+ if (rc == Sqlite.OK) {
+ statement.bind_text (1, object_id);
+ while ((rc = statement.step ()) == Sqlite.ROW) {
+ exists = statement.column_int (0) == 1;
+ break;
+ }
+ } else {
+ warning ("Could not get child count for object %s: %s",
+ object_id,
+ db.errmsg ());
+ }
+
+ return exists;
+ }
+
+
public Gee.ArrayList<MediaObject> get_children (string object_id,
uint offset,
uint max_count) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]