Raised This Month: $ Target: $400
 0% 

SQLX


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
YamiKaitou
Has a lovely bunch of coconuts
Join Date: Apr 2006
Location: Texas
Old 02-16-2007 , 20:45   Re: SQLX
Reply With Quote #1

I know that the SQL_PrepareQuery returns a Hangle:query and you execute it by using SQL_Execute(Handle:query). Then I just use SQL_ReadResults(Handle:query,column[,extra stuff]) to get the results. But all of my querys are always only affecting one line, so I don't have to worry about changing rows.

To see if the connection is established, I just use if(g_DBCon){//stuff dealing with db}
YamiKaitou is offline
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-16-2007 , 21:53   Re: SQLX
Reply With Quote #2

I don't think you understand how a threaded query works: it is asynchronous, meaning it does not actually "happen" the moment you execute it. This means you cannot extract the data from it in the same function it is executed.

With your code, you would have to do the checking in the "SelectHandle" function, or move it back to non-threaded querying. The native to retrieve the data is SQL_ReadResult (there's also a field one that I can't remember).
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Drak
Veteran Member
Join Date: Jul 2005
Old 02-16-2007 , 22:17   Re: SQLX
Reply With Quote #3

Code:
public is_user_registered(id) {     if(!g_SqlConnection) { // We lost connection, don't continue.         return 0     }     new authid[33]     get_user_authid(id,authid,32)     //format(query,255,"SELECT steamid FROM main WHERE steamid='%s'",authid)     new Handle:Query = SQL_PrepareQuery(g_SqlConnection,"SELECT steamid FROM main WHERE steamid='%s'",authid)     if(!SQL_Execute(Query))     {         // if there were any problems         SQL_QueryError(Query,g_error,511)         set_fail_state(g_error)     }     // checks to make sure there's more results     // notice that it starts at the first row, rather than null     new Data     while(SQL_MoreResults(Query))     {         Data = SQL_ReadResult(Query,0)         SQL_NextRow(Query)         console_print(0,"[AMXX SQL] Your SteamID: %s Matched with the SQL SteamID: %s",authid,Query)         SQL_FreeHandle(Query)         return 1     }     return 0     //SQL_FreeHandle(g_SqlConnection) }
This seemed to work, but I still am clueless on some parts. Like, is it necessary to close the connection after the Query is complete?
Drak is offline
Send a message via MSN to Drak
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 02-16-2007 , 22:24   Re: SQLX
Reply With Quote #4

No, and your method is pretty stupid TBH, but I'm not going to argue.

You can just close the connection on plugin_end instead of then.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Reply



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 00:34.


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