Raised This Month: $ Target: $400
 0% 

loop sql select


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
spamipolito
Junior Member
Join Date: Jun 2018
Old 07-01-2020 , 15:17   Re: loop sql select
Reply With Quote #2

PHP Code:

#define MAX_SKINS 4

public LoadSkins(const id)
{
    static 
szQuery[256], szData[1]

    new 
iLen 0;

    
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"SELECT ")

    for(new 
i=0<= MAX_SKINS;i++)
        
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"`F%d`%s "i== MAX_SKINS "" ",")

    
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"FROM `accounts` WHERE `PlayerID`='%d'"get_user_authid(id) )

    
szData[0] = id;

    
SQL_ThreadQuery(g_SqlTuple,"sql_piece_of_skins_thread"szQueryszData1);
}

public 
sql_piece_of_skins_thread(FailState,Handle:Query,Error[],Errcode,szData[],DataSize)
{
    if(
iFailState == TQUERY_CONNECT_FAILED || iFailState == TQUERY_QUERY_FAILED
    { 
        
log_amx("%s"szError)
        return
    } 
    else 
    {
        new 
id iData[0]

        for(new 
i=0;<= MAX_SKINS;i++)
            
DB_skins[i][id] = SQL_ReadResult(Query/*Colum Num*/);
            
        
inventory(id);
    } 
}


public 
TestConsult(const id)
{
    
// Use register_clcmd to testing consult. Return console print
    
new iLen 0
    
new szQuery[256]

    
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"SELECT ")

    for(new 
i=0<= MAX_SKINS;i++)
        
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"`F%d`%s "i== MAX_SKINS "" ",")

    
iLen += formatexszQueryiLen ], charsmaxszQuery ) - iLen"FROM `accounts` WHERE `PlayerID`='%d'")

    
console_print(id"%s"szQuery)


Share the structure of the database "accounts"

Last edited by spamipolito; 07-01-2020 at 15:33.
spamipolito 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 17:06.


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