MySQL Plugins Table


When creating a plugin you need to store anything about your plugin in the the plugins table, the structure of this table looks like this:

img

Should be easy to understand if you know MySQL a little bit. However your sql query to insert data should look similar to this (example from the blog plugin).

$jakdb->query('INSERT INTO '.DB_PREFIX.'plugins (`id`, `name`, `description`, `active`, `access`, `pluginorder`, `pluginpath`, `phpcode`, `phpcodeadmin`, `sidenavhtml`, `usergroup`, `uninstallfile`, `pluginversion`, `time`) VALUES (NULL, "Blog", "Run your own blog.", 1, 1, 4, "blog", "require_once APP_PATH.'plugins/blog/blog.php';", "if ($page == 'blog') {
        require_once APP_PATH.'plugins/blog/admin/blog.php';
           $JAK_PROVED = 1;
           $checkp = 1;
        }", "../plugins/blog/admin/template/blognav.php", "blog", "uninstall.php", "1.0", NOW())');

Let's go thru in detail:

  • ID: is auto_increment so it should be always NULL
  • Name: Please choose a unique name for your plugin.
  • Description: Describe your plugin.
  • Active: The value should be always 1
  • Pluginorder: set the value to whatever you like, usually 1
  • Pluginpath: This should be the same as the Name and please be sure it is unique.
  • PHPCode: the absolute path to your main plugin file.
  • PHPCodeAdmin: the absolute path to your main admin plugin file with a check.
  • SideNavHtml: the relative path to your navigation file for the administration panel.
  • Usergroup: if your plugin is user-group based, enter the name for access this plugin.
  • Uninstall file: the name of your uninstall.php file in your plugin directory.
  • Pluginversion: the version of your plugin, usually starts with 1.0.
  • Time: should be NOW(), so when we install the plugin the time is set correctly.