getDB();
echo '
Install check
';
echo 'The following tables will be created:
';
$tablesdef = simplexml_load_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'm_'.str_replace('.','#',$MOD).'_'.$tableInfo->getName();
echo "- table: ".$tableName.' (columns: '.$tableInfo->getColumnCount().")
\n";
}
echo '
';
echo 'Install';
break;
case 2:
$db = MMSystem::getInstance()->getDB();
try {
echo 'Install check
';
echo 'The following tables are created:
';
$tablesdef = simplexml_load_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'm_'.str_replace('.','#',$MOD).'_'.$tableInfo->getName();
$tableInfo->setName($tableName); // we need to add the module prefix
if ($db->tableExists($tableName))
$db->dropTable($tableName);
$refs = $tableInfo->getRefs();
foreach ($refs as $name=>$ref) {
$tableInfo->setRef($name, 'm_'.str_replace('.','#',$MOD).'_'.$ref['object'], $ref['column']);
}
$db->createTable($tableInfo);
echo "- table ".$tableName." created
\n";
}
echo '
';
$db->table('installinfo')->insert(array('type' => 'module', 'key' => $MOD, 'version' => $VERSION, 'attrib' => 0));
echo 'Go back';
}
catch (MFDBSQLException $ex) {
echo ''.$ex->getMessage().'
';
echo ''.$ex->getQuery().'
';
}
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break;
case 'upgrade':
switch ($STEP) {
default:
throw new BadFunctionCallException('Invalid step');
}
break;
case 'validate':
switch ($STEP) {
case 1:
$this->doDefaultValidate(__FILE__, $MOD, $VERSION);
break;
case 2:
$this->doDefaultValidateFixes(__FILE__, $MOD, $VERSION);
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break;
case 'uninstall':
switch ($STEP) {
case 1:
$db = MMSystem::getInstance()->getDB();
echo 'Uninstall check
';
echo 'The following tables will be removed:
';
$tablesdef = simplexml_load_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'm_'.str_replace('.','#',$MOD).'_'.$tableInfo->getName();
echo "- table: ".$tableName.' (columns: '.$tableInfo->getColumnCount().")
\n";
}
echo '
';
echo 'Uninstall';
break;
case 2:
$db = MMSystem::getInstance()->getDB();
echo 'Install check
';
echo 'The following tables are created:
';
$tablesdef = simplexml_load_file(dirname(__FILE__).DIRECTORY_SEPARATOR.'tables-'.$VERSION.'.xml');
echo '';
foreach ($tablesdef as $tabledef) {
$tableInfo = MFDBTableInfo::fromXML($tabledef);
$tableName = 'm_'.str_replace('.','#',$MOD).'_'.$tableInfo->getName();
$tableInfo->setName($tableName); // we need to add the module prefix
$db->dropTable($tableName);
echo "- table ".$tableName." removed
\n";
}
echo '
';
$db->table('installinfo')->delete(array('type' => 'module', 'key' => $MOD));
echo 'Go back';
break;
default:
throw new BadFunctionCallException('Invalid step');
}
break;
}