Module installation - multiple tables

Have a question or a suggestion about a 3rd party addon module or plugin?
Let us know here.
Post Reply
boscopup
Forum Members
Forum Members
Posts: 35
Joined: Wed May 04, 2005 3:48 pm

Module installation - multiple tables

Post 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!
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Module installation - multiple tables

Post 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.
Follow me on twitter
Please post system information from "Extensions >> System Information" (there is a bbcode option) on all posts asking for assistance.
--------------------
If you can't bother explaining your problem well, you shouldn't expect much in the way of assistance.
boscopup
Forum Members
Forum Members
Posts: 35
Joined: Wed May 04, 2005 3:48 pm

Re: Module installation - multiple tables

Post 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. :(
boscopup
Forum Members
Forum Members
Posts: 35
Joined: Wed May 04, 2005 3:48 pm

Re: Module installation - multiple tables

Post 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!
Post Reply

Return to “Modules/Add-Ons”