[chronojump] New Sqlite.ExistsAndGetUniqueID. Exists method rewritten.
- From: Xavier de Blas <xaviblas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [chronojump] New Sqlite.ExistsAndGetUniqueID. Exists method rewritten.
- Date: Fri, 6 Sep 2019 13:06:33 +0000 (UTC)
commit e166910a4fa0182eb0340e9642d316e7ad36c9a3
Author: Xavier de Blas <xaviblas gmail com>
Date: Fri Sep 6 10:35:01 2019 +0200
New Sqlite.ExistsAndGetUniqueID. Exists method rewritten.
src/sqlite/main.cs | 19 ++++++++++++++-----
1 file changed, 14 insertions(+), 5 deletions(-)
---
diff --git a/src/sqlite/main.cs b/src/sqlite/main.cs
index 4e4c07a8..1980623a 100644
--- a/src/sqlite/main.cs
+++ b/src/sqlite/main.cs
@@ -2767,6 +2767,14 @@ class Sqlite
}
public static bool Exists(bool dbconOpened, string tableName, string findName)
+ {
+ return (ExistsDo(dbconOpened, tableName, findName) != -1);
+ }
+ public static int ExistsAndGetUniqueID(bool dbconOpened, string tableName, string findName)
+ {
+ return ExistsDo(dbconOpened, tableName, findName);
+ }
+ public static int ExistsDo(bool dbconOpened, string tableName, string findName)
{
if(!dbconOpened)
Sqlite.Open();
@@ -2778,19 +2786,20 @@ class Sqlite
SqliteDataReader reader;
reader = dbcmd.ExecuteReader();
- bool exists = new bool();
- exists = false;
+ int id = -1;
if (reader.Read()) {
- exists = true;
+ string s = reader[0].ToString();
+ if(Util.IsNumber(s, false))
+ id = Convert.ToInt32(s);
}
- LogB.SQL(string.Format("name exists = {0}", exists.ToString()));
+ LogB.SQL(string.Format("SQL.ExistsDo... table: {0}; name: {1}; id: {2}.", tableName,
findName, id.ToString()));
reader.Close();
if(!dbconOpened)
Sqlite.Close();
- return exists;
+ return id;
}
public static string SQLBuildQueryString (string tableName, string test, string variable,
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]