Raised This Month: $51 Target: $400
 12% 

Changing database connection - threaded queries


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ilusion9
Veteran Member
Join Date: Jun 2018
Location: Romania
Old 02-11-2020 , 09:24   Changing database connection - threaded queries
Reply With Quote #1

What happens with threaded queries if the hDatabase (global variable) is changed with another database handle? Lets say these threaded queries are finished after the change. Are they throwing errors (with db == null or rs == null), or are finished successfully?

Example:
PHP Code:

public void OnConfigsExecuted()
{
    
Database.Connect(Database_OnConnect"playeractivity");
}

public 
void Database_OnConnect(Database db, const char[] errorany data)
{
    if (!
db)
    {
        
g_Database null;
        
LogError("Could not connect to the database: %s"error);
        return;
    }
    
    if (!
g_Database)
    {
        
g_Database db;
    }
    else
    {
        if (
db.IsSameConnection(g_Database))
        {
            
delete db;
        }
        else
        {
            
delete g_Database;
            
g_Database db;
        }
    }
}

public 
void OnMapEnd()
{
    if (!
g_Database)
    {
        return;
    }

    
// send threaded query here

Lets say the query from OnMapEnd is executed after the map change (and after the Database.Connect thing - lets say I changed the database configurations and now there's a new connection: db.IsSameConnection(g_Database) returns false). What happens with the query?
__________________

Last edited by Ilusion9; 02-11-2020 at 09:24.
Ilusion9 is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 18:24.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode