Keep MySQL connect available to wasm units
This commit is contained in:
@@ -15,31 +15,6 @@ static void mysql_register_request_connection(MySQL* db)
|
|||||||
connections.push_back(db);
|
connections.push_back(db);
|
||||||
}
|
}
|
||||||
|
|
||||||
MySQL* mysql_connect(String host, String username, String password)
|
|
||||||
{
|
|
||||||
if(context)
|
|
||||||
{
|
|
||||||
for(void* raw : context->resources.mysql_connections)
|
|
||||||
{
|
|
||||||
MySQL* db = (MySQL*)raw;
|
|
||||||
if(db && db->request_pooled && db->connection && db->request_host == host && db->request_username == username && db->request_password == password)
|
|
||||||
{
|
|
||||||
db->request_leases++;
|
|
||||||
return(db);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
MySQL* db = new MySQL();
|
|
||||||
db->request_cleanup_delete = true;
|
|
||||||
db->request_pooled = context != 0;
|
|
||||||
db->request_leases = 1;
|
|
||||||
db->request_host = host;
|
|
||||||
db->request_username = username;
|
|
||||||
db->request_password = password;
|
|
||||||
db->connect(host, username, password);
|
|
||||||
return(db);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool MySQL::connect(String host, String username, String password)
|
bool MySQL::connect(String host, String username, String password)
|
||||||
{
|
{
|
||||||
// Register regardless of outcome: tracking is about the wrapper's
|
// Register regardless of outcome: tracking is about the wrapper's
|
||||||
|
|||||||
@@ -44,7 +44,30 @@ struct MySQL {
|
|||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
MySQL* mysql_connect(String host = "localhost", String username = "root", String password = "");
|
inline MySQL* mysql_connect(String host = "localhost", String username = "root", String password = "")
|
||||||
|
{
|
||||||
|
if(context)
|
||||||
|
{
|
||||||
|
for(void* raw : context->resources.mysql_connections)
|
||||||
|
{
|
||||||
|
MySQL* db = (MySQL*)raw;
|
||||||
|
if(db && db->request_pooled && db->connection && db->request_host == host && db->request_username == username && db->request_password == password)
|
||||||
|
{
|
||||||
|
db->request_leases++;
|
||||||
|
return(db);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
MySQL* db = new MySQL();
|
||||||
|
db->request_cleanup_delete = true;
|
||||||
|
db->request_pooled = context != 0;
|
||||||
|
db->request_leases = 1;
|
||||||
|
db->request_host = host;
|
||||||
|
db->request_username = username;
|
||||||
|
db->request_password = password;
|
||||||
|
db->connect(host, username, password);
|
||||||
|
return(db);
|
||||||
|
}
|
||||||
|
|
||||||
inline void mysql_disconnect(MySQL* m)
|
inline void mysql_disconnect(MySQL* m)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user