本文整理汇总了PHP中PMA_Table::getColumnGenerationExpression方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Table::getColumnGenerationExpression方法的具体用法?PHP PMA_Table::getColumnGenerationExpression怎么用?PHP PMA_Table::getColumnGenerationExpression使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Table
的用法示例。
在下文中一共展示了PMA_Table::getColumnGenerationExpression方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_moveColumns
/**
* Moves columns in the table's structure based on $_REQUEST
*
* @param string $db database name
* @param string $table table name
*
* @return void
*/
function PMA_moveColumns($db, $table)
{
$GLOBALS['dbi']->selectDb($db);
/*
* load the definitions for all columns
*/
$columns = $GLOBALS['dbi']->getColumnsFull($db, $table);
$column_names = array_keys($columns);
$changes = array();
// move columns from first to last
for ($i = 0, $l = count($_REQUEST['move_columns']); $i < $l; $i++) {
$column = $_REQUEST['move_columns'][$i];
// is this column already correctly placed?
if ($column_names[$i] == $column) {
continue;
}
// it is not, let's move it to index $i
$data = $columns[$column];
$extracted_columnspec = PMA_Util::extractColumnSpec($data['Type']);
if (isset($data['Extra']) && $data['Extra'] == 'on update CURRENT_TIMESTAMP') {
$extracted_columnspec['attribute'] = $data['Extra'];
unset($data['Extra']);
}
$current_timestamp = false;
if (($data['Type'] == 'timestamp' || $data['Type'] == 'datetime') && $data['Default'] == 'CURRENT_TIMESTAMP') {
$current_timestamp = true;
}
$default_type = $data['Null'] === 'YES' && $data['Default'] === null ? 'NULL' : ($current_timestamp ? 'CURRENT_TIMESTAMP' : ($data['Default'] === null ? 'NONE' : 'USER_DEFINED'));
$virtual = array('VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED');
$data['Virtuality'] = '';
$data['Expression'] = '';
if (isset($data['Extra']) && in_array($data['Extra'], $virtual)) {
$data['Virtuality'] = str_replace(' GENERATED', '', $data['Extra']);
$table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
$expressions = $table->getColumnGenerationExpression($column);
$data['Expression'] = $expressions[$column];
}
$changes[] = 'CHANGE ' . PMA_Table::generateAlter($column, $column, mb_strtoupper($extracted_columnspec['type']), $extracted_columnspec['spec_in_brackets'], $extracted_columnspec['attribute'], isset($data['Collation']) ? $data['Collation'] : '', $data['Null'] === 'YES' ? 'NULL' : 'NOT NULL', $default_type, $current_timestamp ? '' : $data['Default'], isset($data['Extra']) && $data['Extra'] !== '' ? $data['Extra'] : false, isset($data['COLUMN_COMMENT']) && $data['COLUMN_COMMENT'] !== '' ? $data['COLUMN_COMMENT'] : false, $data['Virtuality'], $data['Expression'], $i === 0 ? '-first' : $column_names[$i - 1]);
// update current column_names array, first delete old position
for ($j = 0, $ll = count($column_names); $j < $ll; $j++) {
if ($column_names[$j] == $column) {
unset($column_names[$j]);
}
}
// insert moved column
array_splice($column_names, $i, 0, $column);
}
$response = PMA_Response::getInstance();
if (empty($changes)) {
// should never happen
$response->isSuccess(false);
exit;
}
$move_query = 'ALTER TABLE ' . PMA_Util::backquote($table) . ' ';
$move_query .= implode(', ', $changes);
// move columns
$GLOBALS['dbi']->tryQuery($move_query);
$tmp_error = $GLOBALS['dbi']->getError();
if ($tmp_error) {
$response->isSuccess(false);
$response->addJSON('message', PMA_Message::error($tmp_error));
} else {
$message = PMA_Message::success(__('The columns have been moved successfully.'));
$response->addJSON('message', $message);
$response->addJSON('columns', $column_names);
}
exit;
}
示例2: array
break;
case 'NULL':
case 'CURRENT_TIMESTAMP':
$columnMeta['Default'] = $columnMeta['DefaultType'];
break;
}
$length = Util\get($_REQUEST, "field_length.{$columnNumber}", $length);
$submit_attribute = Util\get($_REQUEST, "field_attribute.{$columnNumber}", false);
$comments_map[$columnMeta['Field']] = Util\get($_REQUEST, "field_comments.{$columnNumber}");
$mime_map[$columnMeta['Field']] = array_merge($mime_map[$columnMeta['Field']], array('mimetype' => Util\get($_REQUEST, "field_mimetype.{${$columnNumber}}"), 'transformation' => Util\get($_REQUEST, "field_transformation.{${$columnNumber}}"), 'transformation_options' => Util\get($_REQUEST, "field_transformation_options.{${$columnNumber}}")));
} elseif (isset($fields_meta[$columnNumber])) {
$columnMeta = $fields_meta[$columnNumber];
$virtual = array('VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED');
if (in_array($columnMeta['Extra'], $virtual)) {
$table = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
$expressions = $table->getColumnGenerationExpression($columnMeta['Field']);
$columnMeta['Expression'] = $expressions[$columnMeta['Field']];
}
switch ($columnMeta['Default']) {
case null:
if (is_null($columnMeta['Default'])) {
// null
if ($columnMeta['Null'] == 'YES') {
$columnMeta['DefaultType'] = 'NULL';
$columnMeta['DefaultValue'] = '';
} else {
$columnMeta['DefaultType'] = 'NONE';
$columnMeta['DefaultValue'] = '';
}
} else {
// empty