当前位置: 首页>>代码示例>>PHP>>正文


PHP Message::getMessageForAffectedRows方法代码示例

本文整理汇总了PHP中PMA\libraries\Message::getMessageForAffectedRows方法的典型用法代码示例。如果您正苦于以下问题:PHP Message::getMessageForAffectedRows方法的具体用法?PHP Message::getMessageForAffectedRows怎么用?PHP Message::getMessageForAffectedRows使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PMA\libraries\Message的用法示例。


在下文中一共展示了Message::getMessageForAffectedRows方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: PMA_executeQuery

/**
 * 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 array  &$sql_data SQL parse data storage
 *
 * @return void
 * @access public
 */
function PMA_executeQuery($sql, $full, &$sql_data)
{
    global $go_sql, $sql_query, $my_die, $error, $reload, $result, $msg, $cfg, $sql_query_disabled, $db;
    $result = $GLOBALS['dbi']->tryQuery($sql);
    // USE query changes the database, son need to track
    // while running multiple queries
    $is_use_query = mb_stripos($sql, "use ") !== false;
    $msg = '# ';
    if ($result === false) {
        // execution failed
        if (!isset($my_die)) {
            $my_die = array();
        }
        $my_die[] = array('sql' => $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;
        } elseif ($a_aff_rows > 0) {
            $message = Message::getMessageForAffectedRows($a_aff_rows);
            $msg .= $message->getMessage();
        } else {
            $msg .= __('MySQL returned an empty result set (i.e. zero ' . 'rows).');
        }
        if ($a_num_rows > 0 || $is_use_query) {
            $sql_data['valid_sql'][] = $sql;
            if (!isset($sql_data['valid_queries'])) {
                $sql_data['valid_queries'] = 0;
            }
            $sql_data['valid_queries']++;
        }
    }
    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($sql, $db, $reload);
    }
    $pattern = '@^[\\s]*(DROP|CREATE)[\\s]+(IF EXISTS[[:space:]]+)' . '?(TABLE|DATABASE)[[:space:]]+(.+)@im';
    if ($result != false && preg_match($pattern, $sql)) {
        $reload = true;
    }
}
开发者ID:nijel,项目名称:phpmyadmin,代码行数:62,代码来源:import.lib.php

示例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['querytype'] == 'DELETE"') {
        $message = Message::getMessageForDeletedRows($num_rows);
    } elseif ($analyzed_sql_results['is_insert']) {
        if ($analyzed_sql_results['querytype'] == 'REPLACE') {
            // For REPLACE we get DELETED + INSERTED row count,
            // so we have to call it affected
            $message = Message::getMessageForAffectedRows($num_rows);
        } else {
            $message = 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 = Message::notice(__('Inserted row id: %1$d'));
            $_inserted->addParam($insert_id + $num_rows - 1);
            $message->addMessage($_inserted);
        }
    } elseif ($analyzed_sql_results['is_affected']) {
        $message = 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['querytype'] != 'SELECT') {
        $message = Message::rawSuccess(htmlspecialchars($message_to_show));
    } elseif (!empty($GLOBALS['show_as_php'])) {
        $message = Message::success(__('Showing as PHP code'));
    } elseif (isset($GLOBALS['show_as_php'])) {
        /* User disable showing as PHP, query is only displayed */
        $message = Message::notice(__('Showing SQL query'));
    } else {
        $message = Message::success(__('MySQL returned an empty result set (i.e. zero rows).'));
    }
    if (isset($GLOBALS['querytime'])) {
        $_querytime = 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;
}
开发者ID:Devuiux,项目名称:phpmyadmin,代码行数:63,代码来源:sql.lib.php

示例3: 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;
        $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'] = 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 = 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);
//.........这里部分代码省略.........
开发者ID:netroby,项目名称:phpmyadmin,代码行数:101,代码来源:import.lib.php


注:本文中的PMA\libraries\Message::getMessageForAffectedRows方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。