- February 12, 2014
- Posted by: Forex Wiki Team
- Category: Uncategorized
Writer:
Initially created by Russell, then modified by vedroid and now forked by lukins
Since construct 600 of MT4 was launched, it is not straightforward to speak with DLLs that use ANSI format for strings as a result of strings in MQL4 at the moment are in UNICODE format (learn extra right here).
This library is predicated on vedroid's modification of Russel's MySQL wrapper and makes use of methods taken from EAX_Mysql library and from snippets posted by gchrmt4
Any contribution appreciated.
Instance:
#embrace <mql4-mysql.mqh> string  host    = "localhost"; string  consumer    = "root"; string  move    = "123456"; string  dbName  = "information_schema"; int    port    = 3306; int    socket  = 0; int    shopper  = 0; int    dbConnectId = 0; bool    goodConnect = false; int begin ()     goodConnect = init_MySQL(dbConnectId, host, consumer, move, dbName, port, socket, shopper);         if ( !goodConnect )         return (1); // dangerous join         //+-------------------------------------------------------------------     //| Fetch a number of columns in a number of rows     //+-------------------------------------------------------------------        string question = StringConcatenate(         "SELECT `TABLE_NAME`, `TABLE_ROWS`, `CREATE_TIME`, `CHECK_TIME` ",             "FROM `TABLES` ",             "WHERE `TABLE_SCHEMA` = 'mysql'");     string knowledge[][4];  // essential: second dimension measurement have to be equal to the variety of columns     int end result = MySQL_FetchArray(dbConnectId, question, knowledge);         if ( outcome == 0 )         // Print("0 rows chosen");     else if ( outcome == -1 )         // Print("some error occured");     else         // Print("Question was profitable. Printing rows...");         int num_rows = ArrayRange(knowledge, 0);         int num_fields = ArrayRange(knowledge, 1);                 for ( int i = 0; i < num_rows; i++)             string line = "";                         for ( int j = 0; j < num_fields; j++ )               string worth = knowledge[i][j];                 line = StringConcatenate(line, worth, ";");                         Print(line);                     //+-------------------------------------------------------------------     //| Single row fetch     //| Just like array fetch     //+-------------------------------------------------------------------     string row[][4];  // essential: second dimension measurement have to be equal to the variety of columns     string rowQuery = StringConcatenate("SELECT `TABLE_NAME`, `TABLE_ROWS`, `CREATE_TIME`, `CHECK_TIME` ",             "FROM `TABLES` ",             "WHERE `TABLE_SCHEMA` = 'mysql' ",             "LIMIT 0,1");     int row_result = MySQL_FetchArray(dbConnectId, rowQuery, row);     line = "One row question: ";     for(int r=0; r < ArrayRange(row, 1); r++)       line = StringConcatenate(line, row[0][r], ";");         Print(line);         //+-------------------------------------------------------------------     //| Pattern INSERT     //| It is simply an instance, no one can insert into information_schema.     //+-------------------------------------------------------------------     /*string insertQuery  = StringConcatenate(         "INSERT INTO `CHARACTER_SETS` VALUES (", "sometext"                                         , "," , "oneMoreText"                                         , "," , "andVarialbe"                                         , "," , "nextWillBeNumber"                                         , "," , 2                                         , ")"         );     if ( MySQL_Query(dbConnectId, insertQuery) )         Print("insert good");     */             //+-------------------------------------------------------------------     deinit_MySQL(dbConnectId);     return (0); //+------------------------------------------------------------------+
Supply: