// Executes the query
 $error_create = false;
 $result = PMA_DBI_try_query($sql_query) or $error_create = true;
 if ($error_create == false) {
     $sql_query = $query_cpy . ';';
     unset($query_cpy);
     $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
     // garvin: If comments were sent, enable relation stuff
     require_once './libs/relation.lib.php';
     require_once './libs/transformations.lib.php';
     $cfgRelation = PMA_getRelationsParam();
     // garvin: Update comment table, if a comment was set.
     if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork'] && PMA_MYSQL_INT_VERSION < 40100) {
         foreach ($field_comments as $fieldindex => $fieldcomment) {
             if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
                 PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment, '', 'pmadb');
             }
         }
     }
     // garvin: Update comment table for mime types [MIME]
     if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
         foreach ($field_mimetype as $fieldindex => $mimetype) {
             if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
                 PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
             }
         }
     }
     $message = $strTable . ' ' . htmlspecialchars(PMA_backquote($db) . '.' . PMA_backquote($table)) . ' ' . $strHasBeenCreated;
     $display_query = $sql_query;
     unset($sql_query);
     // do not switch to sql.php - as there is no row to be displayed on a new table
Ejemplo n.º 2
0
/**
 * Gets the comments for all rows of a table
 *
 * @param   string   the name of the db to check for
 * @param   string   the name of the table to check for
 *
 * @return  array    [field_name] = comment
 *
 * @global  array    the list of relations settings
 *
 * @access  public
 *
 * @authors  Mike Beck <*****@*****.**>
 *           and lem9
 */
function PMA_getComments($db, $table = '')
{
    global $cfgRelation;
    if ($table != '') {
        // MySQL 4.1.x native column comments
        if (PMA_MYSQL_INT_VERSION >= 40100) {
            $fields = PMA_DBI_get_fields($db, $table);
            if ($fields) {
                foreach ($fields as $key => $field) {
                    $tmp_col = $field['Field'];
                    if (!empty($field['Comment'])) {
                        $native_comment[$tmp_col] = $field['Comment'];
                    }
                }
                if (isset($native_comment)) {
                    $comment = $native_comment;
                }
            }
        }
        // pmadb internal column comments
        // (this function can be called even if $cfgRelation['commwork'] is
        // FALSE, to get native column comments, so recheck here)
        if ($cfgRelation['commwork']) {
            $com_qry = '
                 SELECT column_name,
                        comment
                   FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
                  WHERE db_name    = \'' . PMA_sqlAddslashes($db) . '\'
                    AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
            $com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
        }
    } else {
        // pmadb internal db comments
        $com_qry = '
             SELECT ' . PMA_backquote('comment') . '
               FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
              WHERE db_name     = \'' . PMA_sqlAddslashes($db) . '\'
                AND table_name  = \'\'
                AND column_name = \'(db_comment)\'';
        $com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
    }
    if (isset($com_rs) && PMA_DBI_num_rows($com_rs) > 0) {
        $i = 0;
        while ($row = PMA_DBI_fetch_assoc($com_rs)) {
            $i++;
            $col = $table != '' ? $row['column_name'] : $i;
            if (strlen($row['comment']) > 0) {
                $comment[$col] = $row['comment'];
                // if this version supports native comments and this function
                // was called with a table parameter
                if (PMA_MYSQL_INT_VERSION >= 40100 && isset($table) && strlen($table)) {
                    // if native comment found, use it instead of pmadb
                    if (!empty($native_comment[$col])) {
                        $comment[$col] = $native_comment[$col];
                    } else {
                        // no native comment, so migrate pmadb-style to native
                        PMA_setComment($db, $table, $col, $comment[$col], '', 'native');
                        // and erase the pmadb-style comment
                        PMA_setComment($db, $table, $col, '', '', 'pmadb');
                    }
                }
            }
        }
        // end while
        PMA_DBI_free_result($com_rs);
        unset($com_rs);
    }
    if (isset($comment) && is_array($comment)) {
        return $comment;
    } else {
        return FALSE;
    }
}
Ejemplo n.º 3
0
 }
 // Executes the query
 $error_create = false;
 $result = PMA_mysql_query($sql_query) or $error_create = true;
 if ($error_create == false) {
     $sql_query = $query_cpy . ';';
     unset($query_cpy);
     $message = $strTable . ' ' . htmlspecialchars($table) . ' ' . $strHasBeenCreated;
     // garvin: If comments were sent, enable relation stuff
     require_once './libraries/relation.lib.php';
     require_once './libraries/transformations.lib.php';
     $cfgRelation = PMA_getRelationsParam();
     // garvin: Update comment table, if a comment was set.
     if (isset($field_comments) && is_array($field_comments) && $cfgRelation['commwork']) {
         foreach ($field_comments as $fieldindex => $fieldcomment) {
             PMA_setComment($db, $table, $field_name[$fieldindex], $fieldcomment);
         }
     }
     // garvin: Update comment table for mime types [MIME]
     if (isset($field_mimetype) && is_array($field_mimetype) && $cfgRelation['commwork'] && $cfgRelation['mimework'] && $cfg['BrowseMIME']) {
         foreach ($field_mimetype as $fieldindex => $mimetype) {
             PMA_setMIME($db, $table, $field_name[$fieldindex], $mimetype, $field_transformation[$fieldindex], $field_transformation_options[$fieldindex]);
         }
     }
     require './' . $cfg['DefaultTabTable'];
     $abort = TRUE;
     exit;
 } else {
     PMA_mysqlDie('', '', '', $err_url, FALSE);
     // garvin: An error happened while inserting/updating a table definition.
     // to prevent total loss of that data, we embed the form once again.
Ejemplo n.º 4
0
            $upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['table_info']) . ' SET display_field = \'' . PMA_sqlAddslashes($display_field) . '\'' . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        } else {
            $upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['table_info']) . ' WHERE db_name  = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
        }
    } elseif ($display_field != '') {
        $upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['table_info']) . '(db_name, table_name, display_field) ' . ' VALUES(' . '\'' . PMA_sqlAddslashes($db) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($display_field) . '\')';
    }
    if (isset($upd_query)) {
        $upd_rs = PMA_query_as_cu($upd_query);
    }
}
// end if
if ($cfgRelation['commwork'] && isset($submit_comm) && $submit_comm == 'true') {
    foreach ($comment as $key => $value) {
        // garvin: I exported the snippet here to a function (relation.lib.php) , so it can be used multiple times throughout other pages where you can set comments.
        PMA_setComment($db, $table, $key, $value);
    }
    // end while (transferred data)
}
// end if (commwork)
// If we did an update, refresh our data
if (isset($submit_rel) && $submit_rel == 'true') {
    if ($cfgRelation['relwork']) {
        $existrel = PMA_getForeigners($db, $table, '', 'internal');
    }
    if ($tbl_type == 'INNODB') {
        $existrel_innodb = PMA_getForeigners($db, $table, '', 'innodb');
    }
}
if ($cfgRelation['displaywork']) {
    $disp = PMA_getDisplayField($db, $table);