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


PHP PMA_RTN_getDataFromName函数代码示例

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


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

示例1: PMA_RTN_handleExecute

/**
 * Handles requests for executing a routine
 *
 * @return void
 */
function PMA_RTN_handleExecute()
{
    global $_GET, $_POST, $_REQUEST, $GLOBALS, $db;
    /**
     * Handle all user requests other than the default of listing routines
     */
    if (!empty($_REQUEST['execute_routine']) && !empty($_REQUEST['item_name'])) {
        // Build the queries
        $routine = PMA_RTN_getDataFromName($_REQUEST['item_name'], $_REQUEST['item_type'], false, true);
        if ($routine === false) {
            $message = __('Error in processing request:') . ' ';
            $message .= sprintf(PMA_RTE_getWord('not_found'), htmlspecialchars(PMA\libraries\Util::backquote($_REQUEST['item_name'])), htmlspecialchars(PMA\libraries\Util::backquote($db)));
            $message = Message::error($message);
            if ($GLOBALS['is_ajax_request']) {
                $response = PMA\libraries\Response::getInstance();
                $response->setRequestStatus(false);
                $response->addJSON('message', $message);
                exit;
            } else {
                echo $message->getDisplay();
                unset($_POST);
            }
        }
        $queries = array();
        $end_query = array();
        $args = array();
        $all_functions = $GLOBALS['PMA_Types']->getAllFunctions();
        for ($i = 0; $i < $routine['item_num_params']; $i++) {
            if (isset($_REQUEST['params'][$routine['item_param_name'][$i]])) {
                $value = $_REQUEST['params'][$routine['item_param_name'][$i]];
                if (is_array($value)) {
                    // is SET type
                    $value = implode(',', $value);
                }
                $value = $GLOBALS['dbi']->escapeString($value);
                if (!empty($_REQUEST['funcs'][$routine['item_param_name'][$i]]) && in_array($_REQUEST['funcs'][$routine['item_param_name'][$i]], $all_functions)) {
                    $queries[] = "SET @p{$i}=" . $_REQUEST['funcs'][$routine['item_param_name'][$i]] . "('{$value}');\n";
                } else {
                    $queries[] = "SET @p{$i}='{$value}';\n";
                }
                $args[] = "@p{$i}";
            } else {
                $args[] = "@p{$i}";
            }
            if ($routine['item_type'] == 'PROCEDURE') {
                if ($routine['item_param_dir'][$i] == 'OUT' || $routine['item_param_dir'][$i] == 'INOUT') {
                    $end_query[] = "@p{$i} AS " . PMA\libraries\Util::backquote($routine['item_param_name'][$i]);
                }
            }
        }
        if ($routine['item_type'] == 'PROCEDURE') {
            $queries[] = "CALL " . PMA\libraries\Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ");\n";
            if (count($end_query)) {
                $queries[] = "SELECT " . implode(', ', $end_query) . ";\n";
            }
        } else {
            $queries[] = "SELECT " . PMA\libraries\Util::backquote($routine['item_name']) . "(" . implode(', ', $args) . ") " . "AS " . PMA\libraries\Util::backquote($routine['item_name']) . ";\n";
        }
        // Get all the queries as one SQL statement
        $multiple_query = implode("", $queries);
        $outcome = true;
        $affected = 0;
        // Execute query
        if (!$GLOBALS['dbi']->tryMultiQuery($multiple_query)) {
            $outcome = false;
        }
        // Generate output
        if ($outcome) {
            // Pass the SQL queries through the "pretty printer"
            $output = PMA\libraries\Util::formatSql(implode($queries, "\n"));
            // Display results
            $output .= "<fieldset><legend>";
            $output .= sprintf(__('Execution results of routine %s'), PMA\libraries\Util::backquote(htmlspecialchars($routine['item_name'])));
            $output .= "</legend>";
            $nbResultsetToDisplay = 0;
            do {
                $result = $GLOBALS['dbi']->storeResult();
                $num_rows = $GLOBALS['dbi']->numRows($result);
                if ($result !== false && $num_rows > 0) {
                    $output .= "<table><tr>";
                    foreach ($GLOBALS['dbi']->getFieldsMeta($result) as $field) {
                        $output .= "<th>";
                        $output .= htmlspecialchars($field->name);
                        $output .= "</th>";
                    }
                    $output .= "</tr>";
                    $color_class = 'odd';
                    while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
                        $output .= "<tr>" . browseRow($row, $color_class) . "</tr>";
                        $color_class = $color_class == 'odd' ? 'even' : 'odd';
                    }
                    $output .= "</table>";
                    $nbResultsetToDisplay++;
                    $affected = $num_rows;
                }
//.........这里部分代码省略.........
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:101,代码来源:rte_routines.lib.php

示例2: PMA_RTN_getRowForList

/**
 * Creates the contents for a row in the list of routines
 *
 * @param    array    $routine    An array of routine data
 * @param    string   $rowclass   Empty or one of ['even'|'odd']
 *
 * @return   string   HTML code of a row for the list of routines
 */
function PMA_RTN_getRowForList($routine, $rowclass = '')
{
    global $ajax_class, $url_query, $db, $titles;
    $sql_drop = sprintf('DROP %s IF EXISTS %s', $routine['ROUTINE_TYPE'], PMA_backquote($routine['SPECIFIC_NAME']));
    $type_link = "item_type={$routine['ROUTINE_TYPE']}";
    $retval = "        <tr class='noclick {$rowclass}'>\n";
    $retval .= "            <td>\n";
    $retval .= "                <span class='drop_sql hide'>{$sql_drop}</span>\n";
    $retval .= "                <strong>\n";
    $retval .= "                    " . htmlspecialchars($routine['SPECIFIC_NAME']) . "\n";
    $retval .= "                </strong>\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    if ($routine['ROUTINE_DEFINITION'] !== null && PMA_currentUserHasPrivilege('ALTER ROUTINE', $db) && PMA_currentUserHasPrivilege('CREATE ROUTINE', $db)) {
        $retval .= '                <a ' . $ajax_class['edit'] . ' href="db_routines.php?' . $url_query . '&amp;edit_item=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Edit'] . "</a>\n";
    } else {
        $retval .= "                {$titles['NoEdit']}\n";
    }
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    if ($routine['ROUTINE_DEFINITION'] !== null && PMA_currentUserHasPrivilege('EXECUTE', $db)) {
        // Check if he routine has any input parameters. If it does,
        // we will show a dialog to get values for these parameters,
        // otherwise we can execute it directly.
        $routine_details = PMA_RTN_getDataFromName($routine['SPECIFIC_NAME'], $routine['ROUTINE_TYPE'], false);
        if ($routine !== false) {
            $execute_action = 'execute_routine';
            for ($i = 0; $i < $routine_details['item_num_params']; $i++) {
                if ($routine_details['item_type'] == 'PROCEDURE' && $routine_details['item_param_dir'][$i] == 'OUT') {
                    continue;
                }
                $execute_action = 'execute_dialog';
                break;
            }
            $retval .= '                <a ' . $ajax_class['exec'] . ' href="db_routines.php?' . $url_query . '&amp;' . $execute_action . '=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Execute'] . "</a>\n";
        }
    } else {
        $retval .= "                {$titles['NoExecute']}\n";
    }
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= '                <a ' . $ajax_class['export'] . ' href="db_routines.php?' . $url_query . '&amp;export_item=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Export'] . "</a>\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    if (PMA_currentUserHasPrivilege('ALTER ROUTINE', $db)) {
        $retval .= '                <a ' . $ajax_class['drop'] . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sql_drop) . '&amp;goto=db_routines.php' . urlencode("?db={$db}") . '" >' . $titles['Drop'] . "</a>\n";
    } else {
        $retval .= "                {$titles['NoDrop']}\n";
    }
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= "                 {$routine['ROUTINE_TYPE']}\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= "                " . htmlspecialchars($routine['DTD_IDENTIFIER']) . "\n";
    $retval .= "            </td>\n";
    $retval .= "        </tr>\n";
    return $retval;
}
开发者ID:AmberWish,项目名称:laba_web,代码行数:67,代码来源:rte_list.lib.php

示例3: PMA_RTN_getRowForList

/**
 * Creates the contents for a row in the list of routines
 *
 * @param array  $routine  An array of routine data
 * @param string $rowclass Empty or one of ['even'|'odd']
 *
 * @return string HTML code of a row for the list of routines
 */
function PMA_RTN_getRowForList($routine, $rowclass = '')
{
    global $ajax_class, $url_query, $db, $titles;
    $sql_drop = sprintf('DROP %s IF EXISTS %s', $routine['ROUTINE_TYPE'], PMA_Util::backquote($routine['SPECIFIC_NAME']));
    $type_link = "item_type={$routine['ROUTINE_TYPE']}";
    $retval = "        <tr class='noclick {$rowclass}'>\n";
    $retval .= "            <td>\n";
    $retval .= "                <span class='drop_sql hide'>" . htmlspecialchars($sql_drop) . "</span>\n";
    $retval .= "                <strong>\n";
    $retval .= "                    " . htmlspecialchars($routine['SPECIFIC_NAME']) . "\n";
    $retval .= "                </strong>\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    if ($routine['ROUTINE_DEFINITION'] !== null) {
        $retval .= '                <a ' . $ajax_class['edit'] . ' href="db_routines.php?' . $url_query . '&amp;edit_item=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Edit'] . "</a>\n";
    } else {
        $retval .= "                {$titles['NoEdit']}\n";
    }
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    // There is a problem with PMA_Util::currentUserHasPrivilege():
    // it does not detect all kinds of privileges, for example
    // a direct privilege on a specific routine. So, at this point,
    // we show the Execute link, hoping that the user has the correct rights.
    // Also, information_schema might be hiding the ROUTINE_DEFINITION
    // but a routine with no input parameters can be nonetheless executed.
    // Check if he routine has any input parameters. If it does,
    // we will show a dialog to get values for these parameters,
    // otherwise we can execute it directly.
    $routine_details = PMA_RTN_getDataFromName($routine['SPECIFIC_NAME'], $routine['ROUTINE_TYPE'], false);
    if ($routine !== false) {
        $execute_action = 'execute_routine';
        for ($i = 0; $i < $routine_details['item_num_params']; $i++) {
            if ($routine_details['item_type'] == 'PROCEDURE' && $routine_details['item_param_dir'][$i] == 'OUT') {
                continue;
            }
            $execute_action = 'execute_dialog';
            break;
        }
        $retval .= '                <a ' . $ajax_class['exec'] . ' href="db_routines.php?' . $url_query . '&amp;' . $execute_action . '=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Execute'] . "</a>\n";
    }
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= '                <a ' . $ajax_class['export'] . ' href="db_routines.php?' . $url_query . '&amp;export_item=1' . '&amp;item_name=' . urlencode($routine['SPECIFIC_NAME']) . '&amp;' . $type_link . '">' . $titles['Export'] . "</a>\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= '                <a ' . $ajax_class['drop'] . ' href="sql.php?' . $url_query . '&amp;sql_query=' . urlencode($sql_drop) . '&amp;goto=db_routines.php' . urlencode("?db={$db}") . '" >' . $titles['Drop'] . "</a>\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= "                 {$routine['ROUTINE_TYPE']}\n";
    $retval .= "            </td>\n";
    $retval .= "            <td>\n";
    $retval .= "                " . htmlspecialchars($routine['DTD_IDENTIFIER']) . "\n";
    $retval .= "            </td>\n";
    $retval .= "        </tr>\n";
    return $retval;
}
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:65,代码来源:rte_list.lib.php


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