Raised This Month: $ Target: $400
 0% 

SQL_ConnectCustom for threaded MySQL


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
busy.orange
Member
Join Date: May 2009
Old 08-19-2009 , 05:31   SQL_ConnectCustom for threaded MySQL
Reply With Quote #1

Using SQL_UnlockDatabase(g_hDatabase); without SQL_LockDatabase
can crash server?
What do you think about my code?
PHP Code:
public OnClientPostAdminCheck(client)
{
    if (
IsFakeClient(client)) return;
    if (
SQLConnect())//Try connect to DB
    
{
             
SQL_TQuery(g_hDatabaseT_IgnoreResults"bla bla");
    }
}
public 
T_IgnoreResults(Handle:ownerHandle:hndl, const String:error[], any:data)
{
    if (
hndl == INVALID_HANDLE)
    {
        
LogError("Query failed! %s"error);
    } 

bool:SQLConnect()
{
    
// connect to the database if needed
    
if (g_hDatabase == INVALID_HANDLE)
    {
        new 
Handle:KV INVALID_HANDLE;            
        
KV=CreateKeyValues("pishpish");
        
KvSetString(KV,"driver","mysql");
        
KvSetString(KV,"host","remotehost");
        
KvSetString(KV,"database","DB");
        
KvSetString(KV,"user","user");
        
KvSetString(KV,"pass","pass");
        
KvSetString(KV,"port","3306");
        
decl String:error[255];
        
g_hDatabase SQL_ConnectCustom(KV,error,sizeof(error),true);
        if (
g_hDatabase != INVALID_HANDLE)
        {
            
SQL_UnlockDatabase(g_hDatabase);
            return 
true
        
}
        
LogMessage("Failed to connect to database, error: %s"error);
        return 
false;
    }
    else return 
true;

busy.orange is offline
 



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:40.


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