' Rapid-Q by William Yu (c)1999-2000 . ' ================================================================================ ' Upload_il_tuo_script_su_Rapidq.it ' Qmysql ****** QMYSQL Component ****** QMySQL is used to access your local or remote MySQL server. More information on MySQL can be obtained at http://www.mysql.com/ QMySQL Properties 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 R WXG INTEGER 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 QMySQL Methods Method Type Description Params Support =============== =============== =============== =============== =============== Close SUB Disconnect from 0 WXG MySQL FUNCTION Connect (Host$, User$, Connect to 3 WXG Passwd$) AS MySQL INTEGER CreateDB FUNCTION (DB$) Creates a new 1 WXG AS INTEGER database DropDB FUNCTION (DB$) Drop database 1 WXG AS INTEGER Parses binary FUNCTION (S$, string S$ and EscapeString Length%) AS returns a 2 WXG STRING string that can be used in Blob fields FetchField FUNCTION AS Fetch next 0 WXG INTEGER field FetchLengths FUNCTION AS Fetch lengths 0 WXG INTEGER for current row FetchRow FUNCTION AS Fetch next row 0 WXG INTEGER FieldSeek FUNCTION Jump to Field 1 WXG (Position%) Position% FUNCTION Query (Query$) AS Query database 1 WXG INTEGER SUB (Host$, User$, Passwd$, Connect to RealConnect DB$, Port%, MySQL 7 WXG UnixSock$, Flags%) FUNCTION Refresh Refresh (RefreshFlags%) database 1 WXG AS INTEGER FUNCTION (Row%, Returns the RowBlob Bytes&) AS binary blob as 2 WXG STRING a string RowSeek FUNCTION (Row%) Jump to a 1 WXG certain row SelectDB FUNCTION (DB$) Select database 1 WXG AS INTEGER to use QMySQL Events Event Type Occurs when... Params =================== =================== =================== =================== 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 ' =============================================================================== ' 2003 Holyguard.net - 2007_Abruzzoweb