install function help?
Posted: Sat Dec 24, 2005 2:38 pm
Hey all,
I am working on a new module and am having some difficulty formating my SQL to adodb format so that the tables and fileds get created. Any help or suggestions would be appreciated!
Here is my install() function so far:
Thanks!
Luke
I am working on a new module and am having some difficulty formating my SQL to adodb format so that the tables and fileds get created. Any help or suggestions would be appreciated!

Here is my install() function so far:
Code: Select all
function Install()
{
$db = $this->cms->db;
$dict = NewDataDictionary($db);
//menu items
$flds = "
itemid I KEY,
menuid I NOTNULL DEFAULT 0,
text C,
url C,
showmenu C(40),
";
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_milonic_items",
$flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
$db->CreateSequence(cms_db_prefix()."module_milonic_items_seq");
//menus
$flds = "
menuid I KEY,
projectid I NOTNULL DEFAULT 0,
styleid I NOTNULL DEFAULT 0,
name C(40) NOTNULL DEFAULT menuname,
alwaysvisible I,
orientation I,
overflow C(20),
";
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_milonic_menus",
$flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
$db->CreateSequence(cms_db_prefix()."module_milonic_menus_seq");
//projects
$flds = "
projectid I KEY,
menuCloseDelay I NOTNULL DEFAULT 500,
menuOpenDelay I NOTNULL DEFAULT 150,
subOffsetTop I NOTNULL DEFUALT 0,
subOffsetLeft I NOTNULL DEFUALT 0,
name C(100),
";
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_milonic_projects",
$flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
$db->CreateSequence(cms_db_prefix()."module_milonic_projects_seq");
//styles
$flds = "
styleid I KEY,
name C(40) NOTNULL DEFAULT stylename,
oncolor C(6),
onbgcolor C(6),
offcolor C(6),
offbgcolor C(6),
padding I,
separatorsize I,
borderwidth I,
fontfamily C(25),
fontsize C(6),
";
$taboptarray = array('mysql' => 'TYPE=MyISAM');
$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_milonic_styles",
$flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);
$db->CreateSequence(cms_db_prefix()."module_milonic_styles_seq");
// create a permission
$this->CreatePermission('Use milonic', 'Use milonic');
// create a preference
$this->SetPreference("sing_loudly", true);
// put mention into the admin log
$this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('installed',$this->GetVersion()));
}
Luke