⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 relation.lib.php

📁 架設ROSE私服必備之物 ROSE數據庫
💻 PHP
📖 第 1 页 / 共 3 页
字号:
    }    $test_qry = '         SELECT ' . PMA_backquote('comment') . ',                mimetype,                transformation,                transformation_options           FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '          WHERE ' . $cols['db_name']     . ' = \'' . PMA_sqlAddslashes($db) . '\'            AND ' . $cols['table_name']  . ' = \'' . PMA_sqlAddslashes($table) . '\'            AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';    $test_rs   = PMA_query_as_cu($test_qry, true, PMA_DBI_QUERY_STORE);    if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {        $row = PMA_DBI_fetch_assoc($test_rs);        PMA_DBI_free_result($test_rs);        if (strlen($comment) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {            $upd_query = '                 UPDATE ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '                    SET ' . PMA_backquote('comment') . ' = \'' . PMA_sqlAddslashes($comment) . '\'                  WHERE ' . $cols['db_name']     . ' = \'' . PMA_sqlAddslashes($db) . '\'                    AND ' . $cols['table_name']  . ' = \'' . PMA_sqlAddslashes($table) . '\'                    AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddSlashes($col) . '\'';        } else {            $upd_query = '                 DELETE FROM                        ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '                  WHERE ' . $cols['db_name']     . ' = \'' . PMA_sqlAddslashes($db) . '\'                    AND ' . $cols['table_name']  . ' = \'' . PMA_sqlAddslashes($table) . '\'                    AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';        }    } elseif (strlen($comment) > 0) {        $upd_query = '             INSERT INTO                    ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '                    (db_name, table_name, column_name, ' . PMA_backquote('comment') . ')             VALUES (                   \'' . PMA_sqlAddslashes($db) . '\',                   \'' . PMA_sqlAddslashes($table) . '\',                   \'' . PMA_sqlAddslashes($col) . '\',                   \'' . PMA_sqlAddslashes($comment) . '\')';    }    if (isset($upd_query)){        $upd_rs    = PMA_query_as_cu($upd_query);        unset($upd_query);        return true;    } else {        return false;    }} // end of 'PMA_setComment()' function/** * Set a SQL history entry * * @param   string   the name of the db * @param   string   the name of the table * @param   string   the username * @param   string   the sql query * * @global  array    the list of relations settings * * @return  boolean  true * * @access  public */function PMA_setHistory($db, $table, $username, $sqlquery) {    global $cfgRelation;    $hist_rs = PMA_query_as_cu('         INSERT INTO                ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '              (' . PMA_backquote('username') . ',                ' . PMA_backquote('db') . ',                ' . PMA_backquote('table') . ',                ' . PMA_backquote('timevalue') . ',                ' . PMA_backquote('sqlquery') . ')         VALUES              (\'' . PMA_sqlAddslashes($username) . '\',                \'' . PMA_sqlAddslashes($db) . '\',                \'' . PMA_sqlAddslashes($table) . '\',                NOW(),                \'' . PMA_sqlAddslashes($sqlquery) . '\')');    return true;} // end of 'PMA_setHistory()' function/** * Gets a SQL history entry * * @param   string   the username * * @global  array    the list of relations settings * * @return  array    list of history items * * @access  public */function PMA_getHistory($username) {    global $cfgRelation;    $hist_query = '         SELECT ' . PMA_backquote('db') . ',                ' . PMA_backquote('table') . ',                ' . PMA_backquote('sqlquery') . '           FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '          WHERE username = \'' . PMA_sqlAddslashes($username) . '\'       ORDER BY id DESC';    $hist_rs = PMA_query_as_cu($hist_query);    unset($hist_query);    $history = array();    while ($row = PMA_DBI_fetch_assoc($hist_rs)) {        $history[] = $row;    }    PMA_DBI_free_result($hist_rs);    return $history;} // end of 'PMA_getHistory()' function/** * Set a SQL history entry * * @param   string   the name of the db * @param   string   the name of the table * @param   string   the username * @param   string   the sql query * * @global  array    the list of relations settings * @global  array    global phpMyAdmin configuration * * @return  boolean  true * * @access  public */function PMA_purgeHistory($username) {    global $cfgRelation, $cfg;    $purge_query = '         SELECT timevalue           FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '          WHERE username = \'' . PMA_sqlAddSlashes($username) . '\'       ORDER BY timevalue DESC LIMIT ' . $cfg['QueryHistoryMax'] . ', 1';    $purge_rs = PMA_query_as_cu($purge_query);    $i = 0;    $row = PMA_DBI_fetch_row($purge_rs);    PMA_DBI_free_result($purge_rs);    if (is_array($row) && isset($row[0]) && $row[0] > 0) {        $maxtime = $row[0];        // quotes added around $maxtime to prevent a difficult to        // reproduce problem        $remove_rs = PMA_query_as_cu('             DELETE FROM                    ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['history']) . '              WHERE timevalue <= \'' . $maxtime . '\'');    }    return true;} // end of 'PMA_purgeHistory()' function/** * Prepares the dropdown for one mode * * @param   array    the keys and values for foreigns * @param   string   the current data of the dropdown * @param   string   the needed mode * * @global  array    global phpMyAdmin configuration * * @return  array   the <option value=""><option>s * * @access  private */function PMA_foreignDropdownBuild($foreign, $data, $mode) {    global $cfg;    $reloptions = array();    foreach ($foreign as $key => $value) {        if (PMA_strlen($value) <= $cfg['LimitChars']) {            $vtitle = '';            $value  = htmlspecialchars($value);        } else {            $vtitle  = htmlspecialchars($value);            $value  = htmlspecialchars(substr($value, 0, $cfg['LimitChars']) . '...');        }        $reloption = '                <option value="' . htmlspecialchars($key) . '"';        if ($vtitle != '') {            $reloption .= ' title="' . $vtitle . '"';        }        if ((string) $key == (string) $data) {           $reloption .= ' selected="selected"';        }        if ($mode == 'content-id') {            $reloptions[] = $reloption . '>' . $value . '&nbsp;-&nbsp;' . htmlspecialchars($key) .  '</option>' . "\n";        } else {            $reloptions[] = $reloption . '>' . htmlspecialchars($key) .  '&nbsp;-&nbsp;' . $value . '</option>' . "\n";        }    } // end foreach    return $reloptions;} // end of 'PMA_foreignDropdownBuild' function/** * Outputs dropdown with values of foreign fields * * @param   string   the query of the foreign keys * @param   string   the foreign field * @param   string   the foreign field to display * @param   string   the current data of the dropdown * * @global  array    global phpMyAdmin configuration * * @return  string   the <option value=""><option>s * * @access  public */function PMA_foreignDropdown($disp, $foreign_field, $foreign_display, $data, $max) {    global $cfg;    $foreign = array();    // collect the data    foreach ($disp as $relrow) {        $key   = $relrow[$foreign_field];        // if the display field has been defined for this foreign table        if ($foreign_display) {            $value  = $relrow[$foreign_display];        } else {            $value = '';        } // end if ($foreign_display)        $foreign[$key] = $value;    } // end foreach    // beginning of dropdown    $ret = '<option value=""></option>' . "\n";    // master array for dropdowns    $reloptions = array('content-id' => array(), 'id-content' => array());    // sort for id-content    if ($cfg['NaturalOrder']) {        uksort($foreign, 'strnatcasecmp');    } else {        ksort($foreign);    }    // build id-content dropdown    $reloptions['id-content'] = PMA_foreignDropdownBuild($foreign, $data, 'id-content');    // sort for content-id    if ($cfg['NaturalOrder']) {        natcasesort($foreign);    } else {        asort($foreign);    }    // build content-id dropdown    $reloptions['content-id'] = PMA_foreignDropdownBuild($foreign, $data, 'content-id');    // put the dropdown sections in correct order    $c = count($cfg['ForeignKeyDropdownOrder']);    if ($c == 2) {        $top = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];        $bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][1]];    } elseif ($c == 1) {        $bot = $reloptions[$cfg['ForeignKeyDropdownOrder'][0]];        $top = null;    } else {        $top = $reloptions['id-content'];        $bot = $reloptions['content-id'];    }    $str_bot = implode('', $bot);    if ($top !== null) {        $str_top = implode('', $top);        $top_count = count($top);        if ($max == -1 || $top_count < $max) {            $ret .= $str_top;            if ($top_count > 0) {                $ret .= '                <option value=""></option>' . "\n";                $ret .= '                <option value=""></option>' . "\n";            }        }    }    $ret .= $str_bot;    return $ret;} // end of 'PMA_foreignDropdown()' function?>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -