MySQL!

 

Привет,

Я надеюсь, что здесь кто-то, кто хочет помочь мне пожалуйста. В русский форум, я помог в прошлый раз очень хорошо, поэтому я прошу вас еще раз за вашу помощь, пожалуйста.
Я хочу читать из базы данных MySQL, а Dont знаю, как это сделать. У меня уже есть моя код готов установить соединение с базой данных и тоже писать в базу данных.


Но как же я прочитал из базы данных?


Я нашел это: https://forum.mql4.com/15984 MySQL Wrapper и как я вижу, theire является функция для чтения из базы данных:


bool MySQL_FetchRow(string sQuery, string &sResultSet[]){
   
   int i;
   if (gbMySQLInitialized == FALSE) return(FALSE);   
   if (MYSQL_VERBOSE > 1) Print(sQuery);
   
   int liLength= StringLen(sQuery);    
   mysql_real_query(giMySQL, sQuery, liLength);   
   
   int liResult = mysql_store_result(giMySQL);
   ArrayResize(sResultSet, mysql_num_fields(liResult));
   MT4_mysql_fetch_row(liResult, sResultSet);  
  
   //for (i = 0; i < ArrayRange(sResultSet,0); i++){
   //     Print(i+"="+sResultSet[i]);
   //}
   mysql_free_result(liResult);
   return(MySQL_NoError());
}

bool MySQL_FetchArray(string sQuery, string &sResultSet[][]){
   
   int i,j;
   if (gbMySQLInitialized == FALSE) return(FALSE);   
   if (MYSQL_VERBOSE > 1) Print(sQuery);
   
   int liLength= StringLen(sQuery);    
   mysql_real_query(giMySQL, sQuery, liLength);   
   
   int liResult = mysql_store_result(giMySQL);
   string lsResult[0];
   int liNumRow   = mysql_num_rows(liResult);
   int liNumField = mysql_num_fields(liResult);
   
   ArrayResize(lsResult, liNumField);
   ArrayResize(sResultSet, liNumRow);
  // string sFieldSet[7];
  // ArrayResize(sFieldSet, mysql_num_fields(iResult));
  // MT4_mysql_fetch_fields_string(iResult, sFieldSet,FIELD_NAME);
   
   for (i = 0; i < liNumRow; i++){
      MT4_mysql_fetch_row(liResult, lsResult);  
      for (j = 0; j < liNumField; j++){
           sResultSet[i][j] = lsResult[j];
           //Print(i+","+j+":="+sResultSet[i][j]);
      }
   }
   mysql_free_result(liResult);
   return(MySQL_NoError());
}



Но я Dont получить этот код работает над скриптом или ЕА. Пожалуйста, помогите мне!!
Englisch
»
Russisch
Übersetzen

Hi,

i hope here is someone who wants to help me please. I want to read from a MySQL Database, and dont know how to do this. I already have my code ready to establish a connection to the database and too write into the database.


But how can i READ from the database?


I found this: https://forum.mql4.com/15984 MySQL Wrapper and as i see theire is a function to read from the database :


But i dont get this code working on a script or EA. Please help me!!


 
No idea??
 

Can you work with MySQL in some other language? PHP for example? If you do than you can use http51 library for MetaTrader. PHP (Perl|C++|etc) + MySQL will work on your local or remote server and MetaTrader will exchange data with it through http51 library. This way you can even build a Web-Interface to your trading system working on remote server and control it from anywhere :) The hard thing is to organize data exchange. You can use XML data and then parse it with MQL4 in MetaTrader.

 

Dimanjy

thanks for your suggestion. It sounds not easy but if this is the only way to read from the database i will try it. I have an Apache Webserver and PHP is runing too. So you think


  1. i can call a php script from the ea
  2. the php script runs the mysql query
  3. and returns the value to the ea?
Thanks a lot!
 
Нашел решение https://www.mql5.com/ru/code/10645
Причина обращения: