Attach MySQL to MQ4 - page 4

 

if the function returns a pointer, it is a regular int (4 byte) value

we will further use this int in memcpy or strcpy (if we know it is a NULL-terminated string)

#import "msvcrt.dll"
        int memcpy(uchar &Destination[], uchar &Source[], int Length);
        int memcpy(uchar &Destination[], int Source, int Length);
        int memcpy(int Destination, uchar &Source[], int Length);
#import

so, for our rams, we need functions to get lengths Length.

is

mysql_num_fields

mysql_fetch_lengths

 
sergeev:

so for our rams, we will need functions to get Lengths.

is

mysql_num_fields

mysql_fetch_lengths

There's not a lot of information for a complete understanding(for beginner programmers).

 
HIDDEN:

There is not much information to fully understand (beginner programmers).


for example? what function from MySQL is difficult to work with in MQL ?
 
sergeev:

for example? what function from MySQL causes difficulties when working in MQL ?

Return of an array of data, I think this is the only problem that hasn't been fully solved.

P.S. Post the full code of the function to return the array of data from the database in MQL4. I understand that it was possible to do.

 
HIDDEN:

Return of data array, I think this is the only problem that hasn't been fully solved.

P.S. Post the full code of the function to return the array of data from the database in MQL4. I understand that it was possible to do it.


here you go, not to get too far into the wilderness, I'll show by the example mysql_get_client_info

it returns a pointer to a NULL-terminated string (char*)

that we're doing:

#import "libmysql.dll"
    int mysql_get_client_info(); // функция вернула char*
#import "msvcrt.dll"
    int strcpy(uchar &strDestination[], int strSource); // копируем NULL-строку из source в байтовый массив 
#import

void OnStart()
{
    uchar byte[100]; int ptr;
    ptr=mysql_get_client_info(); // получили указатель на строку
    strcpy(byte, ptr); // скопировали его в массив
    string st=CharArrayToString(byte); Print("client_info="+st); // вывели на печать
}

And that's it. ANALOGICALLY everything is pulled from other functions which return pointers.

PS
Sorry it's not MQL4.

 
sergeev:

That's all.

So this is all for mql5, and the implementation is impossible for 4?
 
HIDDEN:
So, all this is for mql5, and the implementation is impossible for 4?

I think it will be similar. only it is necessary to manipulate with type in memcpy (instead of uchar give int[] or string& ).
try it, if you get results (or not), let me know.
 
sergeev:

I think it will be the same. only you need to manipulate with type in memcpy (instead of uchar give int[] or string& ).
try it, and if you get results (or not), let me know.
I've twisted and turned this way and that, nothing worked for me on 4. Sometimes even the terminal crashes completely.
 
sergeev:

Here's an example of mysql_get_client_info

it returns a pointer to a NULL-terminated string (char*)

that we're doing:

And that's it. ANALOGICALLY everything is pulled from other functions which return pointers.

PS
Sorry it's not MQL4.


Were you able to get normal results from mysql_fetch_row? I suddenly needed a muscle and as luck would have it, after a terminal update, my method went bust.
 
Graff:

Did you manage to get normal results from mysql_fetch_row? I suddenly needed a muscle and as badly as possible after the terminal updates my method got screwed.

Yes, everything works perfectly, but so far I've only done it for MQL5

An example of how it works from above in my post