Field |
Type |
R/W |
Default |
Support |
|
|
|
|
|
Connected |
INTEGER |
R |
|
WXG |
|
Connected specifies whether you are currently connected to a MySQL server. Use the Connect method to establish a connection. |
DB |
ARRAY of STRING |
R |
|
WXG |
|
DB returns a database list that are currently available on the MySQL server. |
DBCount |
INTEGER |
R |
|
WXG |
|
DBCount returns the number of databases that are currently available on the MySQL server. |
ColCount |
INTEGER |
R |
|
WXG |
|
ColCount returns the number of columns in the table. ColCount is used after an SQL query to determine the number of columns in the resulting table. |
FieldCount |
INTEGER |
R |
|
WXG |
|
FieldCount returns the number of columns in the table. FieldCount is used after an SQL query to determine the number of columns in the resulting table. |
Field.Decimals |
INTEGER |
R |
|
WXG |
|
Field.Decimals returns the number of decimals in the field. |
Field.Flags |
INTEGER |
R |
|
WXG |
|
Field.Flags returns the flag settings. Refer to MYSQL.INC for supported values. |
Field.Length |
INTEGER |
R |
|
WXG |
|
Field.Length returns the width of the column. |
Field.MaxLength |
INTEGER |
R |
|
WXG |
|
Field.MaxLength returns the maximum width of the selected set. A result set can have multiple fields (or columns), Field.MaxLength returns the largest of these. |
Field.Name |
STRING |
R |
|
WXG |
|
Field.Name returns the name of the column. |
Field.Table |
STRING |
R |
|
WXG |
Field.Type |
INTEGER |
R |
|
WXG |
|
Field.Type returns the type of field. Refer to MYSQL.INC for supported values. |
Length |
ARRAY of INTEGER |
R |
|
WXG |
|
Length returns the length of each field. Make sure a call to FetchLengths is made. |
Row |
ARRAY of STRING |
R |
|
WXG |
|
Row returns the value stored in the particular Row for the current result set. The value is also dependent on the Field (or column). For example, Row(3) returns the value stored in Row 3 and whatever Column, ie. 2. Which is different from Row(3) of Column 3 for example. |
RowCount |
INTEGER |
R |
|
WXG |
Table |
ARRAY of STRING |
R |
|
WXG |
|
Table returns a list of tables for the current database. |
TableCount |
INTEGER |
R |
|
WXG |
Method |
Type |
Description |
Params |
Support |
|
|
|
|
|
Close |
SUB |
Disconnect from MySQL |
0 |
WXG |
Connect |
FUNCTION (Host$, User$, Passwd$) AS INTEGER |
Connect to MySQL |
3 |
WXG |
CreateDB |
FUNCTION (DB$) AS INTEGER |
Creates a new database |
1 |
WXG |
DropDB |
FUNCTION (DB$) AS INTEGER |
Drop database |
1 |
WXG |
EscapeString |
FUNCTION (S$, Length%) AS STRING |
Parses binary string S$ and returns a string that can be used in Blob fields |
2 |
WXG |
FetchField |
FUNCTION AS INTEGER |
Fetch next field |
0 |
WXG |
FetchLengths |
FUNCTION AS INTEGER |
Fetch lengths for current row |
0 |
WXG |
FetchRow |
FUNCTION AS INTEGER |
Fetch next row |
0 |
WXG |
FieldSeek |
FUNCTION (Position%) |
Jump to Field Position% |
1 |
WXG |
Query |
FUNCTION (Query$) AS INTEGER |
Query database |
1 |
WXG |
RealConnect |
SUB (Host$, User$, Passwd$, DB$, Port%, UnixSock$, Flags%) |
Connect to MySQL |
7 |
WXG |
Refresh |
FUNCTION (RefreshFlags%) AS INTEGER |
Refresh database |
1 |
WXG |
RowBlob |
FUNCTION (Row%, Bytes&) AS STRING |
Returns the binary blob as a string |
2 |
WXG |
RowSeek |
FUNCTION (Row%) |
Jump to a certain row |
1 |
WXG |
SelectDB |
FUNCTION (DB$) AS INTEGER |
Select database to use |
1 |
WXG |
QMySQL Examples
' This simply checks that you have a working MySQL server and lets you
' view some database fields.
$TYPECHECK ON
$INCLUDE "RAPIDQ.INC"
DECLARE SUB Button1Click (Sender AS QBUTTON)
DECLARE SUB DBListBoxClick (Sender AS QLISTBOX)
DECLARE SUB TableListBoxClick (Sender AS QLISTBOX)
DECLARE SUB SQLFormResize (Sender AS QFORM)
DIM Font AS QFONT
Font.Name = "Courier"
DIM MySQL AS QMYSQL
CREATE SQLForm AS QFORM
Caption = "Connected"
Width = 330
Height = 300
Center
CREATE DBLabel AS QLABEL
Caption = "Select a database:"
END CREATE
CREATE DBListBox AS QLISTBOX
Top = 20
Width = 150
Height = 100
OnClick = DBListBoxClick
END CREATE
CREATE TableListBox AS QLISTBOX
Top = 20
Left = 165
Width = 150
Height = 100
OnClick = TableListBoxClick
END CREATE
CREATE FieldEdit AS QRICHEDIT
Top = 130
Width = SQLForm.ClientWidth
Height = SQLForm.ClientHeight-130
ReadOnly = TRUE
WordWrap = FALSE
PlainText = TRUE
Font = Font
ScrollBars = ssBoth
END CREATE
CREATE Grid AS QSTRINGGRID
Top = 130
Width = SQLForm.ClientWidth
Height = SQLForm.ClientHeight-130
AddOptions(goEditing)
END CREATE
OnResize = SQLFormResize
END CREATE
CREATE Form AS QFORM
Caption = "SQL Demo"
Width = 230
Height = 174
Center
CREATE Label1 AS QLABEL
Caption = "Host:"
Left = 44
Top = 23
END CREATE
CREATE Label2 AS QLABEL
Caption = "User name:"
Left = 16
Top = 50
Width = 57
END CREATE
CREATE Label3 AS QLABEL
Caption = "Password:"
Left = 21
Top = 79
Width = 54
END CREATE
CREATE Edit1 AS QEDIT
Text = ""
Left = 83
Top = 18
END CREATE
CREATE Edit2 AS QEDIT
Text = ""
Left = 83
Top = 46
END CREATE
CREATE Edit3 AS QEDIT
Text = ""
Left = 83
Top = 74
END CREATE
CREATE Button1 AS QBUTTON
Caption = "&Ok"
Left = 32
Top = 112
Kind = 1
Default = 1
NumBMPs = 2
OnClick = Button1Click
END CREATE
CREATE Button2 AS QBUTTON
Caption = "E&xit"
Left = 118
Top = 112
Kind = 6
NumBMPs = 2
END CREATE
ShowModal
END CREATE
SUB Button1Click
DIM I AS INTEGER
IF MySQL.Connect(Edit1.Text, Edit2.Text, Edit3.Text) = 0 THEN
ShowMessage("Failed to connect to MySQL Server")
EXIT SUB
END IF
FOR I = 0 TO MySQL.DBCount-1
DBListBox.AddItems(MySQL.DB(I))
NEXT
SQLForm.ShowModal
SUB DBListBoxClick (Sender AS QLISTBOX)
IF Sender.ItemIndex < 0 THEN EXIT SUB
IF MySQL.SelectDB(Sender.Item(Sender.ItemIndex)) = 0 THEN
ShowMessage("Could not open "+Sender.Item(Sender.ItemIndex))
EXIT SUB
END IF
TableListBox.Clear
FOR I = 0 TO MySQL.TableCount-1
TableListBox.AddItems(MySQL.Table(I))
NEXT
END SUB
SUB TableListBoxClick (Sender AS QLISTBOX)
DIM Str AS STRING, J AS INTEGER
IF Sender.ItemIndex < 0 THEN EXIT SUB
IF MySQL.Query("show columns from "+Sender.Item(Sender.ItemIndex)) = 0 THEN
ShowMessage("Could not query "+Sender.Item(Sender.ItemIndex))
EXIT SUB
END IF
FieldEdit.Clear
Grid.ColCount = MySQL.FieldCount
I = 0
WHILE MySQL.FetchField
Grid.Cell(I,0) = MySQL.Field.Name
I++
WEND
Grid.RowCount = MySQL.RowCount+1
IF MySQL.RowCount THEN
J = 1
WHILE MySQL.FetchRow
MySQL.FieldSeek(0)
FOR I=0 to MySQL.NumFields-1
Grid.Cell(I,J) = MySQL.Row(I)
NEXT
J++
WEND
END IF
END SUB
END SUB
SUB SQLFormResize (Sender AS QFORM)
Grid.Height = Sender.ClientHeight - Grid.Top
Grid.Width = Sender.ClientWidth-1
TableListBox.Width = Sender.ClientWidth-1 - TableListBox.Left
END SUB
IF MySQL.Connected THEN MySQL.Close
END
Prev ComponentContentsNext Component