本文整理汇总了PHP中PMA_generateCharsetQueryPart函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_generateCharsetQueryPart函数的具体用法?PHP PMA_generateCharsetQueryPart怎么用?PHP PMA_generateCharsetQueryPart使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_generateCharsetQueryPart函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testGenerateCharsetQueryPart
/**
* Test for PMA_generateCharsetQueryPart
*
* @param bool $drizzle Value for PMA_DRIZZLE
* @param string $collation Collation
* @param string $expected Expected Charset Query
*
* @return void
* @test
* @dataProvider charsetQueryData
*/
public function testGenerateCharsetQueryPart(
$drizzle, $collation, $expected
) {
if (! PMA_HAS_RUNKIT) {
$this->markTestSkipped(
'Cannot redefine constant - missing runkit extension'
);
} else {
$restoreDrizzle = '';
if (defined('PMA_DRIZZLE')) {
$restoreDrizzle = PMA_DRIZZLE;
runkit_constant_redefine('PMA_DRIZZLE', $drizzle);
} else {
$restoreDrizzle = 'PMA_TEST_CONSTANT_REMOVE';
define('PMA_DRIZZLE', $drizzle);
}
$this->assertEquals(
$expected,
PMA_generateCharsetQueryPart($collation)
);
if ($restoreDrizzle === 'PMA_TEST_CONSTANT_REMOVE') {
runkit_constant_remove('PMA_DRIZZLE');
} else {
runkit_constant_redefine('PMA_DRIZZLE', $restoreDrizzle);
}
}
}
示例2: PMA_DBI_fetch_value
}
if (!isset($newname) || !strlen($newname)) {
$message = PMA_Message::error('strDatabaseEmpty');
} else {
$sql_query = '';
// in case target db exists
$_error = false;
if ($move || isset($create_database_before_copying) && $create_database_before_copying) {
// lower_case_table_names=1 `DB` becomes `db`
$lower_case_table_names = PMA_DBI_fetch_value('SHOW VARIABLES LIKE "lower_case_table_names"', 0, 1);
if ($lower_case_table_names === '1') {
$newname = strtolower($newname);
}
$local_query = 'CREATE DATABASE ' . PMA_backquote($newname);
if (isset($db_collation)) {
$local_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
}
$local_query .= ';';
$sql_query = $local_query;
PMA_DBI_query($local_query);
// rebuild the database list because PMA_Table::moveCopy
// checks in this list if the target db exists
$GLOBALS['pma']->databases->build();
}
if (isset($GLOBALS['add_constraints'])) {
$GLOBALS['sql_constraints_query_full_db'] = '';
}
$tables_full = PMA_DBI_get_tables_full($db);
$views = array();
foreach ($tables_full as $each_table => $tmp) {
// to be able to rename a db containing views, we
示例3: PMA_sendHeaderLocation
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' . PMA_generateCharsetQueryPart($_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;
}
}
示例4: PMA_getTableCreationQuery
/**
* Function to get table creation sql query
*
* @param string $db database name
* @param string $table table name
*
* @return string
*/
function PMA_getTableCreationQuery($db, $table)
{
// get column addition statements
$sql_statement = PMA_getColumnCreationStatements(true);
// Builds the 'create table' statement
$sql_query = 'CREATE TABLE ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote(trim($table)) . ' (' . $sql_statement . ')';
// Adds table type, character set, comments and partition definition
if (!empty($_REQUEST['tbl_storage_engine']) && $_REQUEST['tbl_storage_engine'] != 'Default') {
$sql_query .= ' ENGINE = ' . $_REQUEST['tbl_storage_engine'];
}
if (!empty($_REQUEST['tbl_collation'])) {
$sql_query .= PMA_generateCharsetQueryPart($_REQUEST['tbl_collation']);
}
if (!empty($_REQUEST['connection']) && !empty($_REQUEST['tbl_storage_engine']) && $_REQUEST['tbl_storage_engine'] == 'FEDERATED') {
$sql_query .= " CONNECTION = '" . PMA\libraries\Util::sqlAddSlashes($_REQUEST['connection']) . "'";
}
if (!empty($_REQUEST['comment'])) {
$sql_query .= ' COMMENT = \'' . PMA\libraries\Util::sqlAddSlashes($_REQUEST['comment']) . '\'';
}
$sql_query .= PMA_getPartitionsDefinition();
$sql_query .= ';';
return $sql_query;
}
示例5: PMA_generateAlterTable
function PMA_generateAlterTable($oldcol, $newcol, $full_field_type, $collation, $null, $default, $default_current_timestamp, $extra, $comment = '')
{
// $default_current_timestamp has priority over $default
// TODO: on the interface, some js to clear the default value
// when the default current_timestamp is checked
$query = PMA_backquote($oldcol) . ' ' . PMA_backquote($newcol) . ' ' . $full_field_type;
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($collation) && $collation != 'NULL' && preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR\\(\\d+\\)|CHAR\\(\\d+\\))$@i', $full_field_type)) {
$query .= PMA_generateCharsetQueryPart($collation);
}
if (!empty($null)) {
$query .= ' NOT NULL';
} else {
$query .= ' NULL';
}
if ($default_current_timestamp && strpos(' ' . strtoupper($full_field_type), 'TIMESTAMP') == 1) {
$query .= ' DEFAULT CURRENT_TIMESTAMP';
// 0 is empty in PHP
} elseif (!empty($default) || $default == '0') {
if (strtoupper($default) == 'NULL') {
$query .= ' DEFAULT NULL';
} else {
$query .= ' DEFAULT \'' . PMA_sqlAddslashes($default) . '\'';
}
}
if (!empty($extra)) {
$query .= ' ' . $extra;
}
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($comment)) {
$query .= " COMMENT '" . PMA_sqlAddslashes($comment) . "'";
}
return $query;
}
示例6: PMA_backquote
* Updates table comment, type and options if required
*/
if (isset($submitcomment)) {
if (empty($prev_comment) || urldecode($prev_comment) != $comment) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
$result = PMA_DBI_query($sql_query);
$message = $strSuccess;
}
}
if (isset($submittype)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' TYPE = ' . $tbl_type;
$result = PMA_DBI_query($sql_query);
$message = $strSuccess;
}
if (isset($submitcollation)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' DEFAULT' . PMA_generateCharsetQueryPart($tbl_collation);
$result = PMA_DBI_query($sql_query);
$message = $strSuccess;
unset($tbl_collation);
}
if (isset($submitoptions)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . (isset($pack_keys) ? ' pack_keys=1' : ' pack_keys=0') . (isset($checksum) ? ' checksum=1' : ' checksum=0') . (isset($delay_key_write) ? ' delay_key_write=1' : ' delay_key_write=0') . (!empty($auto_increment) ? ' auto_increment=' . PMA_sqlAddslashes($auto_increment) : '');
$result = PMA_DBI_query($sql_query);
$message = $strSuccess;
}
/**
* Reordering the table has been requested by the user
*/
if (isset($submitorderby) && !empty($order_field)) {
$sql_query = 'ALTER TABLE ' . PMA_backquote($table) . ' ORDER BY ' . PMA_backquote(urldecode($order_field));
if (isset($order_order) && $order_order == 'desc') {
示例7: PMA_DBI_select_db
// Not a valid db name -> back to the welcome page
if (strlen($db)) {
$is_db = PMA_DBI_select_db($db);
}
if (! strlen($db) || !$is_db) {
PMA_sendHeaderLocation($cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1');
exit;
}
} // end if (ensures db exists)
/**
* Changes database charset if requested by the user
*/
if (isset($submitcollation) && !empty($db_collation)) {
list($db_charset) = explode('_', $db_collation);
$sql_query = 'ALTER DATABASE ' . PMA_backquote($db) . ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
$result = PMA_DBI_query($sql_query);
$message = PMA_Message::success();
unset($db_charset, $db_collation);
}
$GLOBALS['js_include'][] = 'functions.js';
require_once './libraries/header.inc.php';
/**
* Set parameters for links
*/
$url_query = PMA_generate_common_url($db);
?>
示例8: FULLTEXT
if (strlen($fulltext)) {
$sql_query .= ', FULLTEXT (' . $fulltext . ')';
$query_cpy .= ',' . "\n" . ' FULLTEXT (' . $fulltext . ')';
}
unset($fulltext);
// Builds the 'create table' statement
$sql_query = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $sql_query . ')';
$query_cpy = 'CREATE TABLE ' . PMA_backquote($table) . ' (' . $query_cpy . "\n" . ')';
// Adds table type, character set and comments
if (!empty($tbl_type) && $tbl_type != 'Default') {
$sql_query .= ' ' . PMA_ENGINE_KEYWORD . ' = ' . $tbl_type;
$query_cpy .= "\n" . PMA_ENGINE_KEYWORD . ' = ' . $tbl_type;
}
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
$sql_query .= PMA_generateCharsetQueryPart($tbl_collation);
$query_cpy .= "\n" . PMA_generateCharsetQueryPart($tbl_collation);
}
if (!empty($comment)) {
$sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
$query_cpy .= "\n" . 'COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
}
// 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';
示例9: generateFieldSpec
/**
* generates column specification for ALTER or CREATE TABLE syntax
*
* @param string $name name
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
* @param string $index index
* @param string $length length ('2', '5,2', '', ...)
* @param string $attribute attribute
* @param string $collation collation
* @param bool|string $null with 'NULL' or 'NOT NULL'
* @param string $default_type whether default is CURRENT_TIMESTAMP,
* NULL, NONE, USER_DEFINED
* @param string $default_value default value for USER_DEFINED
* default type
* @param string $extra 'AUTO_INCREMENT'
* @param string $comment field comment
* @param array &$field_primary list of fields for PRIMARY KEY
* @param string $move_to new position for column
*
* @todo move into class PMA_Column
* @todo on the interface, some js to clear the default value when the
* default current_timestamp is checked
*
* @return string field specification
*/
static function generateFieldSpec($name, $type, $index, $length = '', $attribute = '', $collation = '', $null = false, $default_type = 'USER_DEFINED', $default_value = '', $extra = '', $comment = '', &$field_primary = null, $move_to = '')
{
$is_timestamp = strpos(strtoupper($type), 'TIMESTAMP') !== false;
$query = PMA_Util::backquote($name) . ' ' . $type;
// allow the possibility of a length for TIME, DATETIME and TIMESTAMP
// (will work on MySQL >= 5.6.4)
//
// MySQL permits a non-standard syntax for FLOAT and DOUBLE,
// see http://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html
//
if ($length != '' && !preg_match('@^(DATE|TINYBLOB|TINYTEXT|BLOB|TEXT|' . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN|UUID)$@i', $type)) {
$query .= '(' . $length . ')';
}
if ($attribute != '') {
$query .= ' ' . $attribute;
}
$matches = preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type);
if (!empty($collation) && $collation != 'NULL' && $matches) {
$query .= PMA_generateCharsetQueryPart($collation);
}
if ($null !== false) {
if ($null == 'NULL') {
$query .= ' NULL';
} else {
$query .= ' NOT NULL';
}
}
switch ($default_type) {
case 'USER_DEFINED':
if ($is_timestamp && $default_value === '0') {
// a TIMESTAMP does not accept DEFAULT '0'
// but DEFAULT 0 works
$query .= ' DEFAULT 0';
} elseif ($type == 'BIT') {
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
} elseif ($type == 'BOOLEAN') {
if (preg_match('/^1|T|TRUE|YES$/i', $default_value)) {
$query .= ' DEFAULT TRUE';
} elseif (preg_match('/^0|F|FALSE|NO$/i', $default_value)) {
$query .= ' DEFAULT FALSE';
} else {
// Invalid BOOLEAN value
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes($default_value) . '\'';
}
} else {
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes($default_value) . '\'';
}
break;
case 'NULL':
// If user uncheck null checkbox and not change default value null,
// default value will be ignored.
if ($null !== false && $null != 'NULL') {
break;
}
// otherwise, fall to next case (no break; here)
// otherwise, fall to next case (no break; here)
case 'CURRENT_TIMESTAMP':
$query .= ' DEFAULT ' . $default_type;
break;
case 'NONE':
default:
break;
}
if (!empty($extra)) {
$query .= ' ' . $extra;
// Force an auto_increment field to be part of the primary key
// even if user did not tick the PK box;
if ($extra == 'AUTO_INCREMENT') {
$primary_cnt = count($field_primary);
if (1 == $primary_cnt) {
for ($j = 0; $j < $primary_cnt; $j++) {
if ($field_primary[$j] == $index) {
break;
}
}
//.........这里部分代码省略.........
示例10: preg_replace
}
}
// end for
$fulltext = preg_replace('@, $@', '', $fulltext);
if (strlen($fulltext)) {
$sql_query .= ', FULLTEXT (' . $fulltext . ')';
}
unset($fulltext);
// Builds the 'create table' statement
$sql_query = 'CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' (' . $sql_query . ')';
// Adds table type, character set and comments
if (!empty($tbl_type) && $tbl_type != 'Default') {
$sql_query .= ' ' . PMA_ENGINE_KEYWORD . ' = ' . $tbl_type;
}
if (PMA_MYSQL_INT_VERSION >= 40100 && !empty($tbl_collation)) {
$sql_query .= PMA_generateCharsetQueryPart($tbl_collation);
}
if (!empty($comment)) {
$sql_query .= ' COMMENT = \'' . PMA_sqlAddslashes($comment) . '\'';
}
// Executes the query
$result = PMA_DBI_try_query($sql_query);
if ($result) {
// 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'] && PMA_MYSQL_INT_VERSION < 40100) {
foreach ($field_comments as $fieldindex => $fieldcomment) {
if (isset($field_name[$fieldindex]) && strlen($field_name[$fieldindex])) {
示例11: createDatabaseAction
/**
* Handles creating a new database
*
* @return void
*/
public function createDatabaseAction()
{
/**
* Builds and executes the db creation sql query
*/
$sql_query = 'CREATE DATABASE ' . Util::backquote($_POST['new_db']);
if (!empty($_POST['db_collation'])) {
list($db_charset) = explode('_', $_POST['db_collation']);
if (in_array($db_charset, $GLOBALS['mysql_charsets']) && in_array($_POST['db_collation'], $GLOBALS['mysql_collations'][$db_charset])) {
$sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($_POST['db_collation']);
}
}
$sql_query .= ';';
$result = $GLOBALS['dbi']->tryQuery($sql_query);
if (!$result) {
// avoid displaying the not-created db name in header or navi panel
$GLOBALS['db'] = '';
$message = Message::rawError($GLOBALS['dbi']->getError());
$this->response->setRequestStatus(false);
$this->response->addJSON('message', $message);
} else {
$GLOBALS['db'] = $_POST['new_db'];
$message = Message::success(__('Database %1$s has been created.'));
$message->addParam($_POST['new_db']);
$this->response->addJSON('message', $message);
$this->response->addJSON('sql_query', Util::getMessage(null, $sql_query, 'success'));
$url_query = PMA_URL_getCommon(array('db' => $_POST['new_db']));
$this->response->addJSON('url_query', Util::getScriptNameForOption($GLOBALS['cfg']['DefaultTabDatabase'], 'database') . $url_query . '&db=' . urlencode($_POST['new_db']));
}
}
示例12: testGenerateCharsetQueryPart
/**
* Test for PMA_generateCharsetQueryPart
*
* @param string $collation Collation
* @param string $expected Expected Charset Query
*
* @return void
* @test
* @dataProvider charsetQueryData
*/
public function testGenerateCharsetQueryPart($collation, $expected)
{
$this->assertEquals($expected, PMA_generateCharsetQueryPart($collation));
}
示例13: PMA_generate_common_url
}
}
// Not a valid db name -> back to the welcome page
$uri = $cfg['PmaAbsoluteUri'] . 'main.php?' . PMA_generate_common_url('', '', '&') . (isset($message) ? '&message=' . urlencode($message) : '') . '&reload=1';
if (!strlen($db) || !$is_db) {
PMA_sendHeaderLocation($uri);
exit;
}
}
// end if (ensures db exists)
/**
* Changes database charset if requested by the user
*/
if (isset($submitcollation) && !empty($db_collation)) {
list($db_charset) = explode('_', $db_collation);
$sql_query = 'ALTER DATABASE ' . PMA_CommonFunctions::getInstance()->backquote($db) . ' DEFAULT' . PMA_generateCharsetQueryPart($db_collation);
$result = PMA_DBI_query($sql_query);
$message = PMA_Message::success();
unset($db_charset, $db_collation);
/**
* 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_Response::getInstance();
$response->isSuccess($message->isSuccess());
$response->addJSON('message', $message);
exit;
}
}
示例14: PMA_URL_getCommon
require_once 'libraries/common.inc.php';
require_once 'libraries/mysql_charsets.inc.php';
require_once 'libraries/replication.inc.php';
require 'libraries/build_html_for_db.lib.php';
/**
* Defines the url to return to in case of error in a sql statement
*/
$err_url = 'index.php' . PMA_URL_getCommon();
/**
* Builds and executes the db creation sql query
*/
$sql_query = 'CREATE DATABASE ' . PMA\libraries\Util::backquote($_POST['new_db']);
if (!empty($_POST['db_collation'])) {
list($db_charset) = explode('_', $_POST['db_collation']);
if (in_array($db_charset, $mysql_charsets) && in_array($_POST['db_collation'], $mysql_collations[$db_charset])) {
$sql_query .= ' DEFAULT' . PMA_generateCharsetQueryPart($_POST['db_collation']);
}
$db_collation_for_ajax = $_POST['db_collation'];
unset($db_charset);
}
$sql_query .= ';';
$result = $GLOBALS['dbi']->tryQuery($sql_query);
if (!$result) {
$message = PMA\libraries\Message::rawError($GLOBALS['dbi']->getError());
// avoid displaying the not-created db name in header or navi panel
$GLOBALS['db'] = '';
$GLOBALS['table'] = '';
/**
* If in an Ajax request, just display the message with {@link PMA\libraries\Response}
*/
if ($GLOBALS['is_ajax_request'] == true) {
示例15: generateFieldSpec
/**
* generates column specification for ALTER or CREATE TABLE syntax
*
* @param string $name name
* @param string $type type ('INT', 'VARCHAR', 'BIT', ...)
* @param string $length length ('2', '5,2', '', ...)
* @param string $attribute attribute
* @param string $collation collation
* @param bool|string $null with 'NULL' or 'NOT NULL'
* @param string $default_type whether default is CURRENT_TIMESTAMP,
* NULL, NONE, USER_DEFINED
* @param string $default_value default value for USER_DEFINED
* default type
* @param string $extra 'AUTO_INCREMENT'
* @param string $comment field comment
* @param string $virtuality virtuality of the column
* @param string $expression expression for the virtual column
* @param string $move_to new position for column
*
* @todo move into class PMA_Column
* @todo on the interface, some js to clear the default value when the
* default current_timestamp is checked
*
* @return string field specification
*/
static function generateFieldSpec($name, $type, $length = '', $attribute = '', $collation = '', $null = false, $default_type = 'USER_DEFINED', $default_value = '', $extra = '', $comment = '', $virtuality = '', $expression = '', $move_to = '')
{
$is_timestamp = mb_strpos(mb_strtoupper($type), 'TIMESTAMP') !== false;
$query = PMA_Util::backquote($name) . ' ' . $type;
// allow the possibility of a length for TIME, DATETIME and TIMESTAMP
// (will work on MySQL >= 5.6.4)
//
// MySQL permits a non-standard syntax for FLOAT and DOUBLE,
// see http://dev.mysql.com/doc/refman/5.5/en/floating-point-types.html
//
$pattern = '@^(DATE|TINYBLOB|TINYTEXT|BLOB|TEXT|' . 'MEDIUMBLOB|MEDIUMTEXT|LONGBLOB|LONGTEXT|SERIAL|BOOLEAN|UUID)$@i';
if ($length != '' && !preg_match($pattern, $type)) {
$query .= '(' . $length . ')';
}
if ($virtuality) {
$query .= ' AS (' . $expression . ') ' . $virtuality;
} else {
if ($attribute != '') {
$query .= ' ' . $attribute;
}
$matches = preg_match('@^(TINYTEXT|TEXT|MEDIUMTEXT|LONGTEXT|VARCHAR|CHAR|ENUM|SET)$@i', $type);
if (!empty($collation) && $collation != 'NULL' && $matches) {
$query .= PMA_generateCharsetQueryPart($collation);
}
if ($null !== false) {
if ($null == 'NULL') {
$query .= ' NULL';
} else {
$query .= ' NOT NULL';
}
}
switch ($default_type) {
case 'USER_DEFINED':
if ($is_timestamp && $default_value === '0') {
// a TIMESTAMP does not accept DEFAULT '0'
// but DEFAULT 0 works
$query .= ' DEFAULT 0';
} elseif ($type == 'BIT') {
$query .= ' DEFAULT b\'' . preg_replace('/[^01]/', '0', $default_value) . '\'';
} elseif ($type == 'BOOLEAN') {
if (preg_match('/^1|T|TRUE|YES$/i', $default_value)) {
$query .= ' DEFAULT TRUE';
} elseif (preg_match('/^0|F|FALSE|NO$/i', $default_value)) {
$query .= ' DEFAULT FALSE';
} else {
// Invalid BOOLEAN value
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes($default_value) . '\'';
}
} elseif ($type == 'BINARY' || $type == 'VARBINARY') {
$query .= ' DEFAULT 0x' . $default_value;
} else {
$query .= ' DEFAULT \'' . PMA_Util::sqlAddSlashes($default_value) . '\'';
}
break;
/** @noinspection PhpMissingBreakStatementInspection */
/** @noinspection PhpMissingBreakStatementInspection */
case 'NULL':
// If user uncheck null checkbox and not change default value null,
// default value will be ignored.
if ($null !== false && $null !== 'NULL') {
break;
}
// else fall-through intended, no break here
// else fall-through intended, no break here
case 'CURRENT_TIMESTAMP':
$query .= ' DEFAULT ' . $default_type;
break;
case 'NONE':
default:
break;
}
if (!empty($extra)) {
$query .= ' ' . $extra;
}
}
//.........这里部分代码省略.........