本文整理汇总了PHP中PMA_Message::success方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Message::success方法的具体用法?PHP PMA_Message::success怎么用?PHP PMA_Message::success使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Message
的用法示例。
在下文中一共展示了PMA_Message::success方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_handleCreateOrEditIndex
/**
* Function to handle the creation or edit of an index
*
* @param string $db current db
* @param string $table current table
* @param PMA_Index $index current index
*
* @return void
*/
function PMA_handleCreateOrEditIndex($db, $table, $index)
{
$error = false;
$sql_query = PMA_getSqlQueryForIndexCreateOrEdit($db, $table, $index, $error);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($sql_query);
}
if (!$error) {
$GLOBALS['dbi']->query($sql_query);
$message = PMA_Message::success(__('Table %1$s has been altered successfully.'));
$message->addParam($table);
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $message);
$response->addJSON('index_table', PMA_Index::getView($table, $db));
$response->addJSON('sql_query', PMA_Util::getMessage(null, $sql_query));
} else {
include 'tbl_structure.php';
}
exit;
} else {
$response = PMA_Response::getInstance();
$response->isSuccess(false);
$response->addJSON('message', $error);
exit;
}
}
示例2: testSuccess
/**
* test success method
*/
public function testSuccess()
{
$this->object = new PMA_Message('test<&>', PMA_Message::SUCCESS);
$this->assertEquals($this->object, PMA_Message::success('test<&>'));
$this->assertEquals(
'Your SQL query has been executed successfully',
PMA_Message::success()->getString()
);
}
示例3: PMA_getHtmlForErrorMessage
/**
* returns HTML for error message
*
* @return String HTML code
*/
function PMA_getHtmlForErrorMessage()
{
$html = '';
if (isset($_SESSION['replication']['sr_action_status']) && isset($_SESSION['replication']['sr_action_info'])) {
if ($_SESSION['replication']['sr_action_status'] == 'error') {
$error_message = $_SESSION['replication']['sr_action_info'];
$html .= PMA_Message::error($error_message)->getDisplay();
$_SESSION['replication']['sr_action_status'] = 'unknown';
} elseif ($_SESSION['replication']['sr_action_status'] == 'success') {
$success_message = $_SESSION['replication']['sr_action_info'];
$html .= PMA_Message::success($success_message)->getDisplay();
$_SESSION['replication']['sr_action_status'] = 'unknown';
}
}
return $html;
}
示例4: PMA_addUserAndCreateDatabase
/**
* Prepares queries for adding users and
* also create database and return query and message
*
* @param boolean $_error whether user create or not
* @param string $real_sql_query SQL query for add a user
* @param string $sql_query SQL query to be displayed
* @param string $username username
* @param string $hostname host name
* @param string $dbname database name
*
* @return array $sql_query, $message
*/
function PMA_addUserAndCreateDatabase($_error, $real_sql_query, $sql_query, $username, $hostname, $dbname)
{
if ($_error || !empty($real_sql_query) && !$GLOBALS['dbi']->tryQuery($real_sql_query)) {
$_REQUEST['createdb-1'] = $_REQUEST['createdb-2'] = $_REQUEST['createdb-3'] = null;
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
} else {
$message = PMA_Message::success(__('You have added a new user.'));
}
if (isset($_REQUEST['createdb-1'])) {
// Create database with same name and grant all privileges
$q = 'CREATE DATABASE IF NOT EXISTS ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($username)) . ';';
$sql_query .= $q;
if (!$GLOBALS['dbi']->tryQuery($q)) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
}
/**
* Reload the navigation
*/
$GLOBALS['reload'] = true;
$GLOBALS['db'] = $username;
$q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::escapeMysqlWildcards(PMA_Util::sqlAddSlashes($username))) . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (!$GLOBALS['dbi']->tryQuery($q)) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
}
}
if (isset($_REQUEST['createdb-2'])) {
// Grant all privileges on wildcard name (username\_%)
$q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($username) . '\\_%') . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (!$GLOBALS['dbi']->tryQuery($q)) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
}
}
if (isset($_REQUEST['createdb-3'])) {
// Grant all privileges on the specified database to the new user
$q = 'GRANT ALL PRIVILEGES ON ' . PMA_Util::backquote(PMA_Util::sqlAddSlashes($dbname)) . '.* TO \'' . PMA_Util::sqlAddSlashes($username) . '\'@\'' . PMA_Util::sqlAddSlashes($hostname) . '\';';
$sql_query .= $q;
if (!$GLOBALS['dbi']->tryQuery($q)) {
$message = PMA_Message::rawError($GLOBALS['dbi']->getError());
}
}
return array($sql_query, $message);
}
示例5: __
}
$odd_row = ! $odd_row;
}
} else {
$user_form .= ' <tr class="odd">' . "\n"
. ' <td colspan="6">' . "\n"
. ' ' . __('No user found.') . "\n"
. ' </td>' . "\n"
. ' </tr>' . "\n";
}
$user_form .= '</tbody>' . "\n"
. '</table></fieldset></form>' . "\n";
if ($GLOBALS['is_ajax_request'] == true) {
$extra_data['user_form'] = $user_form;
$message = PMA_Message::success(__('User has been added.'));
PMA_ajaxResponse($message, $message->isSuccess(), $extra_data);
} else {
// Offer to create a new user for the current database
$user_form .= '<fieldset id="fieldset_add_user">' . "\n"
. '<legend>' . __('New') . '</legend>' . "\n"
. ' <a href="server_privileges.php?' . $GLOBALS['url_query'] . '&adduser=1&dbname=' . htmlspecialchars($checkprivs) .'" rel="'.'checkprivs='.htmlspecialchars($checkprivs). '&'.$GLOBALS['url_query'] . '" class="'.$conditional_class.'" name="db_specific">' . "\n"
. PMA_getIcon('b_usradd.png')
. ' ' . __('Add user') . '</a>' . "\n"
. '</fieldset>' . "\n";
echo $user_form ;
}
} // end if (empty($_REQUEST['adduser']) && empty($checkprivs)) ... elseif ... else ...
示例6: PMA_getDataForDeleteUsers
/**
* Deletes users
* (Changes / copies a user, part IV)
*/
if (isset($_REQUEST['delete']) || isset($_REQUEST['change_copy']) && $_REQUEST['mode'] < 4) {
$queries = PMA_getDataForDeleteUsers($queries);
if (empty($_REQUEST['change_copy'])) {
list($sql_query, $message) = PMA_deleteUser($queries);
}
}
/**
* Changes / copies a user, part V
*/
if (isset($_REQUEST['change_copy'])) {
$queries = PMA_getDataForQueries($queries, $queries_for_display);
$message = PMA_Message::success();
$sql_query = join("\n", $queries);
}
/**
* Reloads the privilege tables into memory
*/
$message_ret = PMA_updateMessageForReload();
if (isset($message_ret)) {
$message = $message_ret;
unset($message_ret);
}
/**
* If we are in an Ajax request for Create User/Edit User/Revoke User/
* Flush Privileges, show $message and exit.
*/
if ($GLOBALS['is_ajax_request'] && empty($_REQUEST['ajax_page_request']) && !isset($_REQUEST['export']) && (!isset($_REQUEST['submit_mult']) || $_REQUEST['submit_mult'] != 'export') && (!isset($_REQUEST['initial']) || $_REQUEST['initial'] === null || $_REQUEST['initial'] === '' || isset($_REQUEST['delete']) && $_REQUEST['delete'] === 'Go') && !isset($_REQUEST['showall']) && !isset($_REQUEST['edit_user_group_dialog']) && !isset($_REQUEST['db_specific'])) {
示例7: PMA_RTN_handleEditor
/**
* Handles editor requests for adding or editing an item
*
* @return void
*/
function PMA_RTN_handleEditor()
{
global $_GET, $_POST, $_REQUEST, $GLOBALS, $db, $errors;
if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
/**
* Handle a request to create/edit a routine
*/
$sql_query = '';
$routine_query = PMA_RTN_getQueryFromRequest();
if (!count($errors)) {
// set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (!empty($_REQUEST['editor_process_edit'])) {
$isProcOrFunc = in_array($_REQUEST['item_original_type'], array('PROCEDURE', 'FUNCTION'));
if (!$isProcOrFunc) {
$errors[] = sprintf(__('Invalid routine type: "%s"'), htmlspecialchars($_REQUEST['item_original_type']));
} else {
// Backup the old routine, in case something goes wrong
$create_routine = $GLOBALS['dbi']->getDefinition($db, $_REQUEST['item_original_type'], $_REQUEST['item_original_name']);
if (!defined('PMA_DRIZZLE') || !PMA_DRIZZLE) {
if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) {
// Backup the Old Privileges before dropping
// if $_REQUEST['item_adjust_privileges'] set
$privilegesBackup = array();
if (isset($_REQUEST['item_adjust_privileges']) && !empty($_REQUEST['item_adjust_privileges'])) {
$privilegesBackupQuery = 'SELECT * FROM ' . PMA_Util::backquote('mysql') . '.' . PMA_Util::backquote('procs_priv') . ' where Routine_name = "' . $_REQUEST['item_original_name'] . '" AND Routine_type = "' . $_REQUEST['item_original_type'] . '";';
$privilegesBackup = $GLOBALS['dbi']->fetchResult($privilegesBackupQuery, 0);
}
}
}
$drop_routine = "DROP {$_REQUEST['item_original_type']} " . PMA_Util::backquote($_REQUEST['item_original_name']) . ";\n";
$result = $GLOBALS['dbi']->tryQuery($drop_routine);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_routine)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$result = $GLOBALS['dbi']->tryQuery($routine_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
// We dropped the old routine,
// but were unable to create the new one
// Try to restore the backup query
$result = $GLOBALS['dbi']->tryQuery($create_routine);
$errors = checkResult($result, __('Sorry, we failed to restore' . ' the dropped routine.'), $create_routine, $errors);
} else {
// Default value
$resultAdjust = false;
if (!defined('PMA_DRIZZLE') || !PMA_DRIZZLE) {
if (isset($GLOBALS['proc_priv']) && $GLOBALS['proc_priv'] && isset($GLOBALS['flush_priv']) && $GLOBALS['flush_priv']) {
// Insert all the previous privileges
// but with the new name and the new type
foreach ($privilegesBackup as $priv) {
$adjustProcPrivilege = 'INSERT INTO ' . PMA_Util::backquote('mysql') . '.' . PMA_Util::backquote('procs_priv') . ' VALUES("' . $priv[0] . '", "' . $priv[1] . '", "' . $priv[2] . '", "' . $_REQUEST['item_name'] . '", "' . $_REQUEST['item_type'] . '", "' . $priv[5] . '", "' . $priv[6] . '", "' . $priv[7] . '");';
$resultAdjust = $GLOBALS['dbi']->query($adjustProcPrivilege);
}
}
}
if ($resultAdjust) {
// Flush the Privileges
$flushPrivQuery = 'FLUSH PRIVILEGES;';
$GLOBALS['dbi']->query($flushPrivQuery);
$message = PMA_Message::success(__('Routine %1$s has been modified. Privileges have been adjusted.'));
} else {
$message = PMA_Message::success(__('Routine %1$s has been modified.'));
}
$message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
$sql_query = $drop_routine . $routine_query;
}
}
}
} else {
// 'Add a new routine' mode
$result = $GLOBALS['dbi']->tryQuery($routine_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($routine_query)) . '<br /><br />' . __('MySQL said: ') . $GLOBALS['dbi']->getError(null);
} else {
$message = PMA_Message::success(__('Routine %1$s has been created.'));
$message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
$sql_query = $routine_query;
}
}
}
if (count($errors)) {
$message = PMA_Message::error(__('One or more errors have occurred while' . ' processing your request:'));
$message->addString('<ul>');
foreach ($errors as $string) {
$message->addString('<li>' . $string . '</li>');
}
$message->addString('</ul>');
}
$output = PMA_Util::getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
if ($message->isSuccess()) {
$routines = $GLOBALS['dbi']->getRoutines($db, $_REQUEST['item_type'], $_REQUEST['item_name']);
$routine = $routines[0];
//.........这里部分代码省略.........
示例8: PMA_moveOrCopyTable
/**
* Move or copy a table
*
* @param string $db current database name
* @param string $table current table name
*
* @return void
*/
function PMA_moveOrCopyTable($db, $table)
{
/**
* Selects the database to work with
*/
$GLOBALS['dbi']->selectDb($db);
/**
* $_REQUEST['target_db'] could be empty in case we came from an input field
* (when there are many databases, no drop-down)
*/
if (empty($_REQUEST['target_db'])) {
$_REQUEST['target_db'] = $db;
}
/**
* A target table name has been sent to this script -> do the work
*/
if (PMA_isValid($_REQUEST['new_name'])) {
if ($db == $_REQUEST['target_db'] && $table == $_REQUEST['new_name']) {
if (isset($_REQUEST['submit_move'])) {
$message = PMA_Message::error(__('Can\'t move table to same one!'));
} else {
$message = PMA_Message::error(__('Can\'t copy table to same one!'));
}
} else {
PMA_Table::moveCopy($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name'], $_REQUEST['what'], isset($_REQUEST['submit_move']), 'one_table');
if (isset($_REQUEST['adjust_privileges']) && !empty($_REQUEST['adjust_privileges'])) {
if (isset($_REQUEST['submit_move'])) {
PMA_AdjustPrivileges_renameOrMoveTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
} else {
PMA_AdjustPrivileges_copyTable($db, $table, $_REQUEST['target_db'], $_REQUEST['new_name']);
}
if (isset($_REQUEST['submit_move'])) {
$message = PMA_Message::success(__('Table %s has been moved to %s. Privileges have been ' . 'adjusted.'));
} else {
$message = PMA_Message::success(__('Table %s has been copied to %s. Privileges have been ' . 'adjusted.'));
}
} else {
if (isset($_REQUEST['submit_move'])) {
$message = PMA_Message::success(__('Table %s has been moved to %s.'));
} else {
$message = PMA_Message::success(__('Table %s has been copied to %s.'));
}
}
$old = PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table);
$message->addParam($old);
$new = PMA_Util::backquote($_REQUEST['target_db']) . '.' . PMA_Util::backquote($_REQUEST['new_name']);
$message->addParam($new);
/* Check: Work on new table or on old table? */
if (isset($_REQUEST['submit_move']) || PMA_isValid($_REQUEST['switch_to_new'])) {
}
}
} else {
/**
* No new name for the table!
*/
$message = PMA_Message::error(__('The table name is empty!'));
}
if ($GLOBALS['is_ajax_request'] == true) {
$response = PMA_Response::getInstance();
$response->addJSON('message', $message);
if ($message->isSuccess()) {
$response->addJSON('db', $GLOBALS['db']);
} else {
$response->isSuccess(false);
}
exit;
}
}
示例9: PMA_displayTable
//.........这里部分代码省略.........
if ($sorted_column_index !== false) {
// fetch first row of the result set
$row = PMA_DBI_fetch_row($dt_result);
$column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
// fetch last row of the result set
PMA_DBI_data_seek($dt_result, $num_rows - 1);
$row = PMA_DBI_fetch_row($dt_result);
$column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
// reset to first row for the loop in PMA_displayTableBody()
PMA_DBI_data_seek($dt_result, 0);
// we could also use here $sort_expression_nodirection
$sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
unset($row, $column_for_first_row, $column_for_last_row);
}
unset($sorted_column_index, $sort_table, $sort_column);
}
// 2. ----- Displays the top of the page -----
// 2.1 Displays a messages with position informations
if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
$selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
} else {
$selectstring = '';
}
$last_shown_rec = $_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
$message = PMA_Message::notice('strViewHasAtLeast');
$message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
$message->addParam('[/a]');
$message_view_warning = PMA_showHint($message);
} else {
$message_view_warning = false;
}
$message = PMA_Message::success('strShowingRecords');
$message->addMessage($_SESSION['tmp_user_values']['pos']);
if ($message_view_warning) {
$message->addMessage('...', ' - ');
$message->addMessage($message_view_warning);
$message->addMessage('(');
} else {
$message->addMessage($last_shown_rec, ' - ');
$message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' (');
$message->addString('strTotal');
$message->addMessage($selectstring, '');
$message->addMessage(', ', '');
}
$messagge_qt = PMA_Message::notice('strQueryTime');
$messagge_qt->addParam($GLOBALS['querytime']);
$message->addMessage($messagge_qt, '');
$message->addMessage(')', '');
$message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', '');
PMA_showMessage($message, $sql_query, 'success');
} elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
}
// 2.3 Displays the navigation bars
if (!strlen($table)) {
if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
// table does not always contain a real table name,
// for example in MySQL 5.0.x, the query SHOW STATUS
// returns STATUS as a table name
$table = $fields_meta[0]->table;
} else {
$table = '';
}
}
示例10: getMessageForInsertedRows
/**
* get PMA_Message for number of inserted rows
*
* shorthand for getting a customized message
*
* @param integer $rows Number of rows
*
* @return PMA_Message
* @static
*/
public static function getMessageForInsertedRows($rows)
{
$message = PMA_Message::success(_ngettext('%1$d row inserted.', '%1$d rows inserted.', $rows));
$message->addParam($rows);
return $message;
}
示例11: elseif
}
// Show correct message
if (!empty($id_bookmark) && $action_bookmark == 2) {
$message = PMA_Message::success('strBookmarkDeleted');
$display_query = $import_text;
$error = FALSE; // unset error marker, it was used just to skip processing
} elseif (!empty($id_bookmark) && $action_bookmark == 1) {
$message = PMA_Message::notice('strShowingBookmark');
} elseif ($bookmark_created) {
$special_message = '[br]' . sprintf($strBookmarkCreated, htmlspecialchars($bkm_label));
} elseif ($finished && !$error) {
if ($import_type == 'query') {
$message = PMA_Message::success();
} else {
$message = PMA_Message::success('strImportSuccessfullyFinished');
$message->addParam($executed_queries);
}
}
// Did we hit timeout? Tell it user.
if ($timeout_passed) {
$message = PMA_Message::error('strTimeoutPassed');
if ($offset == 0 || (isset($original_skip) && $original_skip == $offset)) {
$message->addString('strTimeoutNothingParsed');
}
}
// Parse and analyze the query, for correct db and table name
// in case of a query typed in the query window
require_once './libraries/parse_analyze.lib.php';
示例12: PMA_TRI_handleEditor
/**
* Handles editor requests for adding or editing an item
*
* @return void
*/
function PMA_TRI_handleEditor()
{
global $_REQUEST, $_POST, $errors, $db, $table;
if (!empty($_REQUEST['editor_process_add']) || !empty($_REQUEST['editor_process_edit'])) {
$sql_query = '';
$item_query = PMA_TRI_getQueryFromRequest();
if (!count($errors)) {
// set by PMA_RTN_getQueryFromRequest()
// Execute the created query
if (!empty($_REQUEST['editor_process_edit'])) {
// Backup the old trigger, in case something goes wrong
$trigger = PMA_TRI_getDataFromName($_REQUEST['item_original_name']);
$create_item = $trigger['create'];
$drop_item = $trigger['drop'] . ';';
$result = PMA_DBI_try_query($drop_item);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($drop_item)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$result = PMA_DBI_try_query($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
// We dropped the old item, but were unable to create the new one
// Try to restore the backup query
$result = PMA_DBI_try_query($create_item);
if (!$result) {
// OMG, this is really bad! We dropped the query,
// failed to create a new one
// and now even the backup query does not execute!
// This should not happen, but we better handle
// this just in case.
$errors[] = __('Sorry, we failed to restore the dropped trigger.') . '<br />' . __('The backed up query was:') . "\"" . htmlspecialchars($create_item) . "\"" . '<br />' . __('MySQL said: ') . PMA_DBI_getError(null);
}
} else {
$message = PMA_Message::success(__('Trigger %1$s has been modified.'));
$message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
$sql_query = $drop_item . $item_query;
}
}
} else {
// 'Add a new item' mode
$result = PMA_DBI_try_query($item_query);
if (!$result) {
$errors[] = sprintf(__('The following query has failed: "%s"'), htmlspecialchars($item_query)) . '<br /><br />' . __('MySQL said: ') . PMA_DBI_getError(null);
} else {
$message = PMA_Message::success(__('Trigger %1$s has been created.'));
$message->addParam(PMA_Util::backquote($_REQUEST['item_name']));
$sql_query = $item_query;
}
}
}
if (count($errors)) {
$message = PMA_Message::error(__('<b>One or more errors have occured while processing your request:</b>'));
$message->addString('<ul>');
foreach ($errors as $string) {
$message->addString('<li>' . $string . '</li>');
}
$message->addString('</ul>');
}
$output = PMA_Util::getMessage($message, $sql_query);
if ($GLOBALS['is_ajax_request']) {
$response = PMA_Response::getInstance();
if ($message->isSuccess()) {
$items = PMA_DBI_get_triggers($db, $table, '');
$trigger = false;
foreach ($items as $value) {
if ($value['name'] == $_REQUEST['item_name']) {
$trigger = $value;
}
}
$insert = false;
if (empty($table) || $trigger !== false && $table == $trigger['table']) {
$insert = true;
$response->addJSON('new_row', PMA_TRI_getRowForList($trigger));
$response->addJSON('name', htmlspecialchars(strtoupper($_REQUEST['item_name'])));
}
$response->addJSON('insert', $insert);
$response->addJSON('message', $output);
} else {
$response->addJSON('message', $message);
$response->isSuccess(false);
}
exit;
}
}
/**
* Display a form used to add/edit a trigger, if necessary
*/
if (count($errors) || empty($_REQUEST['editor_process_add']) && empty($_REQUEST['editor_process_edit']) && (!empty($_REQUEST['add_item']) || !empty($_REQUEST['edit_item']))) {
// Get the data for the form (if any)
if (!empty($_REQUEST['add_item'])) {
$title = PMA_RTE_getWord('add');
$item = PMA_TRI_getDataFromRequest();
$mode = 'add';
} else {
if (!empty($_REQUEST['edit_item'])) {
//.........这里部分代码省略.........
示例13: PMA_DBI_getError
if (! PMA_DBI_select_db($db)) {
$common_functions->mysqlDie(
PMA_DBI_getError(),
'USE ' . $common_functions->backquote($db) . ';',
'',
$err_url
);
}
$sql_query = 'ALTER TABLE ' . $common_functions->backquote($table) . ' ';
$sql_query .= implode(', ', $changes) . $key_query;
$sql_query .= ';';
$result = PMA_DBI_try_query($sql_query);
if ($result !== false) {
$message = PMA_Message::success(
__('Table %1$s has been altered successfully')
);
$message->addParam($table);
$btnDrop = 'Fake';
/**
* If comments were sent, enable relation stuff
*/
include_once 'libraries/transformations.lib.php';
// update field names in relation
if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
foreach ($_REQUEST['field_orig'] as $fieldindex => $fieldcontent) {
if ($_REQUEST['field_name'][$fieldindex] != $fieldcontent) {
PMA_REL_renameField(
$db, $table, $fieldcontent,
示例14: 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();
$we_dont_change_keys = 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'));
$changes[] = 'CHANGE ' . PMA_Table::generateAlter($column, $column, 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, $we_dont_change_keys, $i, $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;
}
示例15: elseif
// unset error marker, it was used just to skip processing
} elseif (!empty($id_bookmark) && $action_bookmark == 1) {
$message = PMA_Message::notice(__('Showing bookmark'));
} elseif ($bookmark_created) {
$special_message = '[br]' . sprintf(__('Bookmark %s created'), htmlspecialchars($bkm_label));
} elseif ($finished && !$error) {
if ($import_type == 'query') {
$message = PMA_Message::success();
} else {
if ($import_notice) {
$message = PMA_Message::success('<em>' . __('Import has been successfully finished, %d queries executed.') . '</em>');
$message->addParam($executed_queries);
$message->addString($import_notice);
$message->addString('(' . $_FILES['import_file']['name'] . ')');
} else {
$message = PMA_Message::success(__('Import has been successfully finished, %d queries executed.'));
$message->addParam($executed_queries);
$message->addString('(' . $_FILES['import_file']['name'] . ')');
}
}
}
// Did we hit timeout? Tell it user.
if ($timeout_passed) {
$message = PMA_Message::error(__('Script timeout passed, if you want to finish import, please resubmit same file and import will resume.'));
if ($offset == 0 || isset($original_skip) && $original_skip == $offset) {
$message->addString(__('However on last run no data has been parsed, this usually means phpMyAdmin won\'t be able to finish this import unless you increase php time limits.'));
}
}
// if there is any message, copy it into $_SESSION as well, so we can obtain it by AJAX call
if (isset($message)) {
$_SESSION['Import_message']['message'] = $message->getDisplay();