public static List <string> Databases(string wild = null) { IntPtr intPtr = MySQL1.mysql_list_dbs(MySQL1.SQL, wild); List <string> result; if (intPtr == IntPtr.Zero) { result = null; } else { List <string> list = new List <string>(); for (ulong num = 0uL; num < MySQL1.mysql_num_rows(intPtr); num += 1uL) { IntPtr ptr = MySQL1.mysql_fetch_row(intPtr); list.Add(Marshal.PtrToStringAnsi(Marshal.ReadIntPtr(ptr))); } result = list; } return(result); }
public static MySQL1.Result Query(string query, bool skip = false) { MySQL1.Result result = null; MySQL1.Result result3; try { if (!MySQL1.IsReady && skip) { MySQL1.Result result2 = result; result3 = result2; return(result3); } MySQL1.IsReady = false; int num; if (Core.MySQL_UTF8) { num = MySQL1.mysql_query(MySQL1.SQL, query); } else { num = MySQL1.mysql_real_query(MySQL1.SQL, query, query.Length); } if (num != 0 || MySQL1.ErrorCode != 0u) { if (MySQL1.LogLevel > MySQL1.LogLevelType.NONE) { Helper.LogSQLError(MySQL1.Error(), true); } MySQL1.mysql_ping(MySQL1.SQL); MySQL1.IsReady = true; MySQL1.Result result2 = null; result3 = result2; return(result3); } if (MySQL1.LogLevel > MySQL1.LogLevelType.ERRORS) { Helper.LogSQL(query, false); } IntPtr intPtr = MySQL1.mysql_store_result(MySQL1.SQL); if (MySQL1.ErrorCode == 0u && !(intPtr == IntPtr.Zero)) { result = new MySQL1.Result(); result.Fields = MySQL1.mysql_num_fields(intPtr); result.Rows = MySQL1.mysql_num_rows(intPtr); int num2 = 0; while ((long)num2 < (long)((ulong)result.Fields)) { result.Field.Add((MySQL1.Field)Marshal.PtrToStructure(MySQL1.mysql_fetch_field(intPtr), typeof(MySQL1.Field))); num2++; } IntPtr value; while ((value = MySQL1.mysql_fetch_row(intPtr)) != IntPtr.Zero) { result.Row.Add(new MySQL1.Row(result, value)); } MySQL1.mysql_free_result(intPtr); } else { result = null; } } catch (Exception ex) { result = null; Helper.LogSQLError(query, false); Helper.LogSQLError(ex.Message.ToString(), true); } MySQL1.IsReady = true; result3 = result; return(result3); }