PMA\libraries\Util::getCharsetQueryPart PHP Method

getCharsetQueryPart() static public method

Generate the charset query part
static public getCharsetQueryPart ( string $collation, $override = false ) : string
$collation string Collation
return string
    static function getCharsetQueryPart($collation, $override = false)
    {
        list($charset) = explode('_', $collation);
        $keyword = ' CHARSET=';
        if ($override) {
            $keyword = ' CHARACTER SET ';
        }
        return $keyword . $charset . ($charset == $collation ? '' : ' COLLATE ' . $collation);
    }

Usage Example

        if ($response->isAjax()) {
            $response->setRequestStatus(false);
            $response->addJSON('message', Message::error(__('No databases selected.')));
        } else {
            PMA_sendHeaderLocation($uri);
        }
        exit;
    }
}
// end if (ensures db exists)
/**
 * Changes database charset if requested by the user
 */
if (isset($_REQUEST['submitcollation']) && isset($_REQUEST['db_collation']) && !empty($_REQUEST['db_collation'])) {
    list($db_charset) = explode('_', $_REQUEST['db_collation']);
    $sql_query = 'ALTER DATABASE ' . PMA\libraries\Util::backquote($db) . ' DEFAULT' . Util::getCharsetQueryPart($_REQUEST['db_collation']);
    $result = $GLOBALS['dbi']->query($sql_query);
    $message = Message::success();
    unset($db_charset);
    /**
     * If we are in an Ajax request, let us stop the execution here. Necessary for
     * db charset change action on db_operations.php.  If this causes a bug on
     * other pages, we might have to move this to a different location.
     */
    if ($GLOBALS['is_ajax_request'] == true) {
        $response = PMA\libraries\Response::getInstance();
        $response->setRequestStatus($message->isSuccess());
        $response->addJSON('message', $message);
        exit;
    }
}
All Usage Examples Of PMA\libraries\Util::getCharsetQueryPart
Util