MySQL programming
Posted: Mon Aug 23, 2004 3:08 pm
Hi,
I'm trying to program an interface to MySQL and hit a bump.
I can't seem to be able to use the mysql_data_seek command from the libmysql.dll library. Everytime I use a callfunction on this command, all my variables in memory change values. Is anyone familiar with that command ?
To help you understand my problem, I summed up my code into this snippet which connects to my database and retrieve the value from the third field of a record.
In this code, if you put the dataseek command in comments your gonna end up with the first record and the word "Salut". Now as I understand it, if we used mysql_data_seek command with an offset of 0, we would end up with the same word. But instead, it just stop executing because it changes the value of mlMYSQL_RES.
Now I noticed that the data_seek command uses an offset in the longlong format which is a integer stored on 64 bits, could it be the problem ? Wouldn't a hardcoded offset of 0 be the same with any numeric type ?
Thank you for your numerous replies
I'm trying to program an interface to MySQL and hit a bump.
I can't seem to be able to use the mysql_data_seek command from the libmysql.dll library. Everytime I use a callfunction on this command, all my variables in memory change values. Is anyone familiar with that command ?
To help you understand my problem, I summed up my code into this snippet which connects to my database and retrieve the value from the third field of a record.
In this code, if you put the dataseek command in comments your gonna end up with the first record and the word "Salut". Now as I understand it, if we used mysql_data_seek command with an offset of 0, we would end up with the same word. But instead, it just stop executing because it changes the value of mlMYSQL_RES.
Code: Select all
#libmysql=1
#LONG_SIZE=4
#BYTE_SIZE=1
*lCurLen.l = 0
*lRowData.l = 0
If OpenLibrary(#libmysql,"libmysql.dll")
CallDebugger
dbHnd.l=CallFunction(#libmysql,"mysql_init",dbHnd)
CallFunction(#libmysql,"mysql_real_connect", dbHnd, "erdrick.is-a-geek.com", "purebasic", "purebasic", "rpg", 3306, 0)
CallFunction(#libmysql, "mysql_real_query", dbHnd, "Select * from speech", Len("Select * from speech"))
mlMYSQL_RES.l = CallFunction(#libmysql, "mysql_store_result", dbHnd)
;CallFunction(#libmysql, "mysql_data_seek", mlMYSQL_RES, 0)
mlMYSQL_ROW.l = CallFunction(#libmysql, "mysql_fetch_row", mlMYSQL_RES)
mlMYSQL_FIELD_LENGTHS.l = CallFunction(#libmysql, "mysql_fetch_lengths", mlMYSQL_RES)
;Starting from 0, so the third field in this case
fieldnumber = 2
length=PeekL(mlMYSQL_FIELD_LENGTHS+4*fieldnumber)
fieldptr=PeekL(mlMYSQL_ROW+4*fieldnumber)
content.s=PeekS(fieldptr,length)
Debug content.s
EndIf
Thank you for your numerous replies