Well, I've been recently faffin' about with MySQL on Linux and Windows and thought I might just wrap it up and give it to the DBP community for anyone who might actually have a need for it.
Some things to get you started:
1. Download MySQL from here -
http://dev.mysql.com/downloads/installer/
This will also install the MySQL Workbench which you will need to test out your first database.
2. Run MySQL Workbench and create a test database. This can be quite fiddly as I found out but there is lots more information on the MySQL website on how to use it... No use asking me...
3. Make your first field an "AutoIncrement" field. You will see a line with something along the lines of:
PK NN UQ BIN UN ZF AI - Just select the last AI option to set it to "AutoIncrement".
This will then set your first field as the Primary Key.
4. Add some more fields.
5. Edit table data and only enter values in the other fields (not the Primary Key field). This will populate your first table with some test data to try this plugin out with.
6. Using the HOST, USER, PASSWD and DB names you can now make your changes to this code and run...
` MySQL test
HOST$ = "127.0.0.1"
USER$ = "root"
PASSWORD$ = "1234"
DATABASE$ = "test"
MYQUERY$ = "SELECT * FROM Contacts"
connect = 0
PRINT "HOST = " + HOST$
PRINT "USER = " + USER$
PRINT "PASSWORD = " + PASSWORD$
PRINT "DATABASE = " + DATABASE$
connect = MYSQL INIT(0)
IF connect = 0
PRINT "MySQL did not initialise..."
WAIT KEY
END
ENDIF
PRINT "MySQL initialisation okay..."
connect = MYSQL REAL CONNECT(connect,HOST$,USER$,PASSWORD$,DATABASE$,0,"",0)
IF connect = 0
PRINT "Error connecting to database..."
MYSQL CLOSE connect
WAIT KEY
END
ENDIF
PRINT "Connection established..."
error = MYSQL QUERY(connect,MYQUERY$)
res_set = MYSQL STORE RESULT(connect)
num_rows = MYSQL NUM FIELDS(res_set)
REPEAT
row = MYSQL FETCH ROW(res_set)
IF row <> 0
s$ = ""
FOR i = 0 TO num_rows - 1
s$ = s$ + MYSQL FETCH ROW STRING(row,i)
NEXT i
PRINT s$
ENDIF
UNTIL row = 0
MYSQL CLOSE connect
WAIT KEY
END
The extra function so far is MYSQL FETCH ROW STRING(row,index) which returns the value into a string. If you need a numeric value then use DBP's VAL() function which is more than adequate.
The plugin is attached to this post in the bottom right corner...
Have fun, and yes it's awkward. So if you do need help I'd recommend searching the MySQL website before asking here. I'm still learning MySQL so I will not have any answers for you...
There may be a need to alter and/or add extra functions to the plugin but that will come in time...
EDIT: The functions in the plugin:
MYSQL INIT(mysql) returns mysql or 0 if failed
MYSQL REAL CONNECT(mysql,host$,user$,passwd$,db$,port,socket$,clientflag) returns mysql or 0 if failed
MYSQL QUERY(mysql,query$) returns error state
MYSQL NUM ROWS(result) returns row count
MYSQL NUM FIELDS(result) returns field count
MYSQL EOF(result) returns 1 or 0
MYSQL FETCH FIELD DIRECT(result,fieldnum) returns mysql_field
MYSQL FETCH FIELDS(result) returns mysql_field pointer
MYSQL ROW TELL(result) returns mysql_row_offset
MYSQL FIELD TELL(result) returns mysql_field_offset
MYSQL FIELD COUNT(mysql) returns count
MYSQL AFFECTED ROWS(mysql) returns rows
MYSQL INSERT ID(mysql) returns value
MYSQL ERRNO(mysql) returns value
MYSQL ERROR(mysql) returns error_string$
MYSQL SQLSTATE(mysql) returns sql_state$
MYSQL WARNING COUNT(mysql) return count
MYSQL INFO(mysql) returns info_string$
MYSQL THREAD ID(mysql) returns threadid
MYSQL CHARACTER SET NAME(mysql) returns set_name$
MYSQL SET CHARACTER SET(mysql,csname$) returns value
MYSQL SSL SET(mysql,key$,cert$,ca$,capath$,cipher$) returns 1 or 0
MYSQL GET SSL CIPHER(mysql) returns cipher$
MYSQL CHANGE USER(mysql,user$,passwd$,db$) returns 1 or 0
MYSQL SELECT DB(mysql,db$) returns value
MYSQL SEND QUERY(mysql,query$,length) returns value
MYSQL REAL QUERY(mysql,query$,length) returns value
MYSQL STORE RESULT(mysql) returns result
MYSQL USE RESULT(mysql) returns result
MYSQL GET CHARACTER SET INFO(mysql,charset_ptr) returns value
MYSQL DUMP DEBUG INFO(mysql) returns value
MYSQL REFRESH(mysql,options) returns value
MYSQL KILL(mysql,pid) returns value
MYSQL PING(mysql) returns value
MYSQL STAT(mysql) returns string$
MYSQL GET SERVER INFO(mysql) returns string$
MYSQL GET CLIENT INFO() returns string$
MYSQL GET CLIENT VERSION() returns value
MYSQL GET HOST INFO(mysql) returns string$
MYSQL GET SERVER VERSION(mysql) returns value
MYSQL GET PROTO INFO(mysql) returns value
MYSQL LIST DBS(mysql,wild$) returns result
MYSQL LIST TABLES(mysql,wild$) returns result
MYSQL LIST PROCESSES(mysql) returns result
MYSQL FREE RESULT result NO RETURN
MYSQL DATA SEEK result,offset NO RETURN
MYSQL ROW SEEK(result,row_offset) returns row_offset
MYSQL FIELD SEEK(result,field_offset) returns field_offset
MYSQL FETCH ROW(result) returns row
MYSQL FETCH LENGTHS(result) returns lengths_ptr
MYSQL LIST FIELDS(mysql,table$,wild$) returns result
MYSQL ESCAPE STRING(to$,from$,length) returns value
MYSQL HEX STRING(to$,from$,length) returns value
MYSQL REAL ESCAPE STRING(mysql,to$,from$,length) returns value
MYSQL DEBUG debug$ NO RETURN
MYSQL REMOVE ESCAPE mysql,name$ NO RETURN
MYSQL THREAD SAFE() returns value
MYSQL EMBEDDED() returns 1 or 0
MYSQL READ QUERY RESULT(mysql) returns 1 or 0
MYSQL CLOSE socket NO RETURN
MYSQL FETCH ROW STRING(SQLROW,item) returns STR$
EDIT2: The ".dll" file goes into the "compiler/plugins-user" directory and the ".ini" file goes into the "editor/keywords" directory of your DBPro installation location.
Mental arithmetic? Me? (That's for computers) I can't subtract a fart from a plate of beans!
Warning! May contain Nuts!