To execute a SQL query, use the CQuery::Create(string query) factory function to generate a Query_t (a shared pointer to a CQuery instance). You can then call Execute(MYSQL *connection) on the instance to run the query against a specific MySQL connection.
To handle the results or errors asynchronously, you can register callbacks using OnExecutionFinished (for successful results) and OnError (for error handling). After execution, the result set can be retrieved via GetResult().
// Example of creating and executing a query
auto query = CQuery::Create("SELECT * FROM users");
query->OnExecutionFinished([](ResultSet_t result) {
// Handle the successful result set
});
query->OnError([](unsigned int errorid, string error) {
// Handle the error
});
bool success = query->Execute(mysql_connection);