AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Code Snippets/Tutorials (https://forums.alliedmods.net/forumdisplay.php?f=83)
-   -   [INC] SQLVault (https://forums.alliedmods.net/showthread.php?t=146849)

Doc-Holiday 06-15-2012 10:26

Quote:

Originally Posted by t3hNox (Post 1729233)
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

Exolent[jNr] 06-15-2012 10:31

Re: [INC] SQLVault
 
I don't think you can be running the SQLite module to use a local database, while also connected to a remote database.

t3hNox 06-15-2012 10:41

Re: [INC] SQLVault
 
That's really bad.
Would switching from SQLite to a remote DB for saving player information solve this problem ?

Exolent[jNr] 06-15-2012 10:43

Re: [INC] SQLVault
 
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.

t3hNox 06-15-2012 10:56

Re: [INC] SQLVault
 
Ok, thank you.

funfel 07-02-2012 11:57

Re: [INC] SQLVault
 
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?

Exolent[jNr] 07-02-2012 12:32

Re: [INC] SQLVault
 
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.

funfel 07-02-2012 12:51

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

Exolent[jNr] 07-02-2012 13:49

Re: [INC] SQLVault
 
Wherever this line is:
Code:

new eVaultData[ 10 ][ SQLVaultEntryEx ];
Change it to this:
Code:

static eVaultData[ 10 ][ SQLVaultEntryEx ];

funfel 07-02-2012 16:49

Re: [INC] SQLVault
 
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" )?


All times are GMT -4. The time now is 20:36.

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