diff --git a/Matomat/App.config b/Matomat/App.config
index f7ae6c7..b6c6250 100644
--- a/Matomat/App.config
+++ b/Matomat/App.config
@@ -3,5 +3,11 @@
+
+
+
+
+
+
\ No newline at end of file
diff --git a/Matomat/Config.cs b/Matomat/Config.cs
index 7d53baf..65c35fc 100644
--- a/Matomat/Config.cs
+++ b/Matomat/Config.cs
@@ -23,6 +23,7 @@ namespace Matomat
static List instances;
private AppSettingsReader config;
+
public Config()
{
this.config = new AppSettingsReader();
@@ -34,6 +35,12 @@ namespace Matomat
{
this.com_display = (string)config.GetValue("com_display", typeof(string));
this.com_rfid = (string)config.GetValue("com_rfid", typeof(string));
+ this.mysql_server = (string)config.GetValue("mysql_server", typeof(string));
+ this.mysql_user = (string)config.GetValue("mysql_user", typeof(string));
+ this.mysql_db = (string)config.GetValue("mysql_db", typeof(string));
+ this.mysql_port = (int)config.GetValue("mysql_port", typeof(int));
+ this.mysql_pw = (string)config.GetValue("mysql_pw", typeof(string));
+ this.mysql_driver = (string)config.GetValue("mysql_driver", typeof(string));
}
catch (Exception) { }
}
@@ -54,5 +61,17 @@ namespace Matomat
public string com_display { get; set; }
public string com_rfid { get; set; }
+
+ public string mysql_server { get; set; }
+
+ public string mysql_user { get; set; }
+
+ public string mysql_db { get; set; }
+
+ public int mysql_port { get; set; }
+
+ public string mysql_pw { get; set; }
+
+ public string mysql_driver { get; set; }
}
}
diff --git a/Matomat/DBDriverMysqli.cs b/Matomat/DBDriverMysqli.cs
new file mode 100644
index 0000000..bc29b23
--- /dev/null
+++ b/Matomat/DBDriverMysqli.cs
@@ -0,0 +1,91 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using MySql.Data;
+using MySql.Data.MySqlClient;
+
+namespace Matomat
+{
+ class DBDriverMysqli : Database
+ {
+ MySqlConnection conn;
+ private Exception err;
+ private bool data_b;
+ private MySqlDataReader data;
+ public DBDriverMysqli()
+ {
+
+ }
+ public override bool connect(string server, string dbs, string user, string pw, int port, string driver)
+ {
+ try
+ {
+ this.conn = new MySqlConnection("server=" + server + ";user=" + user + ";database=" + dbs + ";port=" + port + ";password=" + pw + ";");
+ }
+ catch (Exception e)
+ {
+ this.err = e;
+ return false;
+ }
+ new MySqlCommand("SET NAMES 'UTF8'", this.conn).ExecuteNonQuery();
+ new MySqlCommand("SET CHARACTER SET 'UTF8'", this.conn).ExecuteNonQuery();
+ return true;
+ }
+ public override void query(string sql)
+ {
+ this.err = null;
+ if (sql.ToUpper().Substring(0, 6) == "SELECT")
+ this.select(sql);
+ else if (sql.ToUpper().Substring(0, 6) == "INSERT")
+ this.insert(sql);
+ else if (sql.ToUpper().Substring(0, 6) == "UPDATE")
+ this.update(sql);
+ else if (sql.ToUpper().Substring(0, 6) == "DELETE")
+ this.delete(sql);
+ else if (sql.ToUpper().Substring(0, 8) == "TRUNCATE")
+ this.truncate(sql);
+ else if (sql.ToUpper().Substring(0, 6) == "CREATE")
+ this.create(sql);
+ else if (sql.ToUpper().Substring(0, 3) == "SET")
+ this.set(sql);
+ else
+ this.err = new Exception("Keine unterstütze MySQL Abfrage '" + sql + "'...");
+ }
+
+ private void select(string sql)
+ {
+ this.data_b = true;
+ try
+ {
+ MySqlCommand cmd = new MySqlCommand(sql, this.conn);
+ this.data = cmd.ExecuteReader();
+ }
+ catch (Exception e)
+ {
+ this.err = e;
+ this.data_b = false;
+ this.data = null;
+ }
+ }
+ public override List