[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:
David Villalobos Cambronero 2010-07-05 03:01:38 +00:00
parent 64b544e729
commit ec7e7e351f
3 changed files with 42 additions and 24 deletions

View file

@ -549,11 +549,7 @@ _Maintenance
Modify Modify
m m
(Table)s(Action)s[(Symbol)s(Definition)s] (Table)s[(Database)s(Engine)s(Charset)s]
Add
m
(Table)s[(Engine)s(Charset)s]
Engine Engine
m m
s s
@ -562,6 +558,14 @@ Charset
m m
s s
(Table)s[(Database)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 Delete
m m
@ -569,15 +573,15 @@ m
LoadData LoadData
m m
(Table)s(File)s (Table)s(File)s[(Database)s]
Info Info
m m
s s
(Table)s (Table)s[(Database)s]
Insert Insert
m m
(Table)s(Fields)String[];(Values)String[]; (Table)s(Fields)String[];(Values)String[];[(Database)s]
Fields Fields
m m
String[] String[]
@ -585,7 +589,7 @@ String[]
Rename Rename
m m
(Table)s(NewTable)s (Table)s(NewTable)s[(Database)s]
Collation Collation
m m
s s

View file

@ -44,6 +44,9 @@ Geometry=[0,0,210,210]
[DebugWindow/modMain.$hResult] [DebugWindow/modMain.$hResult]
Geometry=[0,0,210,210] Geometry=[0,0,210,210]
[FCommit]
LastCommit="[GB.MYSQL]\n* NEW: Added some new function to the _Trigger class."
[FFind] [FFind]
SearchIn="Module" SearchIn="Module"
CaseSensitive=True CaseSensitive=True
@ -52,10 +55,12 @@ SearchComment=False
SearchString=True SearchString=True
[OpenFile] [OpenFile]
Active=1
File[1]="/home/david/Gambas3/comp/src/gb.mysql/.src/_Trigger.class:10.3" 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" 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] [Watches]
Count=0 Count=0

View file

@ -4,13 +4,21 @@ Export
Create Static Create Static
Private $hMaintenance As _Maintenance Private $hMaintenance As _Maintenance
Property Read Maintenance 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) Action = Upper(Action)
modMain.$Query = "ALTER TABLE `" & Table & "` " modMain.$Query = "ALTER TABLE `" & Database & "`.`" & Table & "`"
Select (Action) Select (Action)
Case "DROP" Case "DROP"
modMain.$Query &= Action & " COLUMN `" & Symbol & "`" modMain.$Query &= Action & " COLUMN `" & Symbol & "`"
@ -27,10 +35,10 @@ Public Procedure Modify(Table As String, Action As String, Optional Symbol As St
End 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 'Make the table statement
modMain.$Query = "CREATE TABLE `" & Table & "` (" modMain.$Query = "CREATE TABLE `" & Database & "`.`" & Table & "` ("
modMain.$Query &= modMain.ArrayToString(modMain.$FieldDefinition, False) modMain.$Query &= modMain.ArrayToString(modMain.$FieldDefinition, False)
If modMain.$PrimaryKey Then modMain.$Query &= modMain.$PrimaryKey If modMain.$PrimaryKey Then modMain.$Query &= modMain.$PrimaryKey
If modMain.$Index.Count Then modMain.$Query &= ", " & modMain.ArrayToString(modMain.$Index, False) 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 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 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" Return modMain.$Connection.Exec(modMain.$Query)!"Create Table"
End 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 Dim iCounter As Integer
modMain.$Query = "INSERT INTO `" & Table & "`" modMain.$Query = "INSERT INTO `" & Database & "`.`" & Table & "`"
If Upper(Fields[0]) = "ALL" Then If Upper(Fields[0]) = "ALL" Then
modMain.$Query &= " VALUES (" modMain.$Query &= " VALUES ("
Else Else
@ -98,9 +107,9 @@ Public Procedure Insert(Table As String, Fields As String[], Values As String[])
End 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 End