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

Solved Clarify docs: What is multiple result set for SQL_LockDatabase()?


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
Dragokas
Veteran Member
Join Date: Nov 2017
Location: Ukraine on fire
Old 06-20-2021 , 16:52   Clarify docs: What is multiple result set for SQL_LockDatabase()?
Reply With Quote #1

Hi,

can you clarify, please, this statement from docs:

Quote:
If your query returns multiple result sets, for example, a procedure call on MySQL that returns results, you must lock both the query and the entire fetch operation. SourceMod is only able to fetch one result set at a time, and all result sets must be cleared before a new query is started.
Can you show / explain example of such multiple result set?

Sample from docs:

PHP Code:
bool GetByAge_Query(Database dbint age)
{
    
char query[100];
    
FormatEx(querysizeof(query), "SELECT name FROM users WHERE age = %d"age);
 
    
SQL_LockDatabase(db);
 
    
DBResultSet hQuery SQL_Query(dbquery);
    if (
hQuery == null)
    {
        
SQL_UnlockDatabase(db);
        return 
false;
    }
 
    
SQL_UnlockDatabase(db);
 
    
PrintResults(hQuery);
 
    
delete hQuery;
 
    return 
true;
}

void PrintResults(Handle query)
{
    
/* Even if we have just one row, you must call SQL_FetchRow() first */
    
char name[MAX_NAME_LENGTH];
    while (
SQL_FetchRow(query))
    {
        
SQL_FetchString(query0namesizeof(name));
        
PrintToServer("Name \"%s\" was found."name);
    }

Do I correctly understand, if SQL_Query returns more than one row (such a way several calls to SQL_FetchRow will be required), in such case I should also move SQL_UnlockDatabase below the PrintResults?
__________________
Expert of CMD/VBS/VB6. Malware analyst. L4D fun (Bloody Witch & FreeZone)
[My plugins] [My tools] [GitHub] [Articles] [HiJackThis+] [Donate]

Last edited by Dragokas; 06-21-2021 at 12:48.
Dragokas 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 07:13.


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