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

[INC] SQLVault


Post New Thread Reply   
 
Thread Tools Display Modes
Doc-Holiday
AlliedModders Donor
Join Date: Jul 2007
Old 06-15-2012 , 10:26  
Reply With Quote #91

Quote:
Originally Posted by t3hNox View Post
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.
Sql vault can do both for you. It just makes sql coding easier and allows nvault like scripting for sql
Doc-Holiday is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 10:31   Re: [INC] SQLVault
Reply With Quote #92

I don't think you can be running the SQLite module to use a local database, while also connected to a remote database.
__________________
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:41   Re: [INC] SQLVault
Reply With Quote #93

That's really bad.
Would switching from SQLite to a remote DB for saving player information solve this problem ?
t3hNox is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 06-15-2012 , 10:43   Re: [INC] SQLVault
Reply With Quote #94

It should. The way SQLx works is that you can set the driver type.
For SQLite, the driver is "sqlite" which forces connections and queries to local.
For normal, the driver is "mysql" which allows local database (if local MySQL server is running) and remote database.
__________________
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:56   Re: [INC] SQLVault
Reply With Quote #95

Ok, thank you.
t3hNox is offline
funfel
Member
Join Date: Apr 2011
Old 07-02-2012 , 11:57   Re: [INC] SQLVault
Reply With Quote #96

Hey, i just met the big problem, here is the code:
Code:
new eVaultData[ 10 ][ SQLVaultEntryEx ];
    
    switch( _motdtype_iType )
    {
        case _motd_LEVEL:
        {
            sqlv_read_set_ex( g_hVault, eVaultData, sizeof( eVaultData ), _, "`key2` = 'level'", "`data` DESC" );
        
            for( new i = 0; i < 10; i++ )
            {
                sqlv_get_data_ex( g_hVault, eVaultData[ i ][ SQLVEx_Key1 ], "name", sData, sizeof( sData ) - 1 );
            
                iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "%d. %s<br>", i++, sData );
            }
            
            
            iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "</td><td style=^"text-align: center^">" );
            
            for( new i = 0; i < 10; i++ )
            {
                iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "%d<br>", eVaultData[ i ][ SQLVEx_Data ] );
            }
            
            iLen += formatex( sText[ iLen ], sizeof( sText ) - iLen - 1, "</table></center></body></html>" );
            
            show_motd( id, sText, "Top10" );
        }
    }
0 errors with compile etc., but when I am trying to use this function on my test server, I am always getting this same log:
Code:
  L 07/02/2012 - 17:30:06: [AMXX] Run time error 3: stack error 
  L 07/02/2012 - 17:30:06: [AMXX]    [0] expmod_official.sma::Motd_Top10 (line 593)
593 line is new eVaultData[ 10 ][ SQLVaultEntryEx ];. Exolent, Can you help me?

Last edited by funfel; 07-02-2012 at 12:01.
funfel is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-02-2012 , 12:32   Re: [INC] SQLVault
Reply With Quote #97

That is a very large variable. If you see the enum in the include file, the struct for vault entries contains large arrays.

To fix this, make the variable static so it isn't created and destroyed each time, thus always staying in the stack and not causing errors when out of memory.
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
funfel
Member
Join Date: Apr 2011
Old 07-02-2012 , 12:51   Re: [INC] SQLVault
Reply With Quote #98

so I should write static eVaultData[ 10 ][ SQLVaultEntryEx ]; at the start of the plug or sth like this?

Last edited by funfel; 07-02-2012 at 12:52.
funfel is offline
Exolent[jNr]
Veteran Member
Join Date: Feb 2007
Location: Tennessee
Old 07-02-2012 , 13:49   Re: [INC] SQLVault
Reply With Quote #99

Wherever this line is:
Code:
new eVaultData[ 10 ][ SQLVaultEntryEx ];
Change it to this:
Code:
static eVaultData[ 10 ][ SQLVaultEntryEx ];
__________________
No private work or selling mods.
Quote:
Originally Posted by xPaw View Post
I love you exolent!
Exolent[jNr] is offline
funfel
Member
Join Date: Apr 2011
Old 07-02-2012 , 16:49   Re: [INC] SQLVault
Reply With Quote #100

Thanks a lot. It works!

One more question.
If I write "`key2` = 'level'" in sqlv_read_set_ex, sqlv_read_set_ex returns a value for key2 (level) in variable eVaultData[ i ][ SQLVEx_Data ]? Or I must use sqlv_get_num_ex( g_hVault, eVaultData[ i ][ SQLVEx_Key1 ], "level" )?
funfel is offline
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 02:13.


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