Introduced wrapper function addCreateTableSql(), fixed parameter order:
[mailer.git] / inc / extensions-functions.php
index dc7660b24cd40c10b207bc8dad6b3398158821d0..90b2bd495df94252c973e6c72a9bd5241d997fd8 100644 (file)
@@ -1741,13 +1741,28 @@ function isExtensionFunctionFileReadable ($ext_name) {
        return ($GLOBALS['cache_array']['extension']['ext_func'][$ext_name] == 'Y');
 }
 
+// Adds a CREATE TABLE statement if the requested table is not there
+function addCreateTableSql ($tableName, $sql) {
+       // Is the table not there?
+       if (!isSqlTableCreated($tableName)) {
+               // Is not found, so add it
+               addExtensionSql('CREATE TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '` ' . $sql);
+       } else {
+               // Is already there, which should not happen
+               debug_report_bug(__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 ($table) {
+function addDropTableSql ($tableName) {
        // Is the table there?
-       if (isSqlTableCreated($table)) {
+       if (isSqlTableCreated($tableName)) {
                // Then add it, non-existing tables can be ignored because it will
                // happen with every newly installed extension.
-               addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $table . '`');
+               addExtensionSql('DROP TABLE `{?_MYSQL_PREFIX?}_' . $tableName . '`');
+
+               // Mark it as gone
+               $GLOBALS['isSqlTableCreated'][$tableName] = false;
        } // END - if
 }