Page 1 of 1

Module installation - multiple tables

Posted: Mon May 22, 2006 2:59 pm
by boscopup
This is probably a really stupid coding error, but I can't seem to find it, and maybe something obvious will jump out to someone else...

I'm trying to install two tables, and I'm getting the first one and its _seq table, then the second one I only get the _seq table. Here's the code (I used ModuleMaker to make the skeleton files):

Code: Select all

	function Install()
	{
		
		// Typical Database Initialization
		$db = &$this->cms->db;
		
		// mysql-specific, but ignored by other database
		$taboptarray = array('mysql' => 'TYPE=MyISAM');
		$dict = NewDataDictionary($db);
		
		// CONTACTS table

    // table schema description
    $flds = "
			id I KEY,
			name C(80),
			email C(80),
			position C(80)
			";

		// create it. This should do error checking, but I'm a lazy sod.
		$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_testmodule_contacts",
				$flds, $taboptarray);
		$dict->ExecuteSQLArray($sqlarray);

		// create a sequence
		$db->CreateSequence(cms_db_prefix()."module_testmodule_contacts_seq");

		// CONTACTGROUPS table

		// table schema description
    $flds = "
			id I KEY,
			group C(80),
			contact I
			";

		// create it. This should do error checking, but I'm a lazy sod.
		$sqlarray = $dict->CreateTableSQL(cms_db_prefix()."module_testmodule_contactgroups",
				$flds, $taboptarray);
		$dict->ExecuteSQLArray($sqlarray);

		// create a sequence
		$db->CreateSequence(cms_db_prefix()."module_testmodule_contactgroups_seq");
	
		
		// permissions
		

		// put mention into the admin log
		$this->Audit( 0, $this->Lang('friendlyname'), $this->Lang('installed',$this->GetVersion()));
	}
After installing this module, I see the following tables:

cms_module_testmodule_contactgroups_seq
cms_module_testmodule_contacts
cms_module_testmodule_contacts_seq

What am I doing wrong to make the cms_module_testmodule_contactgroups table not get installed?

Btw, I'm using CMSMS 0.13, Apache/MySQL on a Linux webhost. This is my first time to try creating a module, but I don't see anything different about mine than what I see in other modules with multiple tables, so a new pair of eyes should be helpful. Thanks!

Re: Module installation - multiple tables

Posted: Mon May 22, 2006 5:30 pm
by calguy1000
if you look at the News module, the Uploads module or the FrontendUsers, Banners, SelfReg, or any of those modules' Install() routines we create numerous tables in them, they'll be a good reference.

Re: Module installation - multiple tables

Posted: Mon May 22, 2006 5:56 pm
by boscopup
Yes, I looked at the News module, and that's what I'm trying to copy. My News module has all its tables, but mine does not, and I don't see where my code is wrong? That's why I need a second pair of eyes. :) I literally copied and pasted the lines for the second one, and changed the name of the table. But it just won't create it!

The only difference I've seen is that the News module puts the $taboptarray line in both places... I don't know if that's necessary, but I tried it, and it still didn't work. Otherwise, I see absolutely NO differences between the code. :(

Re: Module installation - multiple tables

Posted: Mon May 22, 2006 6:14 pm
by boscopup
Aha! I found my error. I knew it was something stupid. I had named one of the fields "group", and that's not a good idea. ;)

Changed the name, and now all is happy. Thanks!