diff options
author | onefang | 2019-08-22 15:46:57 +1000 |
---|---|---|
committer | onefang | 2019-08-22 15:46:57 +1000 |
commit | fe55626fcf7c1fda244db5e0c4f91ad7d0704c64 (patch) | |
tree | cd71b921cd963f7c64393dcb604c621c5b38ff4c | |
parent | When the generate map command is given, generate the map. (diff) | |
download | opensim-SC-fe55626fcf7c1fda244db5e0c4f91ad7d0704c64.zip opensim-SC-fe55626fcf7c1fda244db5e0c4f91ad7d0704c64.tar.gz opensim-SC-fe55626fcf7c1fda244db5e0c4f91ad7d0704c64.tar.bz2 opensim-SC-fe55626fcf7c1fda244db5e0c4f91ad7d0704c64.tar.xz |
Function for MYSQL joins.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MySQL/MySQLRaw.cs | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/OpenSim/Data/MySQL/MySQLRaw.cs b/OpenSim/Data/MySQL/MySQLRaw.cs index e8f80aa..bb8c96c 100644 --- a/OpenSim/Data/MySQL/MySQLRaw.cs +++ b/OpenSim/Data/MySQL/MySQLRaw.cs | |||
@@ -40,6 +40,57 @@ namespace OpenSim.Data.MySQL | |||
40 | return result; | 40 | return result; |
41 | } | 41 | } |
42 | 42 | ||
43 | public List< Hashtable > Join(string table, string select, string join, string wher, string order) | ||
44 | { | ||
45 | if ("" == select) | ||
46 | select = "*"; | ||
47 | string query = "SELECT " + select + " FROM " + table; | ||
48 | if ("" != join) | ||
49 | query = query + " " + join; | ||
50 | if ("" != wher) | ||
51 | query = query + " WHERE " + wher; | ||
52 | if ("" != order) | ||
53 | query = query + " ORDER BY " + order; | ||
54 | |||
55 | using (MySqlConnection dbcon = new MySqlConnection(m_connectString)) | ||
56 | { | ||
57 | dbcon.Open(); | ||
58 | MySqlCommand cmd = new MySqlCommand(query, dbcon); | ||
59 | MySqlDataReader rdr = cmd.ExecuteReader(); | ||
60 | List<string> names = new List<string>(); | ||
61 | DataTable schema = rdr.GetSchemaTable(); | ||
62 | List< Hashtable > list = new List< Hashtable >(); | ||
63 | |||
64 | foreach (DataRow row in schema.Rows) | ||
65 | { | ||
66 | string tbl = ""; | ||
67 | string nm = ""; | ||
68 | string tp = ""; | ||
69 | foreach (DataColumn col in schema.Columns) | ||
70 | { | ||
71 | if ("BaseTableName" == col.ColumnName) tbl = row[col].ToString(); | ||
72 | if ("ColumnName" == col.ColumnName) nm = row[col].ToString(); | ||
73 | if ("DataType" == col.ColumnName) tp = row[col].ToString(); | ||
74 | } | ||
75 | names.Add(nm); | ||
76 | } | ||
77 | |||
78 | while (rdr.Read()) | ||
79 | { | ||
80 | Hashtable r = new Hashtable(); | ||
81 | foreach (string name in names) | ||
82 | { | ||
83 | r[name] = rdr[name]; | ||
84 | } | ||
85 | list.Add(r); | ||
86 | } | ||
87 | |||
88 | rdr.Close(); | ||
89 | dbcon.Close(); | ||
90 | return list; | ||
91 | } | ||
92 | } | ||
93 | |||
43 | public List< Hashtable > Select(string table, string select, string wher, string order) | 94 | public List< Hashtable > Select(string table, string select, string wher, string order) |
44 | { | 95 | { |
45 | if ("" == select) | 96 | if ("" == select) |