Raised This Month: $ Target: $400
 0% 

Help on sqlx


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Fedcomp
Member
Join Date: Feb 2009
Location: Russia
Old 12-04-2010 , 19:19   Re: Help on sqlx
Reply With Quote #2

Global:
PHP Code:
new Handle:g_h_Sql 
Connect to db:
PHP Code:
g_h_Sql SQL_MakeDbTuple("127.0.0.1""dbuser""dbpass""dbname"
Exec query:
PHP Code:
new s_Query[128], s_Name[32]

get_user_name(ids_Namecharsmax(s_Name))
format(s_Querycharsmax(s_Query), "SELECT steam_id FROM table WHERE name='%s'"s_Name)
SQL_ThreadQuery(g_h_Sql"Handle_Query"s_Query
Read results:
PHP Code:
public Handle_Query(i_FailStateHandle:h_Querys_Error[], i_Errcodes_Data[], i_DataSizeFloat:f_QueueTime)
{
    if (
i_FailState == TQUERY_CONNECT_FAILED)
        
set_fail_state("Could not connect to database.")
    else if (
i_FailState == TQUERY_QUERY_FAILED)
        
set_fail_state("Query failed.")
    else if (
i_Errcode)
        
log_amx("Error on query: %s"s_Error)
    else
        if (
SQL_NumResults(h_Query))
        {
            new 
i_SteamIDs_SteamID[32]
            
            
i_SteamID SQL_FieldNameToNum(h_Query"steam_id")
            
            while (
SQL_MoreResults(h_Query))
            {
                
SQL_ReadResult(h_Queryi_SteamIDs_SteamIDcharsmax(s_SteamID))
            
                if (
equal(s_SteamID"STEAM_0:0:123456")){
                   
// action example 
                
}
                
SQL_NextRow(h_Query)
            }
        }

use search to more
__________________
Fedcomp is offline
Send a message via ICQ to Fedcomp
 



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 11:20.


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