AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   SQL_ReadResult to read string (https://forums.alliedmods.net/showthread.php?t=283078)

tonykaram1993 05-24-2016 14:19

SQL_ReadResult to read string
 
Hello,

I have the follwing query:
"formatex( strQuery, charsmax( strQuery ), "SELECT Salt FROM Player WHERE ( Player.SteamID = %s )", strPlayerAuthID );"

Now if I understand MySQL correctly, this should return the string called Salt of that player. My question is, how do I go about to read that result?

I saw this in the include files:
Code:

/**
 * Retrieves the current result.
 * A successful query starts at the first result,
 *  so you should not call SQL_NextRow() first.
 * Passing no extra params - return int
 * Passing one extra param - return float in 1st extra arg
 * Passing two extra params - return string in 1st arg, max length in 2nd
 * Example:
 *  new num = SQL_ReadResult(query, 0)
 *  new Float:num2
 *  new str[32]
 *  SQL_ReadResult(query, 1, num2)
 *  SQL_ReadResult(query, 2, str, 31)
 */
native SQL_ReadResult(Handle:query, column, any:...);

My query does not return a row, but rather a single entry (the string salt), so I should do the following correct? Correct me if I am wrong please.
Code:

SQL_ReadResult( hQuery, 0, strSalt, charsmax( strSalt ) );
Thank you!

HamletEagle 05-24-2016 14:58

Re: SQL_ReadResult to read string
 
Passing two extra params - return string in 1st arg, max length in 2nd

Read what you posted.

tonykaram1993 05-26-2016 09:53

Re: SQL_ReadResult to read string
 
Quote:

Originally Posted by HamletEagle (Post 2421763)
Passing two extra params - return string in 1st arg, max length in 2nd

Read what you posted.

That was not what I was asking about. I already know that if I want to read it into a string, I have to pass the string with its length. I am talking about the column part. Since I am only getting one value (hence only 1 column), I should pass 0 as the column value. Right?

klippy 05-26-2016 12:54

Re: SQL_ReadResult to read string
 
Yes, the second parameter tells which column to pull data from, where 0 is the first one.

Why didn't you just try it by yourself?


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

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