I am still trying to find out how to create a database table when initializing the plugin (see New Plugin: Best users per month).
I could find the documentation, however, without code example. And checking all existing plugins, I could only find the event logger that uses init_queries.
Now I have 2 questions:
1. Registering the module
In qa-plugin.php: Do I have to register a new php-file? Which type do I need, event?
qa_register_plugin_module('event','qa-event-logger.php', 'qa_event_logger', 'Event Logger'); // (example from event logger)
or can I use init_queries directly in the layer.php?
2. Using init_queries
For the code within init_queries (the table name is qa_userscores), I would use the following. Is there any mistake in the code?
function init_queries($tableslc) {
$tablename=qa_db_add_table_prefix('userscores');
if(!in_array($tablename, $tableslc)) {
//require_once QA_INCLUDE_DIR.'qa-app-users.php';
//require_once QA_INCLUDE_DIR.'qa-db-maxima.php';
return 'CREATE TABLE IF NOT EXISTS `'.$tablename.'` (
`date` date NOT NULL,
`userid` int(10) unsigned NOT NULL,
`points` int(11) NOT NULL DEFAULT '0',
KEY `userid` (`userid`),
KEY `date` (`date`)
)
';
}
}