Page 1 of 1

[SOLVED]Module install script

Posted: Sat Dec 27, 2014 8:59 pm
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?

Re: Module instap script

Posted: Sat Dec 27, 2014 9:12 pm
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.

Re: Module install script

Posted: Sat Dec 27, 2014 9:33 pm
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 :)