+ $sql = "SELECT `".implode("`, `", $columns)."` FROM `{!_MYSQL_PREFIX!}_%s` WHERE ``='%s' LIMIT 1";
+
+ // Return the result
+ return SQL_QUERY_ESC($sql,
+ array(
+ bigintval($id),
+ $table,
+ $idRow
+ ), $F, $L);
+}
+
+// ALTER TABLE wrapper function
+function SQL_ALTER_TABLE ($sql, $F, $L) {
+ // This is the default result...
+ $result = false;
+
+ // Determine index/fulltext/unique word
+ // 12 3 3 2 2 3 3 2 2 3 3 21
+ $noIndex = ((eregi("INDEX", $sql) == false) && (eregi("FULLTEXT", $sql) == false) && (eregi("UNIQUE", $sql) == false));
+
+ // Shall we add/drop?
+ if (((eregi("ADD", $sql) > 0) || (eregi("DROP", $sql) > 0)) && ($noIndex)) {
+ // 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), $F, $L);
+
+ // Do we have no entry on ADD or an entry on DROP?
+ // 123 4 4 3 3 4 4 32 23 4 4 3 3 4 4 321
+ if (((SQL_NUMROWS($result) == 0) && (eregi("ADD", $sql) > 0)) || ((SQL_NUMROWS($result) == 1) && (eregi("DROP", $sql) > 0))) {
+ // Do the query
+ $result = SQL_QUERY($sql, $F, $L, false);
+ } // END - if
+ } else {
+ // Send it to the SQL_QUERY() function
+ $result = SQL_QUERY($sql, $F, $L, false);
+ }
+
+ // Return result
+ return $result;
+}
+
+// Getter for SQL link
+function SQL_GET_LINK () {
+ // Init link
+ $link = null;
+
+ // Is it in the globals?
+ if (isset($GLOBALS['sql_link'])) {
+ // Then take it
+ $link = $GLOBALS['sql_link'];
+ } // END - if
+
+ // Return it
+ return $link;
+}
+
+// Setter for link
+function SQL_SET_LINK ($link) {
+ // Is this a resource or null?
+ if ((!is_resource($link)) && (!is_null($link))) {
+ // This should never happen!
+ trigger_error(sprintf("link is not resource or null. Type: %s", gettype($link)));
+ } // END - if
+
+ // Set it
+ $GLOBALS['sql_link'] = $link;
+}
+
+// Checks if the link is up
+function SQL_IS_LINK_UP () {
+ // Get the link
+ $link = SQL_GET_LINK();