Raised This Month: $ Target: $400
 0% 

Base Settings for MySQL


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
tla-nick
Junior Member
Join Date: Mar 2004
Location: Bradford UK
Old 05-27-2004 , 07:26   Base Settings for MySQL
Reply With Quote #1

I've been writing a couple of plugins which make use of the MySQL facilitys available and I was wondering what the opinion is on exec'ing mysql.cfg. ATM all the sql plugins I am using register (or attempt to register) the db cvars and exec the config file, which means that (at tme moment) mysql.cfg is being exec'd three times on each map load.

I was wondering if perhaps it might be better to put all of this in a hypothetical mysql_base plugin consisting of something like this:
Code:
//MySQL base plugin, required for use with all MySQL plugins #include <amxmodx> #include <amxmisc> public plugin_init() {     register_plugin("Base Plugin for MySQL","X.X","default")     register_cvar("amx_mysql_host","127.0.0.1")     register_cvar("amx_mysql_user","root")     register_cvar("amx_mysql_pass","")     register_cvar("amx_mysql_db","amx")     new configsDir[128]     get_configsdir(configsDir, 127)     server_cmd("exec %s/mysql.cfg", configsDir) }
So that people writing plugins for MySql don't need to worry about registering the cvars and exec'ing the config file etc.
__________________
Where did you want to be, the day before yesterday?

- Another Disgruntled Microsoft User
tla-nick is offline
AssKicR
Veteran Member
Join Date: Mar 2004
Location: Norway-Europe(GTM+1)
Old 05-27-2004 , 11:21  
Reply With Quote #2

the question is WTF ("Why The Fuck" in this case) you are executing mysql.cfg

All they have to do is put the Cvars in amx.cfg
__________________
My Plugins

Got ??
AssKicR is offline
tla-nick
Junior Member
Join Date: Mar 2004
Location: Bradford UK
Old 05-27-2004 , 13:37  
Reply With Quote #3

Quote:
Originally Posted by AssKicR
the question is WTF ("Why The Fuck" in this case) you are executing mysql.cfg

All they have to do is put the Cvars in amx.cfg
True, but in a default AMXX install the cvars are in %configsdir%/mysql.cfg so it's best to assume that any given installation will have it's DB cvars set from that file.

I know it's pretty safe to assume that amxx.cfg will be exec'd since both admin.amx and admin_mysql.amx will do this, but I don't want to encourage people to put cvars in there when the default is to put them somewhere else.
__________________
Where did you want to be, the day before yesterday?

- Another Disgruntled Microsoft User
tla-nick is offline
devicenull
Veteran Member
Join Date: Mar 2004
Location: CT
Old 05-27-2004 , 17:31  
Reply With Quote #4

Plugins using sql should exec the config file, other wise it may not get executed..
__________________
Various bits of semi-useful code in a bunch of languages: http://code.devicenull.org/
devicenull is offline
Johnny got his gun
Veteran Member
Join Date: Jan 2004
Location: Tokyo
Old 05-31-2004 , 09:42  
Reply With Quote #5

I think you all missed his point here. There is nothing executing the mysql.cfg, it's just a dead file that has some unregistered cvars lying about.

Well, for sure that base plugin could be done, and it could be optional. You would have to place it high up in plugins.ini also. Also doing a server_exec() right after server_cmd("exec some.cfg") helps to keep the cvars registered fast enough.
Johnny got his gun is offline
tla-nick
Junior Member
Join Date: Mar 2004
Location: Bradford UK
Old 05-31-2004 , 13:11  
Reply With Quote #6

Quote:
Originally Posted by Johnny got his gun
I think you all missed his point here. There is nothing executing the mysql.cfg, it's just a dead file that has some unregistered cvars lying about.
Thats kindof it yes it's mostly having loads of duplicate code offends me (unless it's more effecient to do it that way).

Quote:
Originally Posted by Johnny got his gun
Well, for sure that base plugin could be done, and it could be optional. You would have to place it high up in plugins.ini also. Also doing a server_exec() right after server_cmd("exec some.cfg") helps to keep the cvars registered fast enough.
I hadn't thought of doing it that way, but then I've never exactly sure what server_exec() does, basicly you'd be using it to stop the server from buffering any commands until the ones already there have finished executing?

I was thinking more along these lines, using admin_mysql as an example:

ATM plugin_init() for admin_mysql looks like this:
Code:
public plugin_init() {     register_plugin("Admin Base for MySQL","0.16a","AMXX Dev Team")     register_cvar("amx_mode","2.0")     register_cvar("amx_password_field","_pw")     register_cvar("amx_default_access","")     register_srvcmd("amx_sqladmins","adminSql")     register_cvar("amx_mysql_host","127.0.0.1")     register_cvar("amx_mysql_user","root")     register_cvar("amx_mysql_pass","")     register_cvar("amx_mysql_db","amx")     register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN)     remove_user_flags(0,read_flags("z")) // remove 'user' flag from server rights     new configsDir[128]     get_configsdir(configsDir, 127)     server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file     server_cmd("exec %s/mysql.cfg;amx_sqladmins", configsDir) }
What I was thinking of was using a mysql_base plugin as shown in the first post. and having this in admin_mysql:
Code:
public plugin_init() {     register_plugin("Admin Base for MySQL","0.16a","AMXX Dev Team")     register_cvar("amx_mode","2.0")     register_cvar("amx_password_field","_pw")     register_cvar("amx_default_access","")     register_srvcmd("amx_sqladmins","adminSql")     register_concmd("amx_reloadadmins","cmdReload",ADMIN_ADMIN)     remove_user_flags(0,read_flags("z")) // remove 'user' flag from server rights     new configsDir[128]     get_configsdir(configsDir, 127)     server_cmd("exec %s/amxx.cfg", configsDir) // Execute main configuration file } public plugin_cfg()     server_cmd("amx_sqladmins")
Since that way the cvars are registered and config file exec'd before the plugin(s) attempt to use them. The problem is of course that there isn't any 'safety net' this way, if the user has accidently removed the mysql_base (or dbi_base in the future) it's going to die

Ideally I suppose you might want to use:
Code:
public plugin_init() {     register_plugin("Plugin that uses MySQL","0.1","J.Random.Hacker")     if (!is_plugin_loaded("mysql_base"))         load_plugin("mysql_base") }
but of course load_plugin(const name[]) dosn't exist so thats not much help
__________________
Where did you want to be, the day before yesterday?

- Another Disgruntled Microsoft User
tla-nick 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 10:15.


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