+// Adds a CREATE TABLE statement if the requested table is not there
+function addCreateTableSql ($tableName, $sql, $comment) {
+ // Is the table not there?
+ if (!ifSqlTableExists($tableName)) {
+ // Is not found, so add it
+ addExtensionSql('CREATE TABLE
+ `{?_MYSQL_PREFIX?}_' . $tableName . '` (' . $sql . ')
+ENGINE = {?_TABLE_TYPE?}
+CHARACTER SET utf8
+COLLATE utf8_general_ci
+COMMENT ' . chr(39) . $comment . chr(39));
+ } else {
+ // Is already there, which should not happen
+ reportBug(__FUNCTION__, __LINE__, 'The table ' . $tableName . ' is already created which should not happen.');
+ }
+}
+
+// Adds a DROP TABLE statement if the requested tabled is there
+function addDropTableSql ($tableName) {
+ // Is the table there?
+ if (ifSqlTableExists($tableName)) {
+ // Then add it, non-existing tables can be ignored because it will
+ // happen with every newly installed extension.
+ addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '`');
+
+ // Mark it as gone
+ $GLOBALS['ifSqlTableExists'][$tableName] = false;
+ } // END - if
+}
+
+// Adds a RENAME TABLE stament if 'from' table exist and 'to' table not
+function addRenameTableSql ($fromTable, $toTable) {
+ // Is renaming required?
+ if ((ifSqlTableExists($fromTable)) && (!ifSqlTableExists($toTable))) {
+ // Add it
+ addExtensionSql('RENAME TABLE `{?_MYSQL_PREFIX?}_' . $fromTable . '` TO `{?_MYSQL_PREFIX?}_' . $toTable . '`');
+
+ // Mark both tables
+ $GLOBALS['ifSqlTableExists'][$fromTable] = false;
+ $GLOBALS['ifSqlTableExists'][$toTable] = true;
+ } // END - if
+}
+