//获取历史前五记录 bool GetScore() { IDataReader sqReader = db.SelectWhere("five"); while (sqReader.Read()) { //Debug.Log(sqReader.GetString(sqReader.GetOrdinal("score"))); score.Add(sqReader.GetInt32(sqReader.GetOrdinal("score"))); } if (score != null) { return(true); } return(false); }
static int SelectWhere(IntPtr L) { try { ToLua.CheckArgsCount(L, 6); SqliteDbHelper obj = (SqliteDbHelper)ToLua.CheckObject(L, 1, typeof(SqliteDbHelper)); string arg0 = ToLua.CheckString(L, 2); string[] arg1 = ToLua.CheckStringArray(L, 3); string[] arg2 = ToLua.CheckStringArray(L, 4); string[] arg3 = ToLua.CheckStringArray(L, 5); string[] arg4 = ToLua.CheckStringArray(L, 6); Mono.Data.Sqlite.SqliteDataReader o = obj.SelectWhere(arg0, arg1, arg2, arg3, arg4); ToLua.PushObject(L, o); return(1); } catch (Exception e) { return(LuaDLL.toluaL_exception(L, e)); } }
void OnGUI() { if (GUILayout.Button("create table")) { db.CreateTable("mytable", new string[] { "id", "name", "email" }, new string[] { "int", "varchar(20)", "varchar(50)" }); Debug.Log("create table ok"); } if (GUILayout.Button("insert data")) { db.InsertInto("mytable", new string[] { "" + (++id), "'随风去旅行" + id + "'", "'zhangj_live" + id + "@163.com'" }); Debug.Log("insert table ok"); } if (GUILayout.Button("insert data specific")) { db.InsertIntoSpecific("mytable", new string[] { "name", "id" }, new string[] { "'随风去旅行6'", "99" }); Debug.Log("insert data specific ok"); } if (GUILayout.Button("Delete data")) { db.Delete("mytable", new string[] { "name" }, new string[] { "'随风去旅行6'" }); Debug.Log("Delete data ok"); } if (GUILayout.Button("Read Full Table")) { IDataReader sqReader = db.ReadFullTable("mytable"); while (sqReader.Read()) { string id = "id=" + sqReader.GetInt32(sqReader.GetOrdinal("id")); name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name")); emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email")); Debug.LogError(id + "/" + name + "/" + emls); } Debug.Log("Read Full Table ok"); } if (GUILayout.Button("search database")) { IDataReader sqReader = db.SelectWhere("mytable", new string[] { "name", "email" }, new string[] { "id" }, new string[] { "=" }, new string[] { "2" }); while (sqReader.Read()) { name = "name=" + sqReader.GetString(sqReader.GetOrdinal("name")); emls = "email=" + sqReader.GetString(sqReader.GetOrdinal("email")); } } if (GUILayout.Button("Update data")) { db.UpdateInto("mytable", new string[] { "name", "email" }, new string[] { "'吴小雄'", "'吴小雄21a'" }, "id", "5"); Debug.Log("Update data ok"); } if (name != "") { GUI.Label(new Rect(100, 100, 100, 100), name); GUI.Label(new Rect(100, 200, 100, 100), emls); // GUILayout.Label(emls); } if (GUILayout.Button("close database")) { db.CloseSqlConnection(); Debug.Log("close table ok"); } }