Raised This Month: $32 Target: $400
 8% 

[INC] SQLVault


Post New Thread Reply   
 
Thread Tools Display Modes
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-10-2012 , 14:12   Re: [INC] SQLVault
Reply With Quote #81

So if you have STEAM_0:1:2345 and IP 12.34.56.78 with data, but then join with same Steam ID on a different IP such as 87.65.43.21, then you won't load that data?
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-10-2012 , 15:07   Re: [INC] SQLVault
Reply With Quote #82

Quote:
Originally Posted by Exolent[jNr] View Post
So if you have STEAM_0:1:2345 and IP 12.34.56.78 with data, but then join with same Steam ID on a different IP such as 87.65.43.21, then you won't load that data?
yeah , or if you join with diff STEAM ID on the same ip , it wont load that data
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-10-2012 , 15:40   Re: [INC] SQLVault
Reply With Quote #83

Quote:
Originally Posted by EpicMonkey View Post
yeah , or if you join with diff STEAM ID on the same ip , it wont load that data
Then yes, use the example you showed with random data.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-12-2012 , 10:06   Re: [INC] SQLVault
Reply With Quote #84

Quote:
Originally Posted by Exolent[jNr] View Post
Then yes, use the example you showed with random data.
aww man ..... , ive been thinking this upside down ....

What i actually want it to know if :

1.I save their ip address and steam id
2.When they connect with same ip and diff steam , his data will get loaded or if they connect with diff ip and steam id , his data will still get loaded.

I know it can be done this way
PHP Code:
public Save(id)
{
    new 
szAuthID[33], szIP[33];
    
get_user_authid(idszAuthIDcharsmax(szAuthID)
    
get_user_ip(idszIPcharsmax(szIP))
    
    
sqlv_pset_num_ex(g_hVaultszAuthID"Random1"g_randomdata1[id])
    
sqlv_pset_num_ex(g_hVaultszIP"Random2"g_randomdata2[id])
}

public 
Load(id)
{
    
    new 
szAuthID[33], szIP[33];
    
get_user_authid(idszAuthIDcharsmax(szAuthID)
    
get_user_ip(idszIPcharsmax(szIP))
    
    
g_randomdata1[id] = sqlv_get_num_ex(g_hVaultszAuthID"Random1")
    
g_randomdata2[id] = sqlv_get_num_ex(g_hVaultszIP"Random2")

Is there a better way to do it?

Last edited by EpicMonkey; 05-12-2012 at 10:08.
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2012 , 14:07   Re: [INC] SQLVault
Reply With Quote #85

Code:
Save(id) {     new keys[2][35];     get_user_authid(id, keys[0], charsmax(keys[]));     get_user_ip(id, keys[1], charsmax(keys[]));         sqlv_connect(gVault);         for(new i = 0; i < sizeof(keys); i++) {         sqlv_set_num_ex(gVault, keys[i], "some_data1", gSomeData1[id]);         sqlv_set_num_ex(gVault, keys[i], "some_data2", gSomeData2[id]);     }         sqlv_disconnect(gVault); } Load(id) {     new steamID[35], ip[32];     get_user_authid(id, steamID, charsmax(steamID));     get_user_ip(id, ip, charsmax(ip), 1);         sqlv_connect(gVault);         gSomeData1[id] = _get_num(steamID, ip, "some_data1");     gSomeData2[id] = _get_num(steamID, ip, "some_data2");         sqlv_disconnect(gVault); } _get_num(steamID[], ip[], key2[]) {     if(sqlv_key_exists_ex(gVault, steamID, key2)) {         return sqlv_get_num_ex(gVault, steamID, key2);     }     if(sqlv_key_exists_ex(gVault, ip, key2)) {         return sqlv_get_num_ex(gVault, ip, key2);     }     return 0; }
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!

Last edited by Exolent[jNr]; 05-12-2012 at 16:17.
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-12-2012 , 15:22   Re: [INC] SQLVault
Reply With Quote #86

Quote:
Originally Posted by Exolent[jNr] View Post
Code:
Save(id) {     new keys[2][35];     get_user_authid(id, keys[0], charsmax(keys[]));     get_user_ip(id, keys[1], charsmax(keys[]));         sqlv_connect(gVault);         for(new i = 0; i < sizeof(keys); i++) {         sqlv_set_num_ex(gVault, keys[i], "some_data1", gSomeData1[id]);         sqlv_set_num_ex(gVault, keys[i], "some_data2", gSomeData2[id]);     }         sqlv_disconnect(gVault); } Load(id) {     new steamID[35], ip[32];     get_user_authid(id, steamID, charsmax(steamID));     get_user_ip(id, ip, charsmax(ip), 1);         sqlv_connect(gVault);         gSomeData1[id] = _get_num(steamID, ip, "some_data1");     gSomeData2[id] = _get_num(steamID, ip, "some_data2");         sqlv_disconnect(gVault); } _get_num(const steamID[], const ip[], const key2[]) {     if(sqlv_key_exists_ex(gVault, steamID, key2)) {         return sqlv_get_num_ex(gVault, steamID, key2);     }     if(sqlv_key_exists_ex(gVault, ip, key2)) {         return sqlv_get_num_ex(gVault, ip, key2);     }     return 0; }
is there a difference in performance between the code i posted and the one you posted ?
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2012 , 15:47   Re: [INC] SQLVault
Reply With Quote #87

Quote:
Originally Posted by EpicMonkey View Post
is there a difference in performance between the code i posted and the one you posted ?
It caches the connection so it only connects and disconnects once for the function instead of connecting/disconnecting every sqlv_* function call.
Also, they have different logic.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
EpicMonkey
buttmonkey
Join Date: Feb 2012
Old 05-12-2012 , 15:53   Re: [INC] SQLVault
Reply With Quote #88

i see , am kinda tired right now to understand anything ... ill take a detailed look at your code tomorrow , thank you again

Edit : tried compiling the above code , showing a tag mismatch , argument 2
PHP Code:
if(sqlv_key_exists_ex(gVaultsteamIDkey2)) 

Last edited by EpicMonkey; 05-12-2012 at 16:08.
EpicMonkey is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 05-12-2012 , 16:17   Re: [INC] SQLVault
Reply With Quote #89

Quote:
Originally Posted by EpicMonkey View Post
Edit : tried compiling the above code , showing a tag mismatch , argument 2
PHP Code:
if(sqlv_key_exists_ex(gVaultsteamIDkey2)) 
Forgot SQLVault doesn't allow constants as keys. Fixed the _get_num() header.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
t3hNox
Senior Member
Join Date: Oct 2009
Old 06-15-2012 , 10:19   Re: [INC] SQLVault
Reply With Quote #90

This may be a random question but is it likely that there might be conflicts between sqlvault_ex include and SQLx module ?

I'm currently working on a plugin which uses both this include and SQLx module (although the include itself basically uses SQLx). I store some player information in SQLite (local) DB but I also have to update some information from time to time in another external DB thus I have SQLx tuple and I make threated query connections (I hope I used the terminology correctly).

The problem is when I try to update information in external DB. An error shows up saying that there's "no such table: table_name". I've had the same problem previously but then I thought I simply didn't understand SQL well enough and gave up. Now I suspect that there might be something related to this include.

I have made a test plugin which makes connections to external DB and everything is ok until I include sqlvault_ex.
I also get different error messages but they have the same error code (#1). For example, when I use SQLx alone and there is some problem with SQL table I get "Table 'db_name.table_name' doesn't exist" message but when I include sqlvault_ex I get this error message: "no such table: table_name". So I suspect there might be some kind of conflict.

On a side note on #2 post sqlv_key_exists_ex(SQLVault:hVault, szKey1[], szKey2[]) function description seems to be wrong.
t3hNox is offline
Reply


Thread Tools
Display Modes

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 13:56.


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