[SOLVED]Module install script

Talk about writing modules and plugins for CMS Made Simple, or about specific core functionality. This board is for PHP programmers that are contributing to CMSMS not for site developers
Locked
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

[SOLVED]Module install script

Post by vinyl »

I am struggling with the install script I am making for my very first module.

I followed a how-to and peeked at another module. My script shows no differences, but my main "module_bannermatic" table IS NOT being created.

The "module_bannermatic_seq" IS being created.

The only error I see in the logs is:

Code: Select all

[27-Dec-2014 21:44:25] PHP Warning:  implode() [<a href='function.implode'>function.implode</a>]: Invalid arguments passed in path/cmsms/lib/adodb_lite/adodb-datadict.inc.php on line 740
This is in my "method.install.php":

Code: Select all

<?php 
if (!isset($gCms))
exit;

$db = $this->GetDb();

// mysql-specific, but ignored by other database
$taboptarray = array('mysql' => 'ENGINE=MyISAM');
$dict = NewDataDictionary($db);

$flds = "
bannerid I KEY AUTO,
name C(255),
description X,
filename C(255),
filepath C(255),
from T,
to T,
active I,
default I
";

$sqlarray = $dict->CreateTableSQL(cms_db_prefix() . "module_bannermatic", $flds, $taboptarray);
$dict->ExecuteSQLArray($sqlarray);

$db->CreateSequence(cms_db_prefix().'module_bannermatic_seq');

$this->CreatePermission('Bannermatic Admin', 'Manage banners Bannermatic');        

?>
What am I missing?
Last edited by vinyl on Sat Dec 27, 2014 9:50 pm, edited 2 times in total.
calguy1000
Support Guru
Support Guru
Posts: 8169
Joined: Tue Oct 19, 2004 6:44 pm
Location: Fernie British Columbia, Canada

Re: Module instap script

Post by calguy1000 »

After this line:

Code: Select all

$dict->ExecuteSQLArray($sqlarray);
add:
debug_display($db->sql);
debug_display($db->ErrorMsg());
die();

I am certain that you will find that some of your column names are reserved words in mysql.
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.
vinyl
Forum Members
Forum Members
Posts: 149
Joined: Mon Jul 13, 2009 8:18 pm

Re: Module install script

Post by vinyl »

Thanks, seems like there is an error indeed:

Code: Select all

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ')ENGINE MyISAM CHARACTER SET utf8 COLLATE utf8_general_ci' at line 3
Backtracked the error to the field named "default". Seems you can't use that name for a field :)
Locked

Return to “Developers Discussion”