[GB.MYSQL]
* NEW: Work arround the Table creation. git-svn-id: svn://localhost/gambas/trunk@3027 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
parent
64b544e729
commit
ec7e7e351f
3 changed files with 42 additions and 24 deletions
|
@ -549,11 +549,7 @@ _Maintenance
|
|||
Modify
|
||||
m
|
||||
|
||||
(Table)s(Action)s[(Symbol)s(Definition)s]
|
||||
Add
|
||||
m
|
||||
|
||||
(Table)s[(Engine)s(Charset)s]
|
||||
(Table)s[(Database)s(Engine)s(Charset)s]
|
||||
Engine
|
||||
m
|
||||
s
|
||||
|
@ -562,6 +558,14 @@ Charset
|
|||
m
|
||||
s
|
||||
(Table)s[(Database)s]
|
||||
ModifyColumn
|
||||
m
|
||||
|
||||
(Table)s(Action)s[(Symbol)s(Definition)s(Database)s]
|
||||
Add
|
||||
m
|
||||
|
||||
(Table)s[(Engine)s(Charset)s(Database)s]
|
||||
Delete
|
||||
m
|
||||
|
||||
|
@ -569,15 +573,15 @@ m
|
|||
LoadData
|
||||
m
|
||||
|
||||
(Table)s(File)s
|
||||
(Table)s(File)s[(Database)s]
|
||||
Info
|
||||
m
|
||||
s
|
||||
(Table)s
|
||||
(Table)s[(Database)s]
|
||||
Insert
|
||||
m
|
||||
|
||||
(Table)s(Fields)String[];(Values)String[];
|
||||
(Table)s(Fields)String[];(Values)String[];[(Database)s]
|
||||
Fields
|
||||
m
|
||||
String[]
|
||||
|
@ -585,7 +589,7 @@ String[]
|
|||
Rename
|
||||
m
|
||||
|
||||
(Table)s(NewTable)s
|
||||
(Table)s(NewTable)s[(Database)s]
|
||||
Collation
|
||||
m
|
||||
s
|
||||
|
|
|
@ -44,6 +44,9 @@ Geometry=[0,0,210,210]
|
|||
[DebugWindow/modMain.$hResult]
|
||||
Geometry=[0,0,210,210]
|
||||
|
||||
[FCommit]
|
||||
LastCommit="[GB.MYSQL]\n* NEW: Added some new function to the _Trigger class."
|
||||
|
||||
[FFind]
|
||||
SearchIn="Module"
|
||||
CaseSensitive=True
|
||||
|
@ -52,10 +55,12 @@ SearchComment=False
|
|||
SearchString=True
|
||||
|
||||
[OpenFile]
|
||||
Active=1
|
||||
File[1]="/home/david/Gambas3/comp/src/gb.mysql/.src/_Trigger.class:10.3"
|
||||
File[2]="/home/david/Gambas3/comp/src/gb.mysql/.src/modMain.module:60.18"
|
||||
Count=2
|
||||
Active=3
|
||||
File[3]="/home/david/Gambas3/comp/src/gb.mysql/.src/_Table.class:66.0"
|
||||
File[4]="/home/david/Gambas3/comp/src/gb.mysql/.src/_DataBase.class:26.171"
|
||||
Count=4
|
||||
|
||||
[Watches]
|
||||
Count=0
|
||||
|
|
|
@ -4,13 +4,21 @@ Export
|
|||
Create Static
|
||||
|
||||
Private $hMaintenance As _Maintenance
|
||||
|
||||
Property Read Maintenance As _Maintenance
|
||||
|
||||
Public Procedure Modify(Table As String, Action As String, Optional Symbol As String, Optional Definition As String)
|
||||
Public Procedure Modify(Table As String, Optional Database As String = modMain.$Connection.Name, Optional Engine As String = modMain.$Connection.MySQL.Engine, Optional Charset As String = modMain.$Connection.MySQL.Charset)
|
||||
|
||||
modMain.$Query = "ALTER TABLE `" & Database & "`.`" & Table & "`"
|
||||
modMain.$Query &= " ENGINE = " & Engine
|
||||
modMain.$Query &= " CHARACTER SET = " & Charset
|
||||
modMain.RunQuery(modMain.$Query)
|
||||
|
||||
End
|
||||
|
||||
Public Procedure ModifyColumn(Table As String, Action As String, Optional Symbol As String, Optional Definition As String, Optional Database As String = modMain.$Connection.Name)
|
||||
|
||||
Action = Upper(Action)
|
||||
modMain.$Query = "ALTER TABLE `" & Table & "` "
|
||||
modMain.$Query = "ALTER TABLE `" & Database & "`.`" & Table & "`"
|
||||
Select (Action)
|
||||
Case "DROP"
|
||||
modMain.$Query &= Action & " COLUMN `" & Symbol & "`"
|
||||
|
@ -27,10 +35,10 @@ Public Procedure Modify(Table As String, Action As String, Optional Symbol As St
|
|||
|
||||
End
|
||||
|
||||
Public Procedure Add(Table As String, Optional Engine As String = modMain.$Connection.MySQL.Engine, Optional Charset As String = modMain.$Connection.MySQL.Charset)
|
||||
Public Procedure Add(Table As String, Optional Engine As String = modMain.$Connection.MySQL.Engine, Optional Charset As String = modMain.$Connection.MySQL.Charset, Optional Database As String = modMain.$Connection.Name)
|
||||
|
||||
'Make the table statement
|
||||
modMain.$Query = "CREATE TABLE `" & Table & "` ("
|
||||
modMain.$Query = "CREATE TABLE `" & Database & "`.`" & Table & "` ("
|
||||
modMain.$Query &= modMain.ArrayToString(modMain.$FieldDefinition, False)
|
||||
If modMain.$PrimaryKey Then modMain.$Query &= modMain.$PrimaryKey
|
||||
If modMain.$Index.Count Then modMain.$Query &= ", " & modMain.ArrayToString(modMain.$Index, False)
|
||||
|
@ -57,24 +65,25 @@ Public Procedure Delete(Tables As String[], Optional IfExists As Boolean = False
|
|||
|
||||
End
|
||||
|
||||
Public Procedure LoadData(Table As String, File As String)
|
||||
Public Procedure LoadData(Table As String, File As String, Optional Database As String = modMain.$Connection.Name)
|
||||
|
||||
modMain.RunQuery("LOAD DATA LOCAL INFILE '" & File & "' INTO TABLE `" & Table & "`")
|
||||
modMain.RunQuery("LOAD DATA LOCAL INFILE '" & File & "' INTO TABLE `" & Database & "`.`" & Table & "`")
|
||||
|
||||
End
|
||||
|
||||
Public Function Info(Table As String) As String
|
||||
Public Function Info(Table As String, Optional Database As String = modMain.$Connection.Name) As String
|
||||
|
||||
modMain.$Query = "SHOW CREATE TABLE `" & Table & "`"
|
||||
modMain.$Query = "SHOW CREATE TABLE `" & Database & "`.`" & Table & "`"
|
||||
Return modMain.$Connection.Exec(modMain.$Query)!"Create Table"
|
||||
|
||||
End
|
||||
|
||||
Public Procedure Insert(Table As String, Fields As String[], Values As String[])
|
||||
Public Procedure Insert(Table As String, Fields As String[], Values As String[], Optional Database As String = modMain.$Connection.Name)
|
||||
|
||||
|
||||
Dim iCounter As Integer
|
||||
|
||||
modMain.$Query = "INSERT INTO `" & Table & "`"
|
||||
modMain.$Query = "INSERT INTO `" & Database & "`.`" & Table & "`"
|
||||
If Upper(Fields[0]) = "ALL" Then
|
||||
modMain.$Query &= " VALUES ("
|
||||
Else
|
||||
|
@ -98,9 +107,9 @@ Public Procedure Insert(Table As String, Fields As String[], Values As String[])
|
|||
|
||||
End
|
||||
|
||||
Public Procedure Rename(Table As String, NewTable As String)
|
||||
Public Procedure Rename(Table As String, NewTable As String, Optional Database As String = modMain.$Connection.Name)
|
||||
|
||||
modMain.RunQuery("RENAME TABLE `" & Table & "` TO `" & NewTable & "`")
|
||||
modMain.RunQuery("RENAME TABLE `" & Database & "`.`" & Table & "` TO `" & Database & "`.`" & NewTable & "`")
|
||||
|
||||
End
|
||||
|
||||
|
|
Loading…
Reference in a new issue