WikyBlog
Download

Plugins > MySQL Tables

This section describes three aspects of WikyBlog Plugins and MySQL Tables.

  1. Referencing in PHP
  2. Creating and Modifying
  3. Including in Plugins

Referencing Tables

The most important aspect of referencing tables in your plugin is the usage of the $wbTablePrefix variable.

<?php
global $wbTablePrefix;
$table = "`{$wbTablePrefix}custom_table`";

Creating and Modifying Tables

During the development process of your plugin, I highly recommend using phpMyAdmin to create and modify your tables beyond what can be accomplished with the Custom Data Types tool.

Including Tables With Your Plugin

Once your tables have been created, you can use the Plugin SQL tool in the Administrator's Control Panel to export the appropriate code for the sql.php file of your plugin. The sql.php file should be created in your plugin's root directory.

Example sql.php File

<?php
defined('WikyBlog') or die('Not an entry point...');
 
$dbData = 'a:1:{s:11:"url_example";a:5:{s:6:"Engine";s:6:"MyISAM";s:9:"Collation";s:15:"utf8_general_ci";s:15:"Default_charset";s:4:"utf8";s:7:"columns";a:2:{s:2:"id";s:36:"`id` int(11) NOT NULL auto_increment";s:3:"url";s:28:"`url` varchar(255) NOT NULL ";}s:4:"keys";a:1:{s:7:"PRIMARY";s:18:"PRIMARY KEY (`id`)";}}}';

This serialized code contains the following information for the url_example table.

url_example

Engine

MyISAM

Collation

utf8_general_ci

Default_charset

utf8

columns

id

`id` int(11) NOT NULL auto_increment

url

`url` varchar(255) NOT NULL

keys

PRIMARY

PRIMARY KEY (`id`)

Last modified 14:14 Wed, 26 Dec 2007 by Main. Accessed 464 times Children What Links Here share Share Except where expressly noted, this work is licensed under a Creative Commons License.