IEnumerator GetColumnTypesQ(String input, string baseData) { string url = "http://www.williamrobertfunk.com/applications/vedic/actions/query.php"; WWWForm form = new WWWForm(); form.AddField("dbname", dbname.text); form.AddField("hostname", hostname.text); form.AddField("username", username.text); form.AddField("password", password.text); form.AddField("query", input); UnityWebRequest www = UnityWebRequest.Post(url, form); yield return(www.Send()); if (www.isError) { Debug.Log(www.error); } else { VedicDatabase.db = DatabaseBuilder.ConstructDB(dbname.text, baseData); VedicDatabase.isDatabaseNull = false; string reply = www.downloadHandler.text; string podData = reply.Substring(reply.IndexOf("##SelectTable##:{") + 17); // This Table ID sould be unlike original import // It should consist of a combo db name it came from, and select query random unique hash SelectTable sTable = new SelectTable(podData, "DTypes", "FunkDataTypesTable"); DatabaseUtilities.Table t = sTable.GetTable(); List <string> colTypes = new List <string>(); for (int i = 0; i < t.columns[0].fields.Count; i++) { colTypes.Add(t.columns[0].fields[i]); } int numOfColumns = VedicDatabase.GetNumOfColumns(); List <string> colTypes2 = new List <string>(); for (int i = (colTypes.Count - numOfColumns); i < colTypes.Count; i++) { colTypes2.Add(colTypes[i]); } int counter = 0; for (int j = 0; j < VedicDatabase.db.tables.Count; j++) { for (int k = 0; k < VedicDatabase.db.tables[j].columns.Count && counter < colTypes2.Count; k++, counter++) { VedicDatabase.db.tables[j].columns[k].SetColor(VariableColorTable.GetVariableColor(colTypes2[counter])); VedicDatabase.db.tables[j].columns[k].SetType(colTypes2[counter]); } } GetKeyColumns("SELECT CONCAT(TABLE_NAME, '.', COLUMN_NAME) AS 'foreign key', " + "CONCAT(REFERENCED_TABLE_NAME, '.', REFERENCED_COLUMN_NAME) AS 'references' FROM " + "INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL"); } }
IEnumerator GetColumnTypesQ(String input, string baseData) { string url = "http://www.williamrobertfunk.com/applications/vedic/actions/query.php"; WWWForm form = new WWWForm(); form.AddField("dbname", dbname.text); form.AddField("hostname", hostname.text); form.AddField("username", username.text); form.AddField("password", password.text); form.AddField("query", input); UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.Send(); if (www.isError) { Debug.Log(www.error); } else { VedicDatabase.db = DatabaseBuilder.ConstructDB(dbname.text, baseData); VedicDatabase.isDatabaseNull = false; string reply = www.downloadHandler.text; string podData = reply.Substring(reply.IndexOf("##SelectTable##:{") + 17); // This Table ID sould be unlike original import // It should consist of a combo db name it came from, and select query random unique hash SelectTable sTable = new SelectTable(podData, "DTypes", "FunkDataTypesTable"); DatabaseUtilities.Table t = sTable.GetTable(); List<string> colTypes = new List<string>(); for (int i = 0; i < t.columns[0].fields.Count; i++) { colTypes.Add(t.columns[0].fields[i]); } int numOfColumns = VedicDatabase.GetNumOfColumns(); List<string> colTypes2 = new List<string>(); for (int i = (colTypes.Count - numOfColumns); i < colTypes.Count; i++) { colTypes2.Add(colTypes[i]); } int counter = 0; for (int j = 0; j < VedicDatabase.db.tables.Count; j++) { for(int k = 0; k < VedicDatabase.db.tables[j].columns.Count && counter < colTypes2.Count; k++, counter++) { VedicDatabase.db.tables[j].columns[k].SetColor(VariableColorTable.GetVariableColor(colTypes2[counter])); VedicDatabase.db.tables[j].columns[k].SetType(colTypes2[counter]); } } GetKeyColumns("SELECT CONCAT(TABLE_NAME, '.', COLUMN_NAME) AS 'foreign key', " + "CONCAT(REFERENCED_TABLE_NAME, '.', REFERENCED_COLUMN_NAME) AS 'references' FROM " + "INFORMATION_SCHEMA.KEY_COLUMN_USAGE WHERE REFERENCED_TABLE_NAME IS NOT NULL"); } }
IEnumerator GetKeyColumnsQ(String input) { string url = "http://www.williamrobertfunk.com/applications/vedic/actions/query.php"; WWWForm form = new WWWForm(); form.AddField("dbname", dbname.text); form.AddField("hostname", hostname.text); form.AddField("username", username.text); form.AddField("password", password.text); form.AddField("query", input); UnityWebRequest www = UnityWebRequest.Post(url, form); yield return www.Send(); if (www.isError) { Debug.Log(www.error); } else { string reply = www.downloadHandler.text; string podData = reply.Substring(reply.IndexOf("##SelectTable##:{") + 17); // This Table ID sould be unlike original import // It should consist of a combo db name it came from, and select query random unique hash SelectTable sTable = new SelectTable(podData, "Keys", "FunkKeysTable"); DatabaseUtilities.Table t = sTable.GetTable(); for (int i = 0; i < t.columns[0].fields.Count; i++) { int tabIndex = -1; int colIndex = -1; string fKey = t.columns[0].fields[i]; string referenced = t.columns[1].fields[i]; if (fKey != null && referenced != null && fKey.Length > 0 && referenced.Length > 0) { for (int j = 0; j < VedicDatabase.db.tables.Count; j++) { if (VedicDatabase.db.tables[j].GetName() == referenced.Substring(0, referenced.IndexOf('.'))) { tabIndex = j; break; } } if (tabIndex < 0) continue; for (int k = 0; k < VedicDatabase.db.tables[tabIndex].columns.Count; k++) { if (VedicDatabase.db.tables[tabIndex].columns[k].GetName() == referenced.Substring(referenced.IndexOf('.') + 1)) { colIndex = k; break; } } if (colIndex < 0) continue; VedicDatabase.db.tables[tabIndex].columns[colIndex].AddFKey(fKey.Substring(0, fKey.IndexOf('.')), fKey.Substring(fKey.IndexOf('.') + 1)); } } GameObject.FindGameObjectWithTag("Analytics").GetComponent<AnalyticManager>().BuildAnalytics(); ViewAssembler.GenerateViewObject(VedicDatabase.db, false, false, -1); } }
IEnumerator GetKeyColumnsQ(String input) { string url = "http://www.williamrobertfunk.com/applications/vedic/actions/query.php"; WWWForm form = new WWWForm(); form.AddField("dbname", dbname.text); form.AddField("hostname", hostname.text); form.AddField("username", username.text); form.AddField("password", password.text); form.AddField("query", input); UnityWebRequest www = UnityWebRequest.Post(url, form); yield return(www.Send()); if (www.isError) { Debug.Log(www.error); } else { string reply = www.downloadHandler.text; string podData = reply.Substring(reply.IndexOf("##SelectTable##:{") + 17); // This Table ID sould be unlike original import // It should consist of a combo db name it came from, and select query random unique hash SelectTable sTable = new SelectTable(podData, "Keys", "FunkKeysTable"); DatabaseUtilities.Table t = sTable.GetTable(); for (int i = 0; i < t.columns[0].fields.Count; i++) { int tabIndex = -1; int colIndex = -1; string fKey = t.columns[0].fields[i]; string referenced = t.columns[1].fields[i]; if (fKey != null && referenced != null && fKey.Length > 0 && referenced.Length > 0) { for (int j = 0; j < VedicDatabase.db.tables.Count; j++) { if (VedicDatabase.db.tables[j].GetName() == referenced.Substring(0, referenced.IndexOf('.'))) { tabIndex = j; break; } } if (tabIndex < 0) { continue; } for (int k = 0; k < VedicDatabase.db.tables[tabIndex].columns.Count; k++) { if (VedicDatabase.db.tables[tabIndex].columns[k].GetName() == referenced.Substring(referenced.IndexOf('.') + 1)) { colIndex = k; break; } } if (colIndex < 0) { continue; } VedicDatabase.db.tables[tabIndex].columns[colIndex].AddFKey(fKey.Substring(0, fKey.IndexOf('.')), fKey.Substring(fKey.IndexOf('.') + 1)); } } GameObject.FindGameObjectWithTag("Analytics").GetComponent <AnalyticManager>().BuildAnalytics(); ViewAssembler.GenerateViewObject(VedicDatabase.db, false, false, -1); } }