Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: HelloWorld ServoInterfaceBoardExample1 4180_Lab4
Diff: services/mysql/MySQLClient.h
- Revision:
- 5:dd63a1e02b1b
- Parent:
- 0:632c9925f013
- Child:
- 6:b7dd7cde8ad2
diff -r fd826cad83c0 -r dd63a1e02b1b services/mysql/MySQLClient.h
--- a/services/mysql/MySQLClient.h Fri Jul 09 14:46:47 2010 +0000
+++ b/services/mysql/MySQLClient.h Tue Jul 27 15:59:42 2010 +0000
@@ -37,28 +37,55 @@
typedef unsigned char byte;
+///MySQL client results
enum MySQLResult
{
MYSQL_OK,
MYSQL_PROCESSING,
MYSQL_PRTCL,
- MYSQL_SETUP, //Not properly configured
- MYSQL_DNS, //Could not resolve name
- MYSQL_AUTHFAILED, //Auth failure
- MYSQL_READY, //Ready to send commands
- MYSQL_SQL, //SQL Error
- MYSQL_TIMEOUT, //Connection timeout
- MYSQL_CONN //Connection error
+ MYSQL_SETUP, ///Not properly configured
+ MYSQL_DNS, ///Could not resolve name
+ MYSQL_AUTHFAILED, ///Auth failure
+ MYSQL_READY, ///Ready to send commands
+ MYSQL_SQL, ///SQL Error
+ MYSQL_TIMEOUT, ///Connection timeout
+ MYSQL_CONN ///Connection error
};
+///A MySQL Client
+/**
+This MySQL client implements a limited subset of the MySQL internal client/server protocol (including authentication), for server versions 4.1 and newer.
+*/
class MySQLClient : protected NetService
{
public:
+ ///Instantiates the MySQL client
MySQLClient();
virtual ~MySQLClient();
//High Level setup functions
+
+ ///Opens a connection to a server
+ /**
+ Opens a connection to the server host using the provided username, password passowrd and selecting database
+ On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+ @param host : server
+ @param user : username
+ @param db : database to use
+ @param pMethod : callback to call on each request completion
+ */
MySQLResult open(Host& host, const string& user, const string& password, const string& db, void (*pMethod)(MySQLResult)); //Non blocking
+
+ ///Opens a connection to a server
+ /**
+ Opens a connection to the server host using the provided username, password passowrd and selecting database
+ On completion of this call (and any further one), the callback set in parameter is fired with the result of that command in parameter
+ @param host : server
+ @param user : username
+ @param db : database to use
+ @param pItem : callback's class instance
+ @param pMethod : callback's method to call on each request completion
+ */
template<class T>
MySQLResult open(Host& host, const string& user, const string& password, const string& db, T* pItem, void (T::*pMethod)(MySQLResult)) //Non blocking
{
@@ -67,8 +94,17 @@
return MYSQL_PROCESSING;
}
+
+ ///Executes an SQL command
+ /**
+ Executes an SQL request on the SQL server
+ This is a non-blocking function
+ On completion, the callback set in the open function is fired with the result of the command in parameter
+ @param sqlCommand SQL request to execute
+ */
MySQLResult sql(string& sqlCommand);
+ ///Closes the connection to the server
MySQLResult exit();
void setOnResult( void (*pMethod)(MySQLResult) );
@@ -81,6 +117,10 @@
m_pCbMeth = (void (CDummy::*)(MySQLResult)) pMethod;
}
+ ///Setups timeout
+ /**
+ @param ms : time of connection inactivity in ms after which the request should timeout
+ */
void setTimeout(int ms);
virtual void poll(); //Called by NetServices