]> git.mxchange.org Git - mailer.git/blobdiff - inc/db/lib-mysql3.php
Surfbar text updated, more masks applied, footer/timing removed in frametester module
[mailer.git] / inc / db / lib-mysql3.php
index b64e3937ec828ef647e2bec44dc6b9be87949201..95e409042d6c2421e031971dac3c5fa504521d0a 100644 (file)
@@ -236,10 +236,11 @@ function SQL_INSERTID() {
 // Escape a string for the database
 function SQL_ESCAPE($str) {
        global $link;
+
        if (!is_resource($link)) {
                // Fall-back to addslashes() when there is no link
                return addslashes($str);
-       }
+       } // END - if
 
        if (function_exists('mysql_real_escape_string')) {
                // The new and improved version
@@ -260,5 +261,30 @@ function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id) {
        // Return the result
        return SQL_QUERY_ESC($SQL, array(bigintval($id)), __FILE__, __LINE__);
 }
+// ALTER TABLE wrapper function
+function SQL_ALTER_TABLE($sql, $F, $L) {
+       // Shall we add?
+       if (eregi("ADD", $sql) > 0) {
+               // Extract table name
+               $tableArray = explode(" ", $sql);
+               $tableName = str_replace("`", "", $tableArray[2]);
+
+               // And column name as well
+               $columnName = str_replace("`", "", $tableArray[4]);
+
+               // Get column information
+               $result = SQL_QUERY_ESC("SHOW COLUMNS FROM %s LIKE '%s'",
+                       array($tableName, $columnName), __FILE__, __LINE__);
+
+               // Do we have no entry?
+               if (SQL_NUMROWS($result) == 0) {
+                       // Do the query
+                       return SQL_QUERY($sql, $F, $L, false);
+               } // END - if
+       } else {
+               // Send it to the SQL_QUERY() function
+               return SQL_QUERY($sql, $F, $L, false);
+       }
+}
 //
 ?>