PMA\libraries\StorageEngine::getHtmlSelect PHP Méthode

getHtmlSelect() public static méthode

Returns HTML code for storage engine select box
public static getHtmlSelect ( string $name = 'engine', string $id = null, string $selected = null, boolean $offerUnavailableEngines = false, boolean $addEmpty = false ) : string
$name string The name of the select form element
$id string The ID of the form field
$selected string The selected engine
$offerUnavailableEngines boolean Should unavailable storage engines be offered?
$addEmpty boolean Whether to provide empty option
Résultat string html selectbox
    public static function getHtmlSelect($name = 'engine', $id = null, $selected = null, $offerUnavailableEngines = false, $addEmpty = false)
    {
        $selected = mb_strtolower($selected);
        $output = '<select name="' . $name . '"' . (empty($id) ? '' : ' id="' . $id . '"') . '>' . "\n";
        if ($addEmpty) {
            $output .= '<option value=""></option>';
        }
        foreach (StorageEngine::getStorageEngines() as $key => $details) {
            // Don't show PERFORMANCE_SCHEMA engine (MySQL 5.5)
            if (!$offerUnavailableEngines && ($details['Support'] == 'NO' || $details['Support'] == 'DISABLED' || $details['Engine'] == 'PERFORMANCE_SCHEMA')) {
                continue;
            }
            $output .= '    <option value="' . htmlspecialchars($key) . '"' . (empty($details['Comment']) ? '' : ' title="' . htmlspecialchars($details['Comment']) . '"') . (mb_strtolower($key) == $selected || empty($selected) && $details['Support'] == 'DEFAULT' && !$addEmpty ? ' selected="selected"' : '') . '>' . "\n" . '        ' . htmlspecialchars($details['Engine']) . "\n" . '    </option>' . "\n";
        }
        $output .= '</select>' . "\n";
        return $output;
    }

Usage Example

/**
 * Get HTML fieldset for Table option, it contains HTML table for options
 *
 * @param string  $comment            Comment
 * @param array   $tbl_collation      table collation
 * @param string  $tbl_storage_engine table storage engine
 * @param boolean $is_myisam_or_aria  whether MYISAM | ARIA or not
 * @param boolean $is_isam            whether ISAM or not
 * @param string  $pack_keys          pack keys
 * @param string  $delay_key_write    delay key write
 * @param string  $auto_increment     value of auto increment
 * @param string  $transactional      value of transactional
 * @param string  $page_checksum      value of page checksum
 * @param boolean $is_innodb          whether INNODB or not
 * @param boolean $is_pbxt            whether PBXT or not
 * @param boolean $is_aria            whether ARIA or not
 * @param string  $checksum           the checksum
 *
 * @return string $html_output
 */
function PMA_getTableOptionFieldset($comment, $tbl_collation, $tbl_storage_engine, $is_myisam_or_aria, $is_isam, $pack_keys, $delay_key_write, $auto_increment, $transactional, $page_checksum, $is_innodb, $is_pbxt, $is_aria, $checksum)
{
    $html_output = '<fieldset>' . '<legend>' . __('Table options') . '</legend>';
    $html_output .= '<table>';
    $html_output .= PMA_getHtmlForRenameTable();
    $html_output .= PMA_getHtmlForTableComments($comment);
    //Storage engine
    $html_output .= '<tr><td class="vmiddle">' . __('Storage Engine') . '&nbsp;' . PMA\libraries\Util::showMySQLDocu('Storage_engines') . '</td>' . '<td>' . StorageEngine::getHtmlSelect('new_tbl_storage_engine', null, $tbl_storage_engine) . '</td>' . '</tr>';
    //Table character set
    $html_output .= '<tr><td class="vmiddle">' . __('Collation') . '</td>' . '<td>' . PMA_generateCharsetDropdownBox(PMA_CSDROPDOWN_COLLATION, 'tbl_collation', null, $tbl_collation, false) . '</td>' . '</tr>';
    // Change all Column collations
    $html_output .= '<tr><td></td><td>' . '<input type="checkbox" name="change_all_collations" value="1" ' . 'id="checkbox_change_all_collations" />' . '<label for="checkbox_change_all_collations">' . __('Change all column collations') . '</label>' . '</td></tr>';
    if ($is_myisam_or_aria || $is_isam) {
        $html_output .= PMA_getHtmlForPackKeys($pack_keys);
    }
    // end if (MYISAM|ISAM)
    if ($is_myisam_or_aria) {
        $html_output .= PMA_getHtmlForTableRow('new_checksum', 'CHECKSUM', $checksum);
        $html_output .= PMA_getHtmlForTableRow('new_delay_key_write', 'DELAY_KEY_WRITE', $delay_key_write);
    }
    // end if (MYISAM)
    if ($is_aria) {
        $html_output .= PMA_getHtmlForTableRow('new_transactional', 'TRANSACTIONAL', $transactional);
        $html_output .= PMA_getHtmlForTableRow('new_page_checksum', 'PAGE_CHECKSUM', $page_checksum);
    }
    // end if (ARIA)
    if (mb_strlen($auto_increment) > 0 && ($is_myisam_or_aria || $is_innodb || $is_pbxt)) {
        $html_output .= '<tr><td class="vmiddle">' . '<label for="auto_increment_opt">AUTO_INCREMENT</label></td>' . '<td><input type="number" name="new_auto_increment" ' . 'id="auto_increment_opt"' . 'value="' . $auto_increment . '" /></td>' . '</tr> ';
    }
    // end if (MYISAM|INNODB)
    $possible_row_formats = PMA_getPossibleRowFormat();
    // for MYISAM there is also COMPRESSED but it can be set only by the
    // myisampack utility, so don't offer here the choice because if we
    // try it inside an ALTER TABLE, MySQL (at least in 5.1.23-maria)
    // does not return a warning
    // (if the table was compressed, it can be seen on the Structure page)
    if (isset($possible_row_formats[$tbl_storage_engine])) {
        $current_row_format = mb_strtoupper($GLOBALS['showtable']['Row_format']);
        $html_output .= '<tr><td class="vmiddle">' . '<label for="new_row_format">ROW_FORMAT</label></td>' . '<td>';
        $html_output .= PMA\libraries\Util::getDropdown('new_row_format', $possible_row_formats[$tbl_storage_engine], $current_row_format, 'new_row_format');
        $html_output .= '</td></tr>';
    }
    $html_output .= '</table>' . '</fieldset>';
    return $html_output;
}