AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Solved Work with sqlx and sqlite in the same plugin (https://forums.alliedmods.net/showthread.php?t=333317)

iceeedr 07-02-2021 10:43

Work with sqlx and sqlite in the same plugin
 
I'm having doubts on how to use the 2 affinities at the same time, it may be that I have misunderstood when reading the include.

PHP Code:

/* Sublime AMXX Editor v2.2 */

#include <amxmodx>
#include <sqlx>
#pragma defclasslib sqlite sqlite

#define PLUGIN  "New Plug-In"
#define VERSION "1.0"
#define AUTHOR  "Author"

public plugin_init()
{
        
register_plugin(PLUGINVERSIONAUTHOR)

        
SQL_SetAffinity("sqlite")

        new 
aff[15]
        
SQL_GetAffinity(affcharsmax(aff))
        
server_print("Driver = %s"aff// Printed Driver = sqlite

        
set_task(2.0"ChangeDriver")
}

public 
ChangeDriver()
{
        
SQL_SetAffinity("sqlx")

        new 
aff[15]
        
SQL_GetAffinity(affcharsmax(aff))
        
server_print("Driver = %s"aff// Printed Driver = sqlite



Natsheh 07-02-2021 11:24

Re: Work with sqlx and sqlite in the same plugin
 
Quote:

Originally Posted by Arkshine (Post 2252764)
Just a matter to select the wanted driver. API is the same.

SQL_SetAffinity("sqlite") or SQL_SetAffinity("mysql")

Now about autoloading module, depending what you want to do.
If you want to load only sqlite module, you need to do:
Code:

#pragma defclasslib sqlx sqlite
#include <sqlx>

if you want to load both module mysql and sqlite, so to change driver anytime, then:
Code:

#include "sqlx"
#pragma defclasslib sqlite sqlite



Shadows Adi 07-02-2021 12:52

Re: Work with sqlx and sqlite in the same plugin
 
Quote:

Originally Posted by iceeedr (Post 2751725)

Code:
public ChangeDriver() {         SQL_SetAffinity("mysql") // sqlx is not a driver, it's a module         new aff[15]         SQL_GetAffinity(aff, charsmax(aff))         server_print("Driver = %s", aff) // Printed Driver = sqlite }


iceeedr 07-02-2021 13:38

Re: Work with sqlx and sqlite in the same plugin
 
Oops, lack of attention from me, I spent so much time trying to figure out the problem that it went unnoticed, thanks.


All times are GMT -4. The time now is 02:33.

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