How To Create New Database Table On ClipBucket Plugin Installation

If you are creating a plugin and you would like to create a new table in MySQL database upon installation, follow the steps below.

Step 1:

Create a new PHP file in plugin folder and name it install_plugin_name.php

Step 2:

Paste following code into that file.



function install_plugin_name()
	global $db;
	'CREATE TABLE IF NOT EXISTS '.tbl("your_table_name ").' (
	  `your_column_name` text NOT NULL
	$db->Execute("INSERT INTO  ".tbl(‘your_table_name’)." (your_column_name) VALUES ('')");
function install_plugin_name();

Save it.

Step 3:

Now install your plugin and go to phpMyAdmin. Click on your ClipBucket database name and there you will see your newly created table among other ClipBucket tables.

How To Drop Plugin Table On Uninstallation

1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)