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


PHP PMA_getWarningMessages函数代码示例

本文整理汇总了PHP中PMA_getWarningMessages函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getWarningMessages函数的具体用法?PHP PMA_getWarningMessages怎么用?PHP PMA_getWarningMessages使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: PMA_executeSqlQuery

/**
 * Executes the sql query and get the result, then move back to the calling page
 *
 * @param array $url_params url parameters array
 * @param array $query      built query from PMA_buildSqlQuery()
 *
 * @return array            $url_params, $total_affected_rows, $last_messages
 *                          $warning_messages, $error_messages, $return_to_sql_query
 */
function PMA_executeSqlQuery($url_params, $query)
{
    $return_to_sql_query = '';
    if (!empty($GLOBALS['sql_query'])) {
        $url_params['sql_query'] = $GLOBALS['sql_query'];
        $return_to_sql_query = $GLOBALS['sql_query'];
    }
    $GLOBALS['sql_query'] = implode('; ', $query) . ';';
    // to ensure that the query is displayed in case of
    // "insert as new row" and then "insert another new row"
    $GLOBALS['display_query'] = $GLOBALS['sql_query'];
    $total_affected_rows = 0;
    $last_messages = array();
    $warning_messages = array();
    $error_messages = array();
    foreach ($query as $single_query) {
        if ($_REQUEST['submit_type'] == 'showinsert') {
            $last_messages[] = PMA_Message::notice(__('Showing SQL query'));
            continue;
        }
        if ($GLOBALS['cfg']['IgnoreMultiSubmitErrors']) {
            $result = $GLOBALS['dbi']->tryQuery($single_query);
        } else {
            $result = $GLOBALS['dbi']->query($single_query);
        }
        if (!$result) {
            $error_messages[] = PMA_Message::sanitize($GLOBALS['dbi']->getError());
        } else {
            // The next line contains a real assignment, it's not a typo
            if ($tmp = @$GLOBALS['dbi']->affectedRows()) {
                $total_affected_rows += $tmp;
            }
            unset($tmp);
            $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
                if ($total_affected_rows > 0) {
                    $insert_id = $insert_id + $total_affected_rows - 1;
                }
                $last_message = PMA_Message::notice(__('Inserted row id: %1$d'));
                $last_message->addParam($insert_id);
                $last_messages[] = $last_message;
            }
            $GLOBALS['dbi']->freeResult($result);
        }
        $warning_messages = PMA_getWarningMessages();
    }
    return array($url_params, $total_affected_rows, $last_messages, $warning_messages, $error_messages, $return_to_sql_query);
}
开发者ID:hewenhao2008,项目名称:phpmyadmin,代码行数:59,代码来源:insert_edit.lib.php

示例2: testGetWarningMessages

 /**
  * Test for PMA_getWarningMessages
  *
  * @return void
  */
 public function testGetWarningMessages()
 {
     $warnings = array(array('Level' => 1, 'Code' => 42, 'Message' => 'msg1'), array('Level' => 2, 'Code' => 43, 'Message' => 'msg2'));
     $dbi = $this->getMockBuilder('PMA_DatabaseInterface')->disableOriginalConstructor()->getMock();
     $dbi->expects($this->once())->method('getWarnings')->will($this->returnValue($warnings));
     $GLOBALS['dbi'] = $dbi;
     $result = PMA_getWarningMessages();
     $this->assertEquals(array("1: #42 msg1", "2: #43 msg2"), $result);
 }
开发者ID:kfjihailong,项目名称:phpMyAdmin,代码行数:14,代码来源:PMA_insert_edit_test.php


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