12345678910111213141516171819202122 |
- #include <stdio.h>
- #include <zdb.h>
- #include "common.h"
- #include "mysql_connection.h"
- #include <string>
- std::string MySQLConnection::executeQuery(const char* query)
- {
- URL_T url = URL_new(("mysql://" + user + ":" + password + "@" + host + ":3306/" + database).c_str());
- ConnectionPool_T pool = ConnectionPool_new(url);
- ConnectionPool_start(pool);
- Connection_T con = ConnectionPool_getConnection(pool);
- ResultSet_T r = Connection_executeQuery(con, query);
- std::string result = ResultSet_next(r) ? ResultSet_getString(r, 1) : "";
- Connection_close(con);
- ConnectionPool_free(&pool);
- URL_free(&url);
- return result;
- }
|