//------------------------------------------ /// <summary> /// json型の値を保存 /// </summary> /// <param name="id">ユニークID</param> /// <param name="json">Json.</param> //------------------------------------------ public static int dataInsert(string json, string filepath = "") { JsonNode jn = jsonDecode(json); string query = "INSERT INTO " + tablename; query += " (" + "id," + "name," + "address," + "phone_number," + "weekday," + "rating," + "myrating," + "mycomment," + "image_path," + "tag1," + "tag2," + "tag3," + "tag4," + "tag5," + "place_id" + ")"; query += " VALUES(NULL," + "'" + jn["result"]["name"].Get <string>() + "'," + "'" + jn["result"]["formatted_address"].Get <string>() + "'," + "'" + jn["result"]["formatted_phone_number"].Get <string>() + "'," + "''," + jn["result"]["rating"].Get <double>() + "," + "0" + "," + "''," + "'" + filepath + "'" + "''," + "''," + "''," + "''," + "''," + jn["result"]["place_id"].Get <int>() + ")"; Debug.Log(query); // データ追加 int result = DBControll.execute(query); return(result); }
//------------------------------------------ /// <summary> /// json型の値を保存 /// </summary> /// <param name="id">ユニークID</param> /// <param name="json">Json.</param> //------------------------------------------ public static int dataInsert(string json, string filepath = "") { JsonNode jn = jsonDecode(json); string query = "INSERT INTO " + tablename; /* * query += * " VALUES(NULL," + * "'" + jn["result"]["name"].Get<string>() + "'," + * "'" + jn["result"]["formatted_address"].Get<string>() + "'," + * "'" + jn["result"]["formatted_phone_number"].Get<string>() + "'," + * "''," + * jn["result"]["rating"].Get<double>() + "," + * "0" +"," + * "''," + * "'" + filepath + "'," + * "''," + * "''," + * "''," + * "''," + * "''," + * "'" + jn["result"]["place_id"].Get<string>() + "'," + * ")"; */ query += " VALUES(NULL," + "'" + jn["result"]["name"].Get <string>() + "'," + "'" + jn["result"]["formatted_address"].Get <string>() + "'," + "'" + jn["result"]["formatted_phone_number"].Get <string>() + "'," + "''," + jn["result"]["rating"].Get <double>() + "," + "0," + "''," + "'" + filepath + "'," + "''," + "''," + "''," + "''," + "''," + "'" + jn["result"]["place_id"].Get <string>() + "'" + ")"; Debug.Log(query); // データ追加 int result = DBControll.execute(query); return(result); }
/// <summary> /// データを1件取得 /// </summary> /// <param name="where"></param> /// <returns></returns> public static DataRow getOneData(string where) { DataTable dt = new DataTable(); string query = "SELECT * FROM " + tablename + " WHERE " + where + ";"; // データを取得 dt = DBControll.select(query); if (dt == null) { return(null); } else { return(dt[0]); } }
/// <summary> /// 最新のIdを1件取得 /// </summary> /// <param name="where"></param> /// <returns></returns> public static int getMaxId() { DataTable dt = new DataTable(); string query = "SELECT max(id) AS id FROM " + tablename + ";"; // データを取得 dt = DBControll.select(query); if (dt == null) { return(0); } else { return((int)dt.Rows[0]["id"]); } }
/// <summary> /// データを複数件取得 /// </summary> /// <param name="where"></param> /// <returns></returns> public static DataTable getData(string where = "") { DataTable dt = new DataTable(); string query = ""; if (where.Equals("")) { query = "SELECT * FROM " + tablename + ";"; } else { query = "SELECT * FROM " + tablename + " WHERE " + where + ";"; } // データを取得 dt = DBControll.select(query); Debug.Log(query); return(dt); }
public void pushDecideButton() { string query = "update jtable set myrating =" + rateNum.ToString() + ", mycomment = '" + comment.text + "' where id = " + SceneUtility.photoid.ToString(); DBControll.execute(query); float tempRateNum = rateNum / 5.0f; //詳細画面の評価も変更する controller.reviewStars.fillAmount = tempRateNum; controller.reviewNumber.text = rateNum.ToString(); controller.myReviewStars.fillAmount = tempRateNum; controller.myComment.text = comment.text; reviewView.SetActive(false); if (comment.text != "") { controller.myCommentView.SetActive(true); } }
//データのデリート処理を行う public void executeDeleteData() { bool checkflg = false; int count = listViewNodes.Count; for (int i = 0; i < count; i++) { //デリーとフラグが立っていればデータベースの削除 if (listViewNodes[i].getDeleteFlg()) { checkflg = true; string query = "delete from jtable where id = " + listViewNodes[i].getDetailInfo().photoID.ToString(); DBControll.execute(query); } } //データベース内のデータを削除した場合は再読み込みを行う。 if (checkflg) { SceneManager.LoadScene("photoAlubum"); } if (listViewNodes.Count == 0) { noDataText.SetActive(true); } //終了処理 photoButton.SetActive(true); cancelButton.SetActive(false); mapButton.SetActive(true); this.mode = NORMAL_MODE; }
public void pushDecideButton() { string[] tagPart = comment.text.Split('#'); string query = "update jtable set myrating =" + rateNum.ToString() + ", mycomment = '" + tagPart[0] + "' where id = " + SceneUtility.photoid.ToString(); DBControll.execute(query); float tempRateNum = rateNum / 5.0f; //詳細画面の評価も変更する //controller.reviewStars.fillAmount = tempRateNum; //controller.reviewNumber.text = rateNum.ToString(); controller.myReviewStars.fillAmount = tempRateNum; controller.myComment.text = tagPart[0]; //Debug.Log(tagPart[1]); string tags = ""; string tagquery = ""; if (tagPart.Length != 1) { string[] tag = tagPart[1].Split(','); int i = 0; for (i = 0; i < tag.Length; i++) { if (tag[i] != null) { string str = tag[i].ToString(); Debug.Log(str); if (i != 0) { str = "," + str; } tags = tags + str; tagquery = "update jtable set tag" + (i + 1).ToString() + " = '" + tag[i].ToString() + "' where id = " + SceneUtility.photoid.ToString(); } else { } DBControll.execute(tagquery); } //残りはスペース for (; i < 5; i++) { tagquery = "update jtable set tag" + (i + 1).ToString() + " = '" + "" + "' where id = " + SceneUtility.photoid.ToString(); DBControll.execute(tagquery); } } controller.tagView.text = "tag:" + tags; //controller.tagView.text = "tag:" reviewView.SetActive(false); if (comment.text != "") { controller.myCommentView.SetActive(true); } }