You are missing trading opportunities:
- Free trading apps
- Over 8,000 signals for copying
- Economic news for exploring financial markets
Registration
Log in
You agree to website policy and terms of use
If you do not have an account, please register
how to read the result of mysql_fetch_row function in MQL4 ?
I am currently developing a script to work with a MySQL database to read, insert, delete and modify.
The script is a big one, but the essence of working with the database will be understandable I think from one function.
However, in this example ID of record from table is returned, but it will not be a problem to remake, I remember and text and numbers returned from database, everything worked.
did a little investigative experiment
I have created a table with two fields
INT id; TEXT user
there are two rows in the table
id user
1 aaa
2 bbb
1. When querying "SELECT id FROM table", the fetch_row function returns (address)(address) 1 (address)(address) 2
2. The "SELECT user FROM table" query, the fetch_row function returns (address) aaa (address) bbb
Generally, this can be handled, the only pity is that it returns in string
If I query two fields "SELECT id, user FROM table", the function returns (address) 1 (address) (address) (address) 2
4. If we swap the "SELECT user, id FROM table" fields, the function returns (address) aaa (address) bbb
it turns out that only the first field from the string is clearly visible and another 4-byte address is added.
did a little investigative experiment
created a table with two fields
INT id; TEXT user
the table has two rows
id user
1 aaa
2 bbb
1. When querying "SELECT id FROM table" function fetch_row returns (address)(address) 1 (address)(address) 2
2. When requesting "SELECT user FROM table" function fetch_row returns (address) aaa (address) bbb
Generally it can be handled, but return is in string
3. if the function returns two fields "SELECT id, user FROM table", it returns (address) 1 (address) (address) 2
4. If we swap the "SELECT user, id FROM table" fields, the function returns (address) aaa (address) bbb
it turns out that only the first field from the string is explicitly seen and another 4-byte address is added.
How do you get this into the programme afterwards?
I'm basically going to write floating point numbers and read them.
I am currently developing a script to work with a MySQL database to read, insert, delete and modify.
The script is a big one, but the essence of working with the database will be understandable I think from one function.
True, this example returns record ID from the table, but to remake no problem, I remember and text and numbers returned from the database, all worked.
This is an interesting example, but it doesn't show how to read numerical data.
Basically, I want to use a base with a table of three columns for just two actions:
1) Read the first two columns (index and the first numeric column)
Then choose the most relevant number from the numeric column within the MQ4 program
2) Read from the index of that number the number in the second column.
Which functions should I use for this? And do they work normally in the specified DLL?
This is an interesting example, but it doesn't show how to read numerical data.
Have you written one line of code to see what is returned and how?
HIDDEN already gave a complete solution to read one field from the database. did you run it ?
If you can help write ansi to unicode converter for MKL5, the code of which is given in the previous post. I will send you working code for MKL4, it will also help you when writing class for MKL5.
MQL5 has functions to convert unicode. See /en/docs/convert/chararraytostring and /en/docs/convert/stringtochararray
Declare uchar arrays instead of strings in function import.
In import functions, do not declare strings, but arrays of type uchar
The problem is, unfortunately, that these strings are returned as a result of a function, not as one of its & parameters.
mysql_fetch_row returns a pointer to an array of strings - char**
--------
does anyone know if there are any low-level kernel functions that can return a char ** string from a char array ?
(like strcpy, strcat...)
and similarly from an int* array - some lib function to get its specific element ?
even if the function itself isn't designed for this operation directly :)
Full code implementation....
SQL dump of the database
Working result