]> git.mxchange.org Git - mailer.git/blobdiff - inc/db/lib-mysql3.php
Extension ext-forced/network continued:
[mailer.git] / inc / db / lib-mysql3.php
index 473159e03d5b3a3b8fe0b2fd85e994e77f9dfd3c..c3369299057b789583e7a10acf90de706c26ac60 100644 (file)
@@ -17,7 +17,7 @@
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
  * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
- * For more information visit: http://www.mxchange.org                  *
+ * For more information visit: http://mxchange.org                      *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
  * it under the terms of the GNU General Public License as published by *
@@ -341,8 +341,20 @@ function SQL_RESULT_FROM_ARRAY ($table, $columns, $idRow, $id, $F, $L) {
                return false;
        } // END  - if
 
-       // Prepare the SQL statement
-       $sql = "SELECT `".implode("`,`", $columns)."` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s' LIMIT 1";
+       // Is this is a simple array?
+       if ((is_array($columns[0])) && (isset($columns[0]['column']))) {
+               // Begin with SQL query
+               $sql = 'SELECT ';
+
+               // No, it comes from XML, so get it back from it
+               $sql .= getSqlPartFromXmlArray($columns);
+
+               // Finalize it
+               $sql .= " FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s' LIMIT 1";
+       } else {
+               // Yes, prepare the SQL statement
+               $sql = 'SELECT `' . implode('`,`', $columns) . "` FROM `{?_MYSQL_PREFIX?}_%s` WHERE `%s`='%s' LIMIT 1";
+       }
 
        // Return the result
        return SQL_QUERY_ESC($sql,
@@ -363,16 +375,16 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
        $result = false;
 
        // Determine index/fulltext/unique word
-       $noIndex = (
-       (
-               isInStringIgnoreCase('INDEX', $sql)
-       ) && (
-               isInStringIgnoreCase('KEY', $sql)
-       ) && (
-               isInStringIgnoreCase('FULLTEXT', $sql)
-       ) && (
-               isInStringIgnoreCase('UNIQUE', $sql)
-       )
+       $isAlterIndex = (
+               (
+                       isInString('INDEX', $sql)
+               ) || (
+                       isInString('KEY', $sql)
+               ) || (
+                       isInString('FULLTEXT', $sql)
+               ) || (
+                       isInString('UNIQUE', $sql)
+               )
        );
 
        // Extract table name
@@ -380,10 +392,10 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
        $tableName = str_replace('`', '', $tableArray[2]);
 
        // Debug log
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'sql=' . $sql . ',tableName=' . $tableName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>,isAlterIndex=' . intval($isAlterIndex));
 
        // Shall we add/drop?
-       if (((isInString('ADD', $sql)) || (isInString('DROP', $sql)) || (isInString('CHANGE', $sql))) && ($noIndex === true)) {
+       if (((isInString('ADD', $sql)) || (isInString('DROP', $sql)) || (isInString('CHANGE', $sql))) && ($isAlterIndex === false)) {
                // Try two columns, one should fix
                foreach (array(4,5) as $idx) {
                        // If an entry is not set, abort here
@@ -423,7 +435,7 @@ function SQL_ALTER_TABLE ($sql, $F, $L, $enableCodes = true) {
        } elseif ((getTableType() == 'InnoDB') && (isInString('FULLTEXT', $sql))) {
                // Skip this query silently because InnoDB does not understand fulltext indexes
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, sprintf("Skipped FULLTEXT: sql=%s,tableName=%s,hasZeroNums=%d,file=%s,line=%s", $sql, $tableName, intval((is_bool($result)) ? 0 : isSqlTableColumnFound($columnName)), $F, $L));
-       } elseif ($noIndex === false) {
+       } elseif ($isAlterIndex === true) {
                // And column name as well without backticks
                $keyName = str_replace('`', '', $tableArray[5]);
                //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'keyName=' . $keyName . ',tableArray=<pre>' . print_r($tableArray, true) . '</pre>');
@@ -579,7 +591,7 @@ function isSqlTableCreated ($tableName) {
 
 // Is a table column there?
 function isSqlTableColumnFound ($tableName, $columnName) {
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columName . ' - ENTERED!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ' - ENTERED!');
        // Do we have cache?
        if (!isset($GLOBALS[__FUNCTION__][$tableName][$columnName])) {
                // And column name as well
@@ -598,7 +610,7 @@ function isSqlTableColumnFound ($tableName, $columnName) {
        } // END - if
 
        // Return cache
-       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columName . ',result=' . intval($GLOBALS[__FUNCTION__][$tableName][$columnName]) . ' - EXIT!');
+       //* DEBUG: */ logDebugMessage(__FUNCTION__, __LINE__, 'tableName=' . $tableName . ',columnName=' . $columnName . ',result=' . intval($GLOBALS[__FUNCTION__][$tableName][$columnName]) . ' - EXIT!');
        return $GLOBALS[__FUNCTION__][$tableName][$columnName];
 }