本文整理汇总了PHP中PMA_Message::getMessageForAffectedRows方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Message::getMessageForAffectedRows方法的具体用法?PHP PMA_Message::getMessageForAffectedRows怎么用?PHP PMA_Message::getMessageForAffectedRows使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Message
的用法示例。
在下文中一共展示了PMA_Message::getMessageForAffectedRows方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testAffectedRows
/**
* Test for getMessageForAffectedRows() method
*
* @param int $rows Number of rows
* @param string $output Expected string
*
* @return void
*
* @dataProvider providerAffectedRows
*/
public function testAffectedRows($rows, $output)
{
$this->object = new PMA_Message();
$msg = $this->object->getMessageForAffectedRows($rows);
echo $this->object->addMessage($msg);
$this->expectOutputString($output);
$this->object->display();
}
示例2: PMA_getMessageForNoRowsReturned
/**
* Function to get the message for the no rows returned case
*
* @param string $message_to_show message to show
* @param array $analyzed_sql_results analyzed sql results
* @param int $num_rows number of rows
*
* @return string $message
*/
function PMA_getMessageForNoRowsReturned($message_to_show, $analyzed_sql_results, $num_rows)
{
if ($analyzed_sql_results['is_delete']) {
$message = PMA_Message::getMessageForDeletedRows($num_rows);
} elseif ($analyzed_sql_results['is_insert']) {
if ($analyzed_sql_results['is_replace']) {
// For replace we get DELETED + INSERTED row count,
// so we have to call it affected
$message = PMA_Message::getMessageForAffectedRows($num_rows);
} else {
$message = PMA_Message::getMessageForInsertedRows($num_rows);
}
$insert_id = $GLOBALS['dbi']->insertId();
if ($insert_id != 0) {
// insert_id is id of FIRST record inserted in one insert,
// so if we inserted multiple rows, we had to increment this
$message->addMessage('[br]');
// need to use a temporary because the Message class
// currently supports adding parameters only to the first
// message
$_inserted = PMA_Message::notice(__('Inserted row id: %1$d'));
$_inserted->addParam($insert_id + $num_rows - 1);
$message->addMessage($_inserted);
}
} elseif ($analyzed_sql_results['is_affected']) {
$message = PMA_Message::getMessageForAffectedRows($num_rows);
// Ok, here is an explanation for the !$is_select.
// The form generated by sql_query_form.lib.php
// and db_sql.php has many submit buttons
// on the same form, and some confusion arises from the
// fact that $message_to_show is sent for every case.
// The $message_to_show containing a success message and sent with
// the form should not have priority over errors
} elseif (!empty($message_to_show) && !$analyzed_sql_results['is_select']) {
$message = PMA_Message::rawSuccess(htmlspecialchars($message_to_show));
} elseif (!empty($GLOBALS['show_as_php'])) {
$message = PMA_Message::success(__('Showing as PHP code'));
} elseif (isset($GLOBALS['show_as_php'])) {
/* User disable showing as PHP, query is only displayed */
$message = PMA_Message::notice(__('Showing SQL query'));
} else {
$message = PMA_Message::success(__('MySQL returned an empty result set (i.e. zero rows).'));
}
if (isset($GLOBALS['querytime'])) {
$_querytime = PMA_Message::notice('(' . __('Query took %01.4f seconds.') . ')');
$_querytime->addParam($GLOBALS['querytime']);
$message->addMessage($_querytime);
}
// In case of ROLLBACK, notify the user.
if (isset($_REQUEST['rollback_query'])) {
$message->addMessage(__('[ROLLBACK occurred.]'));
}
return $message;
}
示例3: unset
}
unset($multi_edit_columns, $is_insertignore);
// If there is a request for SQL previewing.
if (isset($_REQUEST['preview_sql'])) {
PMA_previewSQL($query);
}
/**
* Executes the sql query and get the result, then move back to the calling
* page
*/
list($url_params, $total_affected_rows, $last_messages, $warning_messages, $error_messages, $return_to_sql_query) = PMA_executeSqlQuery($url_params, $query);
if ($is_insert && (count($value_sets) > 0 || $row_skipped)) {
$message = PMA_Message::getMessageForInsertedRows($total_affected_rows);
$unsaved_values = array_values($unsaved_values);
} else {
$message = PMA_Message::getMessageForAffectedRows($total_affected_rows);
}
if ($row_skipped) {
$goto_include = 'tbl_change.php';
$message->addMessages($insert_errors, '<br />');
$message->isError(true);
}
$message->addMessages($last_messages, '<br />');
if (!empty($warning_messages)) {
$message->addMessages($warning_messages, '<br />');
$message->isError(true);
}
if (!empty($error_messages)) {
$message->addMessages($error_messages);
$message->isError(true);
}
示例4: PMA_importRunQuery
/**
* Runs query inside import buffer. This is needed to allow displaying
* of last SELECT, SHOW or HANDLER results and similar nice stuff.
*
* @param string $sql query to run
* @param string $full query to display, this might be commented
* @param bool $controluser whether to use control user for queries
* @param array &$sql_data SQL parse data storage
*
* @return void
* @access public
*/
function PMA_importRunQuery($sql = '', $full = '', $controluser = false, &$sql_data = array())
{
global $import_run_buffer, $go_sql, $complete_query, $display_query, $sql_query, $my_die, $error, $reload, $last_query_with_results, $result, $msg, $skip_queries, $executed_queries, $max_sql_len, $read_multiply, $cfg, $sql_query_disabled, $db, $run_query, $is_superuser;
$read_multiply = 1;
if (!isset($import_run_buffer)) {
// Do we have something to push into buffer?
$import_run_buffer = PMA_ImportRunQuery_post($import_run_buffer, $sql, $full);
return;
}
// Should we skip something?
if ($skip_queries > 0) {
$skip_queries--;
// Do we have something to push into buffer?
$import_run_buffer = PMA_ImportRunQuery_post($import_run_buffer, $sql, $full);
return;
}
if (!empty($import_run_buffer['sql']) && trim($import_run_buffer['sql']) != '') {
// USE query changes the database, son need to track
// while running multiple queries
$is_use_query = mb_stripos($import_run_buffer['sql'], "use ") !== false ? true : false;
$max_sql_len = max($max_sql_len, mb_strlen($import_run_buffer['sql']));
if (!$sql_query_disabled) {
$sql_query .= $import_run_buffer['full'];
}
$pattern = '@^[[:space:]]*DROP[[:space:]]+(IF EXISTS[[:space:]]+)?' . 'DATABASE @i';
if (!$cfg['AllowUserDropDatabase'] && !$is_superuser && preg_match($pattern, $import_run_buffer['sql'])) {
$GLOBALS['message'] = PMA_Message::error(__('"DROP DATABASE" statements are disabled.'));
$error = true;
} else {
$executed_queries++;
$pattern = '/^[\\s]*(SELECT|SHOW|HANDLER)/i';
if ($run_query && $GLOBALS['finished'] && empty($sql) && !$error && (!empty($import_run_buffer['sql']) && preg_match($pattern, $import_run_buffer['sql']) || $executed_queries == 1)) {
$go_sql = true;
if (!$sql_query_disabled) {
$complete_query = $sql_query;
$display_query = $sql_query;
} else {
$complete_query = '';
$display_query = '';
}
$sql_query = $import_run_buffer['sql'];
$sql_data['valid_sql'][] = $import_run_buffer['sql'];
if (!isset($sql_data['valid_queries'])) {
$sql_data['valid_queries'] = 0;
}
$sql_data['valid_queries']++;
// If a 'USE <db>' SQL-clause was found,
// set our current $db to the new one
list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
} elseif ($run_query) {
if ($controluser) {
$result = PMA_queryAsControlUser($import_run_buffer['sql']);
} else {
$result = $GLOBALS['dbi']->tryQuery($import_run_buffer['sql']);
}
$msg = '# ';
if ($result === false) {
// execution failed
if (!isset($my_die)) {
$my_die = array();
}
$my_die[] = array('sql' => $import_run_buffer['full'], 'error' => $GLOBALS['dbi']->getError());
$msg .= __('Error');
if (!$cfg['IgnoreMultiSubmitErrors']) {
$error = true;
return;
}
} else {
$a_num_rows = (int) @$GLOBALS['dbi']->numRows($result);
$a_aff_rows = (int) @$GLOBALS['dbi']->affectedRows();
if ($a_num_rows > 0) {
$msg .= __('Rows') . ': ' . $a_num_rows;
$last_query_with_results = $import_run_buffer['sql'];
} elseif ($a_aff_rows > 0) {
$message = PMA_Message::getMessageForAffectedRows($a_aff_rows);
$msg .= $message->getMessage();
} else {
$msg .= __('MySQL returned an empty result set (i.e. zero ' . 'rows).');
}
$sql_data = updateSqlData($sql_data, $a_num_rows, $is_use_query, $import_run_buffer);
}
if (!$sql_query_disabled) {
$sql_query .= $msg . "\n";
}
// If a 'USE <db>' SQL-clause was found and the query
// succeeded, set our current $db to the new one
if ($result != false) {
list($db, $reload) = PMA_lookForUse($import_run_buffer['sql'], $db, $reload);
//.........这里部分代码省略.........
示例5: PMA_DBI_insert_id
$message = PMA_Message::getMessageForInsertedRows($num_rows);
}
$insert_id = PMA_DBI_insert_id();
if ($insert_id != 0) {
// insert_id is id of FIRST record inserted in one insert,
// so if we inserted multiple rows, we had to increment this
$message->addMessage('[br]');
// need to use a temporary because the Message class
// currently supports adding parameters only to the first
// message
$_inserted = PMA_Message::notice(__('Inserted row id: %1$d'));
$_inserted->addParam($insert_id + $num_rows - 1);
$message->addMessage($_inserted);
}
} elseif ($is_affected) {
$message = PMA_Message::getMessageForAffectedRows($num_rows);
// Ok, here is an explanation for the !$is_select.
// The form generated by sql_query_form.lib.php
// and db_sql.php has many submit buttons
// on the same form, and some confusion arises from the
// fact that $message_to_show is sent for every case.
// The $message_to_show containing a success message and sent with
// the form should not have priority over errors
} elseif (!empty($message_to_show) && !$is_select) {
$message = PMA_Message::rawSuccess(htmlspecialchars($message_to_show));
} elseif (!empty($GLOBALS['show_as_php'])) {
$message = PMA_Message::success(__('Showing as PHP code'));
} elseif (isset($GLOBALS['show_as_php'])) {
/* User disable showing as PHP, query is only displayed */
$message = PMA_Message::notice(__('Showing SQL query'));
} elseif (!empty($GLOBALS['validatequery'])) {