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


PHP PMA_Table::showCreate方法代码示例

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


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

示例1: PMA_getForeigners

/**
 * Gets all Relations to foreign tables for a given table or
 * optionally a given column in a table
 *
 * @param string $db     the name of the db to check for
 * @param string $table  the name of the table to check for
 * @param string $column the name of the column to check for
 * @param string $source the source for foreign key information
 *
 * @return array    db,table,column
 *
 * @access  public
 */
function PMA_getForeigners($db, $table, $column = '', $source = 'both')
{
    $cfgRelation = PMA_getRelationsParam();
    $foreign = array();
    if ($cfgRelation['relwork'] && ($source == 'both' || $source == 'internal')) {
        $rel_query = '
             SELECT `master_field`,
                    `foreign_db`,
                    `foreign_table`,
                    `foreign_field`
               FROM ' . PMA_Util::backquote($cfgRelation['db']) . '.' . PMA_Util::backquote($cfgRelation['relation']) . '
              WHERE `master_db`    = \'' . PMA_Util::sqlAddSlashes($db) . '\'
                AND `master_table` = \'' . PMA_Util::sqlAddSlashes($table) . '\' ';
        if (mb_strlen($column)) {
            $rel_query .= ' AND `master_field` = ' . '\'' . PMA_Util::sqlAddSlashes($column) . '\'';
        }
        $foreign = $GLOBALS['dbi']->fetchResult($rel_query, 'master_field', null, $GLOBALS['controllink']);
    }
    if (($source == 'both' || $source == 'foreign') && mb_strlen($table)) {
        $tableObj = new PMA_Table($table, $db);
        $show_create_table = $tableObj->showCreate();
        if ($show_create_table) {
            $parser = new SqlParser\Parser($show_create_table);
            /**
             * @var CreateStatement $stmt
             */
            $stmt = $parser->statements[0];
            $foreign['foreign_keys_data'] = SqlParser\Utils\Table::getForeignKeys($stmt);
        }
    }
    /**
     * Emulating relations for some information_schema and data_dictionary tables
     */
    $isInformationSchema = mb_strtolower($db) == 'information_schema';
    $is_data_dictionary = PMA_DRIZZLE && mb_strtolower($db) == 'data_dictionary';
    $isMysql = mb_strtolower($db) == 'mysql';
    if (($isInformationSchema || $is_data_dictionary || $isMysql) && ($source == 'internal' || $source == 'both')) {
        if ($isInformationSchema) {
            $relations_key = 'information_schema_relations';
            include_once './libraries/information_schema_relations.lib.php';
        } else {
            if ($is_data_dictionary) {
                $relations_key = 'data_dictionary_relations';
                include_once './libraries/data_dictionary_relations.lib.php';
            } else {
                $relations_key = 'mysql_relations';
                include_once './libraries/mysql_relations.lib.php';
            }
        }
        if (isset($GLOBALS[$relations_key][$table])) {
            foreach ($GLOBALS[$relations_key][$table] as $field => $relations) {
                if ((!mb_strlen($column) || $column == $field) && (!isset($foreign[$field]) || !mb_strlen($foreign[$field]))) {
                    $foreign[$field] = $relations;
                }
            }
        }
    }
    return $foreign;
}
开发者ID:nobodypb,项目名称:phpmyadmin,代码行数:72,代码来源:relation.lib.php

示例2:

$primary = PMA_Index::getPrimary($table, $db);
$columns_with_index = PMA_getColumnsWithIndex($db, $table, PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT);
$columns_with_unique_index = PMA_getColumnsWithIndex($db, $table, PMA_Index::UNIQUE);
// 3. Get fields
$fields = (array) $GLOBALS['dbi']->getColumns($db, $table, null, true);
// Get more complete field information
// For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
// but later, if the analyser returns more information, it
// could be executed for any MySQL version and replace
// the info given by SHOW FULL COLUMNS FROM.
//
// We also need this to correctly learn if a TIMESTAMP is NOT NULL, since
// SHOW FULL COLUMNS or INFORMATION_SCHEMA incorrectly says NULL
// and SHOW CREATE TABLE says NOT NULL (tested
// in MySQL 4.0.25 and 5.0.21, http://bugs.mysql.com/20910).
$tableObj = new PMA_Table($table, $db);
$show_create_table = $tableObj->showCreate();
$parser = new SqlParser\Parser($show_create_table);
/**
 * @var CreateStatement $stmt
 */
$stmt = $parser->statements[0];
$create_table_fields = SqlParser\Utils\Table::getFields($stmt);
/**
 * prepare table infos
 */
// action titles (image or string)
$titles = PMA_getActionTitlesArray();
//display table structure
require_once 'libraries/display_structure.inc.php';
$response->addHTML('</div>');
开发者ID:Timandes,项目名称:phpmyadmin,代码行数:31,代码来源:tbl_structure.php

示例3: PMA_getHtmlForEditView

/**
 * Get HTML for edit views'
 *
 * @param string $url_params URL parameters
 *
 * @return string $html_output
 */
function PMA_getHtmlForEditView($url_params)
{
    $query = "SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`, `SECURITY_TYPE`" . " FROM `INFORMATION_SCHEMA`.`VIEWS`" . " WHERE TABLE_SCHEMA='" . PMA_Util::sqlAddSlashes($GLOBALS['db']) . "'" . " AND TABLE_NAME='" . PMA_Util::sqlAddSlashes($GLOBALS['table']) . "';";
    $item = $GLOBALS['dbi']->fetchSingleRow($query);
    $tableObj = new PMA_Table($GLOBALS['table'], $GLOBALS['db']);
    $createView = $tableObj->showCreate();
    // get algorithm from $createView of the form CREATE ALGORITHM=<ALGORITHM> DE...
    $parts = explode(" ", substr($createView, 17));
    $item['ALGORITHM'] = $parts[0];
    $view = array('operation' => 'alter', 'definer' => $item['DEFINER'], 'sql_security' => $item['SECURITY_TYPE'], 'name' => $GLOBALS['table'], 'as' => $item['VIEW_DEFINITION'], 'with' => $item['CHECK_OPTION'], 'algorithm' => $item['ALGORITHM']);
    $url = 'view_create.php' . PMA_URL_getCommon($url_params) . '&amp;';
    $url .= implode('&amp;', array_map(function ($key, $val) {
        return 'view[' . urlencode($key) . ']=' . urlencode($val);
    }, array_keys($view), $view));
    $html_output = PMA_Util::linkOrButton($url, PMA_Util::getIcon('b_edit.png', __('Edit view'), true));
    return $html_output;
}
开发者ID:scriptpazar,项目名称:phpmyadmin,代码行数:24,代码来源:structure.lib.php

示例4: PMA_getHtmlShowCreate

/**
 * Returns Html for show create.
 *
 * @param string $db         Database name
 * @param array  $db_objects Array containing DB objects
 *
 * @return string Html
 */
function PMA_getHtmlShowCreate($db, $db_objects)
{
    // Main outer container.
    $html_output = '<div class="show_create_results">' . '<h2>' . __('Showing create queries') . '</h2>';
    // Table header.
    $output_table = '<fieldset>' . '<legend>%s</legend>' . '<table class="show_create">' . '<thead>' . '<tr>' . '<th>%s</th>' . '<th>Create %s</th>' . '</tr>' . '</thead>' . '<tbody>';
    // Holds rows html for views.
    $views = '';
    // Holds rows html for tables.
    $tables = '';
    // Handles odd, even classes for rows.
    // for 'Views'
    $odd1 = true;
    // for 'Tables'
    $odd2 = true;
    // Iterate through each object.
    foreach ($db_objects as $object) {
        $tableObj = new PMA_Table($object, $db);
        // Check if current object is a View or Table.
        $isView = PMA_Table::isView($db, $object);
        if ($isView) {
            $row_class = $odd1 ? 'odd' : 'even';
            $views .= '<tr class="' . $row_class . '">' . '<td><strong>' . PMA_mimeDefaultFunction($object) . '</strong></td>' . '<td>' . PMA_mimeDefaultFunction($tableObj->showCreate()) . '</td>' . '</tr>';
            $odd1 = !$odd1;
        } else {
            $row_class = $odd2 ? 'odd' : 'even';
            $tables .= '<tr class="' . $row_class . '">' . '<td><strong>' . PMA_mimeDefaultFunction($object) . '</strong></td>' . '<td>' . PMA_mimeDefaultFunction($tableObj->showCreate()) . '</td>' . '</tr>';
            $odd2 = !$odd2;
        }
    }
    // Prepare table header for each type of object.
    if (!empty($tables)) {
        $title = __('Tables');
        $tables = sprintf($output_table, $title, 'Table', 'Table') . $tables . '</tbody></table></fieldset>';
    }
    if (!empty($views)) {
        $title = __('Views');
        $views = sprintf($output_table, $title, 'View', 'View') . $views . '</tbody></table></fieldset>';
    }
    // Compile the final html.
    $html_output .= $tables . $views . '</div>';
    return $html_output;
}
开发者ID:saisai,项目名称:phpmyadmin,代码行数:51,代码来源:structure.lib.php


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