How to add a field in the dataabse with install function for a plugin I am creating.
ZiNgA BuRgA Offline
Fag
*******
Posts: 3,357
Joined: Jan 2008
Post: #4
RE: How to add a field in the dataabse with install function for a plugin I am creating.
It's ALTER TABLE (look at the example queries on the page I linked to).

SQL Code
ALTER TABLE 'mybb_forums' ADD COLUMN 'forum_ignore' INT(1) NOT NULL DEFAULT '0'

ALTER TABLE 'mybb_forums' DROP COLUMN 'forum_ignore'


PHP Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
function forumsignore_install()
{
global $db, $cache;
$db->write_query("ALTER TABLE ".TABLE_PREFIX."forums ADD 'forum_ignore' INT(1) NOT NULL DEFAULT '0'");
$cache->update_forums();
}
function forumsignore_is_installed()
{
global $db;
return $db->field_exists('forum_ignore', 'forums');
}
function forumsignore_uninstall()
{
global $db, $cache;
$db->write_query("ALTER TABLE ".TABLE_PREFIX."forums DROP 'forum_ignore'");
$cache->update_forums();
}


My Blog
08-05-2010 08:12 AM
Find all posts by this user Quote this message in a reply

« Next Oldest | Next Newest »

Messages In This Thread
RE: How to add a field in the dataabse with install function for a plugin I am creating. - ZiNgA BuRgA - 08-05-2010 08:12 AM

 Standard Tools
Forum Jump: