' Gambas class file Private $sColumnSort As String Public Procedure _new() 'tvwTables definition tvwTables.Columns.Count = 7 tvwTables.Columns[0].Title = ("Name") tvwTables.Columns[1].Title = ("Rows") tvwTables.Columns[2].Title = ("Engine") tvwTables.Columns[3].Title = ("Charset") tvwTables.Columns[4].Title = ("Collation") tvwTables.Columns[5].Title = ("Size") tvwTables.Columns[6].Title = ("Update Time") 'tvwViews definition tvwViews.Columns.Count = 7 tvwViews.Columns[0].Title = ("Name") tvwViews.Columns[1].Title = ("Updatable") tvwViews.Columns[2].Title = ("Definer") tvwViews.Columns[3].Title = ("Security") tvwViews.Columns[4].Title = ("Check") tvwViews.Columns[5].Title = ("Charset") tvwViews.Columns[6].Title = ("Collation") 'tvwIndex definition tvwIndexes.Columns.Count = 4 tvwIndexes.Columns[0].Title = ("Name") tvwIndexes.Columns[1].Title = ("Column") tvwIndexes.Columns[2].Title = ("Collation") tvwIndexes.Columns[3].Title = ("Type") 'tvwProcedures definition tvwProcedures.Columns.Count = 8 tvwProcedures.Columns[0].Width = 30 tvwProcedures.Columns[1].Title = ("Name") tvwProcedures.Columns[2].Title = ("Returns") tvwProcedures.Columns[3].Title = ("Creation Time") tvwProcedures.Columns[4].Title = ("Update Time") tvwProcedures.Columns[5].Title = ("Type") tvwProcedures.Columns[6].Title = ("Definer") tvwProcedures.Columns[7].Title = ("Comment") 'tvwFields definition tvwFields.Columns.Count = 10 tvwFields.Columns[0].Width = 30 tvwFields.Columns[1].Title = ("Name") tvwFields.Columns[2].Title = ("Default") tvwFields.Columns[3].Title = ("Nullable") tvwFields.Columns[4].Title = ("DataType") tvwFields.Columns[5].Title = ("Key") tvwFields.Columns[6].Title = ("Extra") tvwFields.Columns[7].Title = ("Charset") tvwFields.Columns[8].Title = ("Collation") tvwFields.Columns[9].Title = ("Comment") 'tvwTrigger definition tvwTriggers.Columns.Count = 5 tvwTriggers.Columns[0].Title = ("Name") tvwTriggers.Columns[1].Title = ("Event") tvwTriggers.Columns[2].Title = ("Table") tvwTriggers.Columns[3].Title = ("Timing") tvwTriggers.Columns[4].Title = ("Definer") 'tvwEvents definition tvwEvents.Columns.Count = 19 tvwEvents.Columns[0].Title = ("Name") tvwEvents.Columns[1].Title = ("Definer") tvwEvents.Columns[2].Title = ("Time Zone") tvwEvents.Columns[3].Title = ("Type") tvwEvents.Columns[4].Title = ("Execute At") tvwEvents.Columns[5].Title = ("Interval Value") tvwEvents.Columns[6].Title = ("Interval Field") tvwEvents.Columns[7].Title = ("SQL Mode") tvwEvents.Columns[8].Title = ("Starts") tvwEvents.Columns[9].Title = ("Ends") tvwEvents.Columns[10].Title = ("On Completion") tvwEvents.Columns[11].Title = ("Created") tvwEvents.Columns[12].Title = ("Last Altered") tvwEvents.Columns[13].Title = ("Last Executed") tvwEvents.Columns[14].Title = ("Originator") tvwEvents.Columns[15].Title = ("Charset") tvwEvents.Columns[16].Title = ("Collation") tvwEvents.Columns[17].Title = ("Database Collation") tvwEvents.Columns[18].Title = ("Comment") Catch modMain.Error() End Public Procedure SearchInfo() 'Search for the info in the database Inc Application.Busy tvwTables.Clear() tvwTables.Rows.Count = 0 tvwViews.Clear() tvwViews.Rows.Count = 0 tvwIndexes.Clear() tvwIndexes.Rows.Count = 0 tvwFields.Clear() tvwFields.Rows.Count = 0 tvwProcedures.Clear() tvwProcedures.Rows.Count = 0 tvwTriggers.Clear() tvwTriggers.Rows.Count = 0 tvwEvents.Clear() tvwEvents.Rows.Count = 0 tabData[2].Text = ("Indexes") tabData[3].Text = ("Fields") 'Database's info textResult.Text = modMain.$Connection.MySQL.DataBase.Info(modMain.$Connection.Name) TableInfo() 'Returns if the database is information_schema If modMain.$Connection.Name = "information_schema" Then Dec Application.Busy Return Endif ViewInfo() IndexInfo() RoutinesInfo() TriggersInfo() If modMain.$bSchemaOk Then EventInfo() Dec Application.Busy Catch modMain.Error() End Public Procedure FieldInfo(Optional Column As Integer) 'Field's Info Dim iCounter As Integer If tvwTables.Rows.Count = 0 Or tvwTables.Row = -1 Then Return 'Empty set or not table selected tabData[3].Text = ("Fields on:") & " " & tvwTables[tvwTables.Row, 0].Text Select (Column) Case 1 $sColumnSort = "COLUMN_NAME" Case 2 $sColumnSort = "COLUMN_DEFAULT" Case 3 $sColumnSort = "IS_NULLABLE" Case 4 $sColumnSort = "COLUMN_TYPE" Case 5 $sColumnSort = "COLUMN_KEY" Case 6 $sColumnSort = "EXTRA" Case 7 $sColumnSort = "CHARACTER_SET_NAME" Case 8 $sColumnSort = "COLLATION_NAME" Case 9 $sColumnSort = "COLUMN_COMMENT" Default $sColumnSort = "COLUMN_NAME" End Select modMain.$hResult = modMain.$Connection.Exec("SELECT `COLUMN_KEY`, `DATA_TYPE`, `EXTRA`, `COLUMN_NAME`, `COLUMN_DEFAULT`, `IS_NULLABLE`, `COLUMN_TYPE`, `CHARACTER_SET_NAME`, `COLLATION_NAME`, `COLUMN_COMMENT` FROM `information_schema`.`COLUMNS` WHERE `TABLE_NAME` = '" & tvwTables[tvwTables.Row, 0].Text & "' AND `TABLE_SCHEMA` = '" & modMain.$Connection.Name & "' ORDER BY `" & $sColumnSort & "`") tvwFields.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max Select (Upper(modMain.$hResult!DATA_TYPE)) Case "INT", "MEDIUMINT", "TINYINT", "BOOL", "BOOLEAN", "SMALLINT", "INTEGER", "FLOAT", "BIGINT", "SERIAL", "DOUBLE", "DOUBLEPRECISION", "DECIMAL", "DEC" tvwFields[iCounter, 0].Picture = Picture["icons/16/Numeric.png"] Case "VARCHAR", "CHAR", "BIT", "BINARY", "VARBINARY", "TINYTEXT", "TEXT", "MEDIUMTEXT", "LONGTEXT", "SET", "ENUM" tvwFields[iCounter, 0].Picture = Picture["icons/16/String.png"] Case "DATE", "DATETIME", "TIME", "TIMESTAMP", "YEAR" tvwFields[iCounter, 0].Picture = Picture["icons/16/Datetime.png"] Case "TINYBLOB", "MEDIUMBLOB", "LONGBLOB", "BLOB" tvwFields[iCounter, 0].Picture = Picture["icons/16/Blob.png"] Default tvwFields[iCounter, 0].Picture = Picture["icons/16/Field.png"] End Select Select (Upper(modMain.$hResult!COLUMN_KEY)) Case "PRI" tvwFields[iCounter, 0].Picture = Picture["icons/16/Primarykey.png"] Case "MUL" tvwFields[iCounter, 0].Picture = Picture["icons/16/Column_FK.png"] Default End Select tvwFields[iCounter, 0].Alignment = Align.Center tvwFields[iCounter, 1].Text = modMain.$hResult!COLUMN_NAME tvwFields[iCounter, 2].Text = modMain.$hResult!COLUMN_DEFAULT tvwFields[iCounter, 3].Text = modMain.$hResult!IS_NULLABLE tvwFields[iCounter, 4].Text = modMain.$hResult!COLUMN_TYPE tvwFields[iCounter, 5].Text = modMain.$hResult!COLUMN_KEY tvwFields[iCounter, 6].Text = modMain.$hResult!EXTRA tvwFields[iCounter, 7].Text = modMain.$hResult!CHARACTER_SET_NAME tvwFields[iCounter, 8].Text = modMain.$hResult!COLLATION_NAME tvwFields[iCounter, 9].Text = modMain.$hResult!COLUMN_COMMENT If (iCounter Mod 2) = 0 Then tvwFields[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 4].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 5].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 6].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 7].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 8].Background = Color.RGB(239, 243, 247) tvwFields[iCounter, 9].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next tvwFields.Columns[0].Width = -1 tvwFields.Columns[1].Width = -1 tvwFields.Columns[2].Width = -1 tvwFields.Columns[3].Width = -1 tvwFields.Columns[4].Width = -1 tvwFields.Columns[5].Width = -1 tvwFields.Columns[6].Width = -1 tvwFields.Columns[7].Width = -1 tvwFields.Columns[8].Width = -1 tvwFields.Columns[9].Width = -1 Catch modMain.Error() End Public Procedure TableInfo(Optional Column As Integer) 'Table's Info Dim iCounter As Integer tvwTables.Clear() Select (Column) Case 0 $sColumnSort = "TABLE_NAME" Case 1 $sColumnSort = "TABLE_ROWS" Case 2 $sColumnSort = "ENGINE" Case 3 $sColumnSort = "CHARSET" Case 4 $sColumnSort = "TABLE_COLLATION" Case 5 $sColumnSort = "DATA_LENGTH" Case 6 $sColumnSort = "UPDATE_TIME" Default $sColumnSort = "TABLE_NAME" End Select modMain.$hResult = modMain.$Connection.Exec("SELECT `a`.`TABLE_NAME` AS `TABLE_NAME`, `a`.`ENGINE` AS ENGINE, `a`.`TABLE_ROWS` AS TABLE_ROWS, `a`.`UPDATE_TIME` AS UPDATE_TIME, `b`.`CHARACTER_SET_NAME` AS CHARSET, `a`.`TABLE_COLLATION` AS TABLE_COLLATION FROM `information_schema`.`TABLES` `a`, `information_schema`.`COLLATIONS` `b` WHERE `a`.`TABLE_SCHEMA` = '" & modMain.$Connection.Name & "' AND `a`.`TABLE_COLLATION` = `b`.`COLLATION_NAME` ORDER BY `" & $sColumnSort & "`") tvwTables.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max tvwTables[iCounter, 0].Text = modMain.$hResult!TABLE_NAME If modMain.$hResult!TABLE_ROWS <> Null Then tvwTables[iCounter, 1].Text = Format(modMain.$hResult!TABLE_ROWS, "#,#") tvwTables[iCounter, 1].Alignment = Align.Right tvwTables[iCounter, 2].Text = modMain.$hResult!ENGINE tvwTables[iCounter, 3].Text = modMain.$hResult!CHARSET tvwTables[iCounter, 4].Text = modMain.$hResult!TABLE_COLLATION If modMain.$hResult!UPDATE_TIME = Null tvwTables[iCounter, 6].Picture = Picture["icons/24/Null.png"] Else tvwTables[iCounter, 6].Text = modMain.$hResult!UPDATE_TIME Endif tvwTables[iCounter, 5].Text = Format((modMain.$Connection.Exec("SELECT `DATA_LENGTH` FROM `information_schema`.`TABLES` WHERE `TABLE_SCHEMA` = '" & modMain.$Connection.Name & "' AND `TABLE_NAME` = '" & modMain.$hResult!TABLE_NAME & "'")!DATA_LENGTH / 1024), "#,#.00 KB") tvwTables[iCounter, 5].Alignment = Align.Right If (iCounter Mod 2) = 0 Then tvwTables[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 4].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 5].Background = Color.RGB(239, 243, 247) tvwTables[iCounter, 6].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next tvwTables.Columns[0].Width = -1 tvwTables.Columns[1].Width = -1 tvwTables.Columns[2].Width = -1 tvwTables.Columns[3].Width = -1 tvwTables.Columns[4].Width = -1 tvwTables.Columns[5].Width = -1 tvwTables.Columns[6].Width = -1 Catch modMain.Error() End Public Procedure ViewInfo(Optional Column As Integer) 'View's Info Dim iCounter As Integer Select (Column) Case 0 $sColumnSort = "TABLE_NAME" Case 1 $sColumnSort = "IS_UPDATABLE" Case 2 $sColumnSort = "DEFINER" Case 3 $sColumnSort = "SECURITY_TYPE" Case 4 $sColumnSort = "CHECK_OPTION" Case 5 $sColumnSort = "CHARACTER_SET_CLIENT" Case 6 $sColumnSort = "COLLATION_CONNECTION" Default $sColumnSort = "TABLE_NAME" End Select modMain.$hResult = modMain.$Connection.Exec("SELECT * FROM `information_schema`.`VIEWS` WHERE `TABLE_SCHEMA` = '" & modMain.$Connection.Name & "' ORDER BY `" & $sColumnSort & "`") tvwViews.Rows.Count = modMain.$hResult.Count If modMain.$hResult.Available Then tvwViews.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max tvwViews[iCounter, 0].Text = modMain.$hResult!TABLE_NAME tvwViews[iCounter, 1].Text = modMain.$hResult!IS_UPDATABLE tvwViews[iCounter, 2].Text = modMain.$hResult!DEFINER tvwViews[iCounter, 3].Text = modMain.$hResult!SECURITY_TYPE tvwViews[iCounter, 4].Text = modMain.$hResult!CHECK_OPTION If modMain.$bSchemaOk Then tvwViews[iCounter, 5].Text = modMain.$hResult!CHARACTER_SET_CLIENT tvwViews[iCounter, 6].Text = modMain.$hResult!COLLATION_CONNECTION Else tvwViews[iCounter, 5].Text = ("Not aviable") tvwViews[iCounter, 6].Text = ("Not aviable") Endif If (iCounter Mod 2) = 0 Then tvwViews[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 4].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 5].Background = Color.RGB(239, 243, 247) tvwViews[iCounter, 6].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next Endif tvwViews.Columns[0].Width = -1 tvwViews.Columns[1].Width = -1 tvwViews.Columns[2].Width = -1 tvwViews.Columns[3].Width = -1 tvwViews.Columns[4].Width = -1 tvwViews.Columns[5].Width = -1 tvwViews.Columns[6].Width = -1 Catch modMain.Error() End Public Procedure IndexInfo(Optional Column As Integer) 'Index's Info Dim iCounter As Integer If tvwTables.Rows.Count = 0 Or tvwTables.Row = -1 Then Return 'Empty set or not table selected tabData[2].Text = ("Indexes on:") & " " & tvwTables[tvwTables.Row, 0].Text tvwIndexes.Clear() ' Select (Column) ' Case 0 ' $sColumnSort = "Key_name" ' Case 1 ' $sColumnSort = "Column_name" ' Case 2 ' $sColumnSort = "Collation" ' Case 3 ' $sColumnSort = "Index_type" ' Default ' $sColumnSort = "Key_name" ' End Select modMain.$hResult = modMain.$Connection.Exec("SHOW INDEX FROM `" & modMain.$Connection.Name & "`.`" & tvwTables[tvwTables.Row, 0].Text & "`") If modMain.$hResult.Available Then tvwIndexes.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max tvwIndexes[iCounter, 0].Text = modMain.$hResult!Key_name tvwIndexes[iCounter, 1].Text = modMain.$hResult!Column_name tvwIndexes[iCounter, 2].Text = modMain.$hResult!Collation tvwIndexes[iCounter, 3].Text = modMain.$hResult!Index_type If (iCounter Mod 2) = 0 Then tvwIndexes[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwIndexes[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwIndexes[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwIndexes[iCounter, 3].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next Endif tvwIndexes.Columns[0].Width = -1 tvwIndexes.Columns[1].Width = -1 tvwIndexes.Columns[2].Width = -1 tvwIndexes.Columns[3].Width = -1 Catch modMain.Error() End Public Procedure RoutinesInfo(Optional Column As Integer) 'Rotines's Info Dim iCounter As Integer tvwProcedures.Clear() Select (Column) Case 0 $sColumnSort = "ROUTINE_TYPE" Case 1 $sColumnSort = "ROUTINE_NAME" Case 2 $sColumnSort = "DTD_IDENTIFIER" Case 3 $sColumnSort = "CREATED" Case 4 $sColumnSort = "LAST_ALTERED" Case 5 $sColumnSort = "ROUTINE_TYPE" Case 6 $sColumnSort = "DEFINER" Case 7 $sColumnSort = "ROUTINE_COMMENT" Default $sColumnSort = "ROUTINE_NAME" End Select modMain.$hResult = modMain.$Connection.Exec("SELECT * FROM `information_schema`.`ROUTINES` WHERE `ROUTINE_SCHEMA` = '" & modMain.$Connection.Name & "' ORDER BY `" & $sColumnSort & "`") If modMain.$hResult.Available Then tvwProcedures.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max If modMain.$hResult!ROUTINE_TYPE = "FUNCTION" Then tvwProcedures[iCounter, 0].Picture = Picture["icons/16/Function.png"] Else tvwProcedures[iCounter, 0].Picture = Picture["icons/16/Routine.png"] Endif tvwProcedures[iCounter, 0].Alignment = Align.Center tvwProcedures[iCounter, 1].Text = modMain.$hResult!ROUTINE_NAME tvwProcedures[iCounter, 2].Text = modMain.$hResult!DTD_IDENTIFIER tvwProcedures[iCounter, 3].Text = modMain.$hResult!CREATED tvwProcedures[iCounter, 4].Text = modMain.$hResult!LAST_ALTERED tvwProcedures[iCounter, 5].Text = modMain.$hResult!ROUTINE_TYPE tvwProcedures[iCounter, 6].Text = modMain.$hResult!DEFINER tvwProcedures[iCounter, 7].Text = modMain.$hResult!ROUTINE_COMMENT If (iCounter Mod 2) = 0 Then tvwProcedures[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 4].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 5].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 6].Background = Color.RGB(239, 243, 247) tvwProcedures[iCounter, 7].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next Endif tvwProcedures.Columns[0].Width = -1 tvwProcedures.Columns[1].Width = -1 tvwProcedures.Columns[2].Width = -1 tvwProcedures.Columns[3].Width = -1 tvwProcedures.Columns[4].Width = -1 tvwProcedures.Columns[5].Width = -1 tvwProcedures.Columns[6].Width = -1 tvwProcedures.Columns[7].Width = -1 Catch modMain.Error() End Public Procedure EventInfo(Optional Column As Integer) 'Event's Info Dim iCounter As Integer tvwEvents.Clear() Select (Column) Case 0 $sColumnSort = "EVENT_NAME" Case 1 $sColumnSort = "DEFINER" Case 2 $sColumnSort = "TIME_ZONE" Case 3 $sColumnSort = "EVENT_TYPE" Case 4 $sColumnSort = "EXECUTE_AT" Case 5 $sColumnSort = "INTERVAL_VALUE" Case 6 $sColumnSort = "INTERVAL_FIELD" Case 7 $sColumnSort = "SQL_MODE" Case 8 $sColumnSort = "STARTS" Case 9 $sColumnSort = "ENDS" Case 10 $sColumnSort = "ON_COMPLETION" Case 11 $sColumnSort = "CREATED" Case 12 $sColumnSort = "LAST_ALTERED" Case 13 $sColumnSort = "LAST_EXECUTED" Case 14 $sColumnSort = "ORIGINATOR" Case 15 $sColumnSort = "CHARACTER_SET_CLIENT" Case 16 $sColumnSort = "COLLATION_CONNECTION" Case 17 $sColumnSort = "DATABASE_COLLATION" Case 18 $sColumnSort = "EVENT_COMMENT" Default $sColumnSort = "EVENT_NAME" End Select modMain.$hResult = modMain.$Connection.Exec("SELECT * FROM `information_schema`.`EVENTS` WHERE `EVENT_SCHEMA` = '" & modMain.$Connection.Name & "' ORDER BY `" & $sColumnSort & "`") If modMain.$hResult.Available Then tvwEvents.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max tvwEvents[iCounter, 0].Text = modMain.$hResult!EVENT_NAME tvwEvents[iCounter, 1].Text = modMain.$hResult!DEFINER tvwEvents[iCounter, 2].Text = modMain.$hResult!TIME_ZONE tvwEvents[iCounter, 3].Text = modMain.$hResult!EVENT_TYPE tvwEvents[iCounter, 4].Text = modMain.$hResult!EXECUTE_AT tvwEvents[iCounter, 5].Text = modMain.$hResult!INTERVAL_VALUE tvwEvents[iCounter, 6].Text = modMain.$hResult!INTERVAL_FIELD tvwEvents[iCounter, 7].Text = modMain.$hResult!SQL_MODE tvwEvents[iCounter, 8].Text = modMain.$hResult!STARTS tvwEvents[iCounter, 9].Text = modMain.$hResult!ENDS tvwEvents[iCounter, 10].Text = modMain.$hResult!ON_COMPLETION tvwEvents[iCounter, 11].Text = modMain.$hResult!CREATED tvwEvents[iCounter, 12].Text = modMain.$hResult!LAST_ALTERED tvwEvents[iCounter, 13].Text = modMain.$hResult!LAST_EXECUTED tvwEvents[iCounter, 14].Text = modMain.$hResult!ORIGINATOR tvwEvents[iCounter, 15].Text = modMain.$hResult!CHARACTER_SET_CLIENT tvwEvents[iCounter, 16].Text = modMain.$hResult!COLLATION_CONNECTION tvwEvents[iCounter, 17].Text = modMain.$hResult!DATABASE_COLLATION tvwEvents[iCounter, 18].Text = modMain.$hResult!EVENT_COMMENT If (iCounter Mod 2) = 0 Then tvwEvents[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 4].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 5].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 6].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 7].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 8].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 9].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 10].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 11].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 12].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 13].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 14].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 15].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 16].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 17].Background = Color.RGB(239, 243, 247) tvwEvents[iCounter, 18].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next Endif tvwEvents.Columns[0].Width = -1 tvwEvents.Columns[1].Width = -1 tvwEvents.Columns[2].Width = -1 tvwEvents.Columns[3].Width = -1 tvwEvents.Columns[4].Width = -1 tvwEvents.Columns[5].Width = -1 tvwEvents.Columns[6].Width = -1 tvwEvents.Columns[7].Width = -1 tvwEvents.Columns[8].Width = -1 tvwEvents.Columns[9].Width = -1 tvwEvents.Columns[10].Width = -1 tvwEvents.Columns[11].Width = -1 tvwEvents.Columns[12].Width = -1 tvwEvents.Columns[13].Width = -1 tvwEvents.Columns[14].Width = -1 tvwEvents.Columns[15].Width = -1 tvwEvents.Columns[16].Width = -1 tvwEvents.Columns[17].Width = -1 tvwEvents.Columns[18].Width = -1 Catch modMain.Error() End Public Procedure TriggersInfo(Optional Column As Integer) 'Table's Info Dim iCounter As Integer tvwTriggers.Clear() Select (Column) Case 0 $sColumnSort = "TRIGGER_NAME" Case 1 $sColumnSort = "EVENT_MANIPULATION" Case 2 $sColumnSort = "EVENT_OBJECT_TABLE" Case 3 $sColumnSort = "ACTION_TIMING" Case 4 $sColumnSort = "DEFINER" Default $sColumnSort = "TRIGGER_NAME" End Select 'Triggers Info modMain.$hResult = modMain.$Connection.Exec("SELECT `TRIGGER_NAME`, `EVENT_MANIPULATION`, `EVENT_OBJECT_TABLE`, `ACTION_TIMING`, `DEFINER` FROM `information_schema`.`TRIGGERS` WHERE `TRIGGER_SCHEMA` = '" & modMain.$Connection.Name & "' ORDER BY `" & $sColumnSort & "`") If modMain.$hResult.Available Then tvwTriggers.Rows.Count = modMain.$hResult.Count For iCounter = 0 To modMain.$hResult.Max tvwTriggers[iCounter, 0].Text = modMain.$hResult!TRIGGER_NAME tvwTriggers[iCounter, 1].Text = modMain.$hResult!EVENT_MANIPULATION tvwTriggers[iCounter, 2].Text = modMain.$hResult!EVENT_OBJECT_TABLE tvwTriggers[iCounter, 3].Text = modMain.$hResult!ACTION_TIMING tvwTriggers[iCounter, 4].Text = modMain.$hResult!DEFINER If (iCounter Mod 2) = 0 Then tvwTriggers[iCounter, 0].Background = Color.RGB(239, 243, 247) tvwTriggers[iCounter, 1].Background = Color.RGB(239, 243, 247) tvwTriggers[iCounter, 2].Background = Color.RGB(239, 243, 247) tvwTriggers[iCounter, 3].Background = Color.RGB(239, 243, 247) tvwTriggers[iCounter, 4].Background = Color.RGB(239, 243, 247) Endif modMain.$hResult.MoveNext() Next Endif tvwTriggers.Columns[0].Width = -1 tvwTriggers.Columns[1].Width = -1 tvwTriggers.Columns[2].Width = -1 tvwTriggers.Columns[3].Width = -1 tvwTriggers.Columns[4].Width = -1 Catch modMain.Error() End Public Sub Form_Open() Me.Text = "mysql://" & modMain.$Connection.User & "@" & modMain.$Connection.Host & "/" & modMain.$Connection.Name cmbDatabases.List = modMain.$Connection.MySQL.Databases cmbDatabases.Index = cmbDatabases.Find(modMain.$Connection.Name) SearchInfo() End '***************************** Procedures for tables ************************** Public Sub tvwTables_Select() If tvwTables.Row = -1 Then Return textResult.Clear() textResult.Text = modMain.$Connection.MySQL.Table.Info(tvwTables[tvwTables.Row, 0].Text) FieldInfo() IndexInfo() Select (tvwTables.Column) Case 0 tvwTables.Edit() Case 1, 5 Return Case 2 tvwTables.Edit(modMain.$Connection.MySQL.Engines, True) Case 3 tvwTables.Edit(modMain.$Connection.MySQL.Charsets, True) Case 4 tvwTables.Edit(modMain.$Connection.MySQL.Collations, True) Default tvwTables.Edit() End Select Catch modMain.Error() End Public Sub tvwTables_Save(Row As Integer, Column As Integer, Value As String) 'Alters the table definition, the value is never saved into the TableView, it is used to make the update If tbtLock.Value Then Return Select (Column) Case 0 modMain.$Connection.MySQL.Table.Rename(tvwTables[Row, 0].Text, Value) Case 1, 5 Return Case 2 modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[Row, 0].Text, "ENGINE",, Value) Case 3 modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[Row, 0].Text, "CHARACTER SET",, Value & " COLLATE " & Value & "_bin") Case 4 modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[Row, 0].Text, "CHARACTER SET",, tvwTables[Row, 3].Text & " COLLATE " & Value) Default End Select RefreshData(tvwTables.Row, tabData.Index) Catch modMain.Error() End Public Sub tvwTables_DblClick() tabData.Index = 3 'Fields End '***************************** End of Procedures for tables ******************* '***************************** Procedures for views *************************** Public Sub tvwViews_Click() If tvwViews.Row = -1 Then Return textResult.Text = modMain.$Connection.MySQL.View.Info(tvwViews[tvwViews.Row, 0].Text) ViewInfo() Catch modMain.Error() End Public Sub tvwViews_DblClick() modMain.$hFNewView = New FNewView(Null, tvwViews[tvwViews.Row, 0].Text) modMain.$hFNewView.ShowModal() Catch modMain.Error() End Public Sub tvwViews_Select() tvwViews_Click() End '***************************** End of Procedures for views ******************** '***************************** Procedures for fields ********************* Public Sub tvwFields_Click() 'If the tbtLock is true then the change is not made If tbtLock.Value Then Return Select (tvwFields.Column) Case 0, 5, 6 Return Case 1, 2, 9 tvwFields.Edit() Case 3 tvwFields.Edit(["YES", "NO"], True) Case 7 tvwFields.Edit(modMain.$Connection.MySQL.Charsets, True) Case 8 tvwFields.Edit(modMain.$Connection.MySQL.Collations, True) Default tvwFields.Edit() End Select Catch modMain.Error() End Public Sub tvwFields_DblClick() 'If the tbtLock is true then the change is not made If tbtLock.Value Then Return If ValidateTableSelected() Then modMain.$hFNewField = New FNewField(tvwTables[tvwTables.Row, 0].Text, Null, tvwFields[tvwFields.Row, 1].Text) modMain.$hFNewField.ShowModal() Endif FieldInfo() Catch modMain.Error() End Public Sub tvwFields_Save(Row As Integer, Column As Integer, Value As String) Dim sDefinition As String Select (Column) Case 0, 5, 6, 7, 8 Return Case 1 'Field name modMain.$Connection.MySQL.Field.Rename(tvwTables[tvwTables.Row, 0].Text, tvwFields[Row, Column].Text, Value) Case 2 'Default If Value = "" Then modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "ALTER", tvwFields[Row, 1].Text, "DROP DEFAULT") Else modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "ALTER", tvwFields[Row, 1].Text, "SET DEFAULT '" & Value & "'") Endif Case 3 'Nullable sDefinition = tvwFields[Row, 4].Text If Value = "NO" Then sDefinition &= " NOT NULL" If tvwFields[Row, 2].Text <> "" Then sDefinition &= " DEFAULT '" & tvwFields[Row, 2].Text & "'" If tvwFields[Row, 9].Text <> "" Then sDefinition &= " COMMENT '" & tvwFields[Row, 2].Text & "'" modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "MODIFY", tvwFields[Row, 1].Text, sDefinition) Case 4 'Datatype sDefinition = Value If tvwFields[Row, 3].Text = "NO" Then sDefinition &= " NOT NULL" If tvwFields[Row, 2].Text <> "" Then sDefinition &= " DEFAULT '" & tvwFields[Row, 2].Text & "'" If tvwFields[Row, 9].Text <> "" Then sDefinition &= " COMMENT '" & tvwFields[Row, 2].Text & "'" modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "MODIFY", tvwFields[Row, 1].Text, sDefinition) Case 9 'Comment sDefinition = tvwFields[Row, 4].Text If tvwFields[Row, 3].Text = "NO" Then sDefinition &= " NOT NULL" If tvwFields[Row, 2].Text <> "" Then sDefinition &= " DEFAULT '" & tvwFields[Row, 2].Text & "'" If Value <> "" Then sDefinition &= " COMMENT '" & Value & "'" modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "MODIFY", tvwFields[Row, 1].Text, sDefinition) Default End Select RefreshData(tvwTables.Row, tabData.Index) Catch modMain.Error() End '***************************** End of Procedures for fields ******************** '***************************** Procedures for procedures *********************** Public Sub tvwProcedures_Click() If tvwProcedures.Row = -1 Then Return textResult.Text = modMain.$Connection.MySQL.Routines.Info(tvwProcedures[tvwProcedures.Row, 1].Text, modMain.$Connection.Name) Catch modMain.Error() End Public Sub tvwProcedures_DblClick() modMain.$hFNewRoutine = New FNewRoutine(Null, tvwProcedures[tvwProcedures.Row, 1].Text) modMain.$hFNewRoutine.ShowModal() RoutinesInfo() Catch modMain.Error() End Public Sub tvwProcedures_Select() tvwProcedures_Click() End '***************************** End of Procedures for procedures **************** '***************************** Procedures for triggers ************************* Public Sub tvwTriggers_Click() If tvwTriggers.Row = -1 Then Return textResult.Text = modMain.$Connection.MySQL.Trigger.Info(tvwTriggers[tvwTriggers.Row, 0].Text, modMain.$Connection.Name) Catch modMain.Error() End Public Sub tvwTriggers_DblClick() modMain.$hFNewTrigger = New FNewTrigger(tvwTables[tvwTables.Row, 0].Text, Null, tvwTriggers[tvwTriggers.Row, 0].Text) modMain.$hFNewTrigger.ShowModal() TriggersInfo() Catch modMain.Error() End Public Sub tvwTriggers_Select() tvwTriggers_Click() End '***************************** End of Procedures for triggers ****************** Public Sub tabData_Click() Select (tabData.Index) Case 0 'Tables tbtNew.ToolTip = ("New Table") tbtDelete.ToolTip = ("Delete Table") Case 1 'Views tbtNew.ToolTip = ("New View") tbtDelete.ToolTip = ("Delete View") Case 2 'Indexes tbtNew.ToolTip = ("New Index") tbtDelete.ToolTip = ("Delete Index") Case 3 'Fileds tbtNew.ToolTip = ("New Field") tbtDelete.ToolTip = ("Delete Field") Case 4 'Routines tbtNew.ToolTip = ("New Routine") tbtDelete.ToolTip = ("Delete Routine") Case 5 'Triggers tbtNew.ToolTip = ("New Trigger") tbtDelete.ToolTip = ("Delete Trigger") Case 6 'Events tbtNew.ToolTip = ("New Event") tbtDelete.ToolTip = ("Delete Event") Default End Select Catch modMain.Error() End Public Sub Action_Activate(Name As String) As Boolean Select (Name) Case "NewItem" 'tbtNew, F2 If tbtLock.Value Then Return NewItem() RefreshData(tvwTables.Row, tabData.Index) Case "EditItem" 'tbtNew, Ctrl + E If tbtLock.Value Then Return EditItem() RefreshData(tvwTables.Row, tabData.Index) Case "DeleteItem" 'tbtDelete, Del If tbtLock.Value Then Return DeleteItem() RefreshData(tvwTables.Row, tabData.Index) Case "Refresh" 'F5, tbtRefresh RefreshData(tvwTables.Row, tabData.Index) Case "NewDatabase" 'tbtNewDatabase modMain.$hFNewDatabase = New FNewDatabase modMain.$hFNewDatabase.ShowModal() RefreshData(tvwTables.Row, tabData.Index) Form_Open() Case "DeleteDatabase" 'tbtDeleteDatabase If Message.Question(Subst(("Do you realy want to delete the database: &1?"), modMain.$Connection.Name), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.DataBase.Delete(modMain.$Connection.Name, False) modMain.$Connection.MySQL.Use("mysql") Form_Open() Endif RefreshData(tvwTables.Row, tabData.Index) Case "Lock" tbtDeleteDatabase.Enabled = Not tbtDeleteDatabase.Enabled tbtNewDatabase.Enabled = Not tbtNewDatabase.Enabled tbtNew.Enabled = Not tbtNew.Enabled tbtDelete.Enabled = Not tbtDelete.Enabled Default End Select Catch modMain.Error() End Private Function ValidateTableSelected() As Boolean If tvwTables.Row = -1 Then Return False Return True End Public Procedure NewItem() 'Add the item Select (tabData.Index) Case 0 'Tables modMain.$hFNewTable = New FNewTable modMain.$hFNewTable.ShowModal() Case 1 'Views modMain.$hFNewView = New FNewView(Null) modMain.$hFNewView.ShowModal() Case 2 'Indexes If ValidateTableSelected() Then modMain.$hFNewIndex = New FNewIndex(tvwTables[tvwTables.Row, 0].Text) modMain.$hFNewIndex.ShowModal() Endif Case 3 'Fileds If ValidateTableSelected() Then modMain.$hFNewField = New FNewField(tvwTables[tvwTables.Row, 0].Text) modMain.$hFNewField.ShowModal() Endif Case 4 'Routines modMain.$hFNewRoutine = New FNewRoutine modMain.$hFNewRoutine.ShowModal() Case 5 'Triggers If ValidateTableSelected() Then modMain.$hFNewTrigger = New FNewTrigger(tvwTables[tvwTables.Row, 0].Text) modMain.$hFNewTrigger.ShowModal() Endif Case 6 'Events modMain.$hFNewEvent = New FNewEvent modMain.$hFNewEvent.ShowModal() Default End Select RefreshData(tvwTables.Row, tabData.Index) End Public Procedure EditItem() Select (tabData.Index) Case 0 'Tables modMain.$hFNewTable = New FNewTable(Null, tvwTables[tvwTables.Row, 0].Text) modMain.$hFNewTable.ShowModal() TableInfo() Case 1 'Views tvwViews_DblClick() Case 2 'Indexes tvwIndexes_DblClick() Case 3 'Fileds tvwFields_DblClick() Case 4 'Routines tvwProcedures_DblClick() Case 5 'Triggers tvwTriggers_DblClick() Case 6 'Events tvwEvents_DblClick() Default End Select Catch modMain.Error() End Public Procedure DeleteItem() Select (tabData.Index) Case 0 'Tables If Message.Question(Subst(("Do you realy want to delete the table: &1?"), tvwTables[tvwTables.Row, 0].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Table.Delete([tvwTables[tvwTables.Row, 0].Text], False) Case 1 'Views If Message.Question(Subst(("Do you realy want to delete the view: &1?"), tvwViews[tvwViews.Row, 0].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.View.Delete([tvwViews[tvwViews.Row, 0].Text], False) Case 2 'Indexes If Message.Question(Subst(("Do you realy want to delete the index: &1?"), tvwIndexes[tvwIndexes.Row, 0].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Index.Delete(tvwTables[tvwTables.Row, 0].Text, tvwIndexes[tvwIndexes.Row, 0].Text) Case 3 'Fileds If Message.Question(Subst(("Do you realy want to delete the field: &1?"), tvwFields[tvwFields.Row, 1].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Table.ModifyColumn(tvwTables[tvwTables.Row, 0].Text, "DROP", tvwFields[tvwFields.Row, 1].Text) Case 4 'Routines If Message.Question(Subst(("Do you realy want to delete the routine: &1?"), tvwProcedures[tvwProcedures.Row, 1].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Routines.Delete(tvwProcedures[tvwProcedures.Row, 1].Text, False) Case 5 'Triggers If Message.Question(Subst(("Do you realy want to delete the trigger: &1?"), tvwTriggers[tvwTriggers.Row, 0].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Trigger.Delete(tvwTriggers[tvwTriggers.Row, 0].Text, False) Case 6 'Events If Message.Question(Subst(("Do you realy want to delete the event: &1?"), tvwEvents[tvwEvents.Row, 0].Text), ("&Yes"), ("&No")) = 1 Then modMain.$Connection.MySQL.Event.Delete(tvwEvents[tvwEvents.Row, 0].Text, False) Default End Select modMain.$hFBrowser.SetMessage(("Item deleted."), 1) End Public Procedure RefreshData(Table As Integer, Tab As Integer) textResult.Clear() SearchInfo() If Table = -1 Then Table = 0 tvwTables.Row = Table FieldInfo() IndexInfo() tabData.Index = Tab End Public Procedure SetEditor() textResult.SetStyle() End '***************************** Procedures for events ************************* Public Sub tvwEvents_Click() textResult.Text = modMain.$Connection.MySQL.Event.Info(tvwEvents[tvwEvents.Row, 0].Text, modMain.$Connection.Name) Catch modMain.Error() End Public Sub tvwEvents_DblClick() If Not modMain.$bSchemaOk Then Return modMain.$hFNewEvent = New FNewEvent(Null, tvwEvents[tvwEvents.Row, 0].Text) modMain.$hFNewEvent.ShowModal() EventInfo() Catch modMain.Error() End Public Sub tvwEvents_Select() tvwEvents_Click() End '***************************** Procedures for indexes ************************* Public Sub tvwIndexes_DblClick() modMain.$hFNewIndex = New FNewIndex(tvwTables[tvwTables.Row, 0].Text, Null, tvwIndexes[tvwIndexes.Row, 0].Text) modMain.$hFNewIndex.ShowModal() IndexInfo() Catch modMain.Error() End '***************************** End of Procedures for indexes ************************* '**************************** Procedures for sorting info ******************** Public Sub tvwFields_ColumnClick(Column As Integer) FieldInfo(Column) End Public Sub tvwTables_ColumnClick(Column As Integer) TableInfo(Column) End Public Sub tvwViews_ColumnClick(Column As Integer) ViewInfo(Column) End Public Sub tvwIndexes_ColumnClick(Column As Integer) IndexInfo(Column) End Public Sub tvwProcedures_ColumnClick(Column As Integer) RoutinesInfo(Column) End Public Sub tvwTriggers_ColumnClick(Column As Integer) TriggersInfo(Column) End Public Sub tvwEvents_ColumnClick(Column As Integer) EventInfo(Column) End '**************************** End of Procedures for sorting info ************** Public Sub tvwTables_Menu() mnuItem.Popup() End Public Sub tvwViews_Menu() mnuItem.Popup() End Public Sub tvwIndexes_Menu() mnuItem.Popup() End Public Sub tvwFields_Menu() mnuItem.Popup() End Public Sub tvwProcedures_Menu() mnuItem.Popup() End Public Sub tvwTriggers_Menu() mnuItem.Popup() End Public Sub tvwEvents_Menu() mnuItem.Popup() End Public Sub cmbDatabases_Click() modMain.$Connection.MySQL.Use(cmbDatabases.Text) Me.Text = "mysql://" & modMain.$Connection.User & "@" & modMain.$Connection.Host & "/" & modMain.$Connection.Name SearchInfo() End