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


PHP libraries\Table类代码示例

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


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

示例1: PMA_buildColumnCreationStatement

/**
 * Initiate the column creation statement according to the table creation or
 * add columns to a existing table
 *
 * @param int     $field_cnt     number of columns
 * @param boolean $is_create_tbl true if requirement is to get the statement
 *                               for table creation
 *
 * @return array  $definitions An array of initial sql statements
 *                             according to the request
 */
function PMA_buildColumnCreationStatement($field_cnt, $is_create_tbl = true)
{
    $definitions = array();
    for ($i = 0; $i < $field_cnt; ++$i) {
        // '0' is also empty for php :-(
        if (empty($_REQUEST['field_name'][$i]) && $_REQUEST['field_name'][$i] != '0') {
            continue;
        }
        $definition = PMA_getStatementPrefix($is_create_tbl) . Table::generateFieldSpec(trim($_REQUEST['field_name'][$i]), $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], isset($_REQUEST['field_collation'][$i]) ? $_REQUEST['field_collation'][$i] : '', isset($_REQUEST['field_null'][$i]) ? $_REQUEST['field_null'][$i] : 'NOT NULL', $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], isset($_REQUEST['field_extra'][$i]) ? $_REQUEST['field_extra'][$i] : false, isset($_REQUEST['field_comments'][$i]) ? $_REQUEST['field_comments'][$i] : '', isset($_REQUEST['field_virtuality'][$i]) ? $_REQUEST['field_virtuality'][$i] : '', isset($_REQUEST['field_expression'][$i]) ? $_REQUEST['field_expression'][$i] : '');
        $definition .= PMA_setColumnCreationStatementSuffix($i, $is_create_tbl);
        $definitions[] = $definition;
    }
    // end for
    return $definitions;
}
开发者ID:rugbyprof,项目名称:phpmyadmin,代码行数:26,代码来源:create_addfield.lib.php

示例2: PMA_calculatePosForLastPage

/**
 * Function to calculate new pos if pos is higher than number of rows
 * of displayed table
 *
 * @param String   $db    Database name
 * @param String   $table Table name
 * @param Int|null $pos   Initial position
 *
 * @return Int Number of pos to display last page
 */
function PMA_calculatePosForLastPage($db, $table, $pos)
{
    if (null === $pos) {
        $pos = $_SESSION['tmpval']['pos'];
    }
    $_table = new Table($table, $db);
    $unlim_num_rows = $_table->countRecords(true);
    //If position is higher than number of rows
    if ($unlim_num_rows <= $pos && 0 != $pos) {
        $pos = PMA_getStartPosToDisplayRow($unlim_num_rows);
    }
    return $pos;
}
开发者ID:Devuiux,项目名称:phpmyadmin,代码行数:23,代码来源:sql.lib.php

示例3: testMoveCopy

 /**
  * Test for moveCopy
  *
  * @return void
  */
 public function testMoveCopy()
 {
     $source_table = 'PMA_BookMark';
     $source_db = 'PMA';
     $target_table = 'PMA_BookMark_new';
     $target_db = 'PMA_new';
     $what = "dataonly";
     $move = true;
     $mode = "one_table";
     $GLOBALS['dbi']->expects($this->any())->method('getTable')->will($this->returnValue(new Table($target_table, $target_db)));
     $_REQUEST['drop_if_exists'] = true;
     $return = Table::moveCopy($source_db, $source_table, $target_db, $target_table, $what, $move, $mode);
     //successfully
     $expect = true;
     $this->assertEquals($expect, $return);
     $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM " . "`PMA`.`PMA_BookMark`";
     $this->assertContains($sql_query, $GLOBALS['sql_query']);
     $sql_query = "DROP VIEW `PMA`.`PMA_BookMark`";
     $this->assertContains($sql_query, $GLOBALS['sql_query']);
     $return = Table::moveCopy($source_db, $source_table, $target_db, $target_table, $what, false, $mode);
     //successfully
     $expect = true;
     $this->assertEquals($expect, $return);
     $sql_query = "INSERT INTO `PMA_new`.`PMA_BookMark_new` SELECT * FROM " . "`PMA`.`PMA_BookMark`;";
     $this->assertContains($sql_query, $GLOBALS['sql_query']);
     $sql_query = "DROP VIEW `PMA`.`PMA_BookMark`";
     $this->assertNotContains($sql_query, $GLOBALS['sql_query']);
 }
开发者ID:pboutin44,项目名称:maintest,代码行数:33,代码来源:TableTest.php

示例4: Table

 * Various table operations
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\Partition;
use PMA\libraries\Table;
/**
 *
 */
require_once 'libraries/common.inc.php';
/**
 * functions implementation for this script
 */
require_once 'libraries/check_user_privileges.lib.php';
require_once 'libraries/operations.lib.php';
$pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
/**
 * Load JavaScript files
 */
$response = PMA\libraries\Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('tbl_operations.js');
/**
 * Runs common work
 */
require 'libraries/tbl_common.inc.php';
$url_query .= '&amp;goto=tbl_operations.php&amp;back=tbl_operations.php';
$url_params['goto'] = $url_params['back'] = 'tbl_operations.php';
/**
 * Gets relation settings
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:31,代码来源:tbl_operations.php

示例5: PMA_getHtmlForExportOptions

/**
 * Prints Html For Export Options
 *
 * @param String         $export_type    Selected Export Type
 * @param String         $db             Selected DB
 * @param String         $table          Selected Table
 * @param String         $multi_values   Export selection
 * @param String         $num_tables     number of tables
 * @param ExportPlugin[] $export_list    Export List
 * @param String         $unlim_num_rows Number of Rows
 *
 * @return string
 */
function PMA_getHtmlForExportOptions($export_type, $db, $table, $multi_values, $num_tables, $export_list, $unlim_num_rows)
{
    global $cfg;
    $html = PMA_getHtmlForExportOptionsMethod();
    $html .= PMA_getHtmlForExportOptionsFormatDropdown($export_list);
    $html .= PMA_getHtmlForExportOptionsSelection($export_type, $multi_values);
    $_table = new Table($table, $db);
    if (strlen($table) > 0 && empty($num_tables) && !$_table->isMerge()) {
        $html .= PMA_getHtmlForExportOptionsRows($db, $table, $unlim_num_rows);
    }
    if (isset($cfg['SaveDir']) && !empty($cfg['SaveDir'])) {
        $html .= PMA_getHtmlForExportOptionsQuickExport();
    }
    $html .= PMA_getHtmlForAliasModalDialog($db, $table);
    $html .= PMA_getHtmlForExportOptionsOutput($export_type);
    $html .= PMA_getHtmlForExportOptionsFormat($export_list);
    return $html;
}
开发者ID:nijel,项目名称:phpmyadmin,代码行数:31,代码来源:display_export.lib.php

示例6: Table

<?php

/* vim: set expandtab sw=4 ts=4 sts=4: */
/**
 * View manipulations
 *
 * @package PhpMyAdmin
 */
use PMA\libraries\Table;
use PMA\libraries\Response;
use PMA\libraries\URL;
/**
 *
 */
require_once './libraries/common.inc.php';
$pma_table = new Table($GLOBALS['table'], $GLOBALS['db']);
/**
 * functions implementation for this script
 */
require_once 'libraries/operations.lib.php';
/**
 * Load JavaScript files
 */
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('tbl_operations.js');
/**
 * Runs common work
 */
require './libraries/tbl_common.inc.php';
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:31,代码来源:view_operations.php

示例7: _setMessageInformation

 /**
  * Set the content that needs to be shown in message
  *
  * @param string  $sorted_column_message the message for sorted column
  * @param array   $analyzed_sql_results  the analyzed query
  * @param integer $total                 the total number of rows returned by
  *                                       the SQL query without any
  *                                       programmatically appended LIMIT clause
  * @param integer $pos_next              the offset for next page
  * @param string  $pre_count             the string renders before row count
  * @param string  $after_count           the string renders after row count
  *
  * @return Message $message an object of Message
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _setMessageInformation($sorted_column_message, $analyzed_sql_results, $total, $pos_next, $pre_count, $after_count)
 {
     $unlim_num_rows = $this->__get('unlim_num_rows');
     // To use in isset()
     if (!empty($analyzed_sql_results['statement']->limit)) {
         $first_shown_rec = $analyzed_sql_results['statement']->limit->offset;
         $row_count = $analyzed_sql_results['statement']->limit->rowCount;
         if ($row_count < $total) {
             $last_shown_rec = $first_shown_rec + $row_count - 1;
         } else {
             $last_shown_rec = $first_shown_rec + $total - 1;
         }
     } elseif ($_SESSION['tmpval']['max_rows'] == self::ALL_ROWS || $pos_next > $total) {
         $first_shown_rec = $_SESSION['tmpval']['pos'];
         $last_shown_rec = $total - 1;
     } else {
         $first_shown_rec = $_SESSION['tmpval']['pos'];
         $last_shown_rec = $pos_next - 1;
     }
     $table = new Table($this->__get('table'), $this->__get('db'));
     if ($table->isView() && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
         $message = Message::notice(__('This view has at least this number of rows. ' . 'Please refer to %sdocumentation%s.'));
         $message->addParam('[doc@cfg_MaxExactCount]');
         $message->addParam('[/doc]');
         $message_view_warning = Util::showHint($message);
     } else {
         $message_view_warning = false;
     }
     $message = Message::success(__('Showing rows %1s - %2s'));
     $message->addParam($first_shown_rec);
     if ($message_view_warning !== false) {
         $message->addParam('... ' . $message_view_warning, false);
     } else {
         $message->addParam($last_shown_rec);
     }
     $message->addMessage('(');
     if ($message_view_warning === false) {
         if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
             $message_total = Message::notice($pre_count . __('%1$d total, %2$d in query'));
             $message_total->addParam($total);
             $message_total->addParam($unlim_num_rows);
         } else {
             $message_total = Message::notice($pre_count . __('%d total'));
             $message_total->addParam($total);
         }
         if (!empty($after_count)) {
             $message_total->addMessage($after_count);
         }
         $message->addMessage($message_total, '');
         $message->addMessage(', ', '');
     }
     $message_qt = Message::notice(__('Query took %01.4f seconds.') . ')');
     $message_qt->addParam($this->__get('querytime'));
     $message->addMessage($message_qt, '');
     if (!is_null($sorted_column_message)) {
         $message->addMessage($sorted_column_message, '');
     }
     return $message;
 }
开发者ID:rugbyprof,项目名称:phpmyadmin,代码行数:77,代码来源:DisplayResults.php

示例8: PMA_exportTable

/**
 * Export at the table level
 *
 * @param string       $db              the database to export
 * @param string       $table           the table to export
 * @param string       $whatStrucOrData structure or data or both
 * @param ExportPlugin $export_plugin   the selected export plugin
 * @param string       $crlf            end of line character(s)
 * @param string       $err_url         the URL in case of error
 * @param string       $export_type     the export type
 * @param bool         $do_relation     whether to export relation info
 * @param bool         $do_comments     whether to add comments
 * @param bool         $do_mime         whether to add MIME info
 * @param bool         $do_dates        whether to add dates
 * @param string       $allrows         whether "dump all rows" was ticked
 * @param string       $limit_to        upper limit
 * @param string       $limit_from      starting limit
 * @param string       $sql_query       query for which exporting is requested
 * @param array        $aliases         Alias information for db/table/column
 *
 * @return void
 */
function PMA_exportTable($db, $table, $whatStrucOrData, $export_plugin, $crlf, $err_url, $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $allrows, $limit_to, $limit_from, $sql_query, $aliases)
{
    $db_alias = !empty($aliases[$db]['alias']) ? $aliases[$db]['alias'] : '';
    if (!$export_plugin->exportDBHeader($db, $db_alias)) {
        return;
    }
    if (isset($allrows) && $allrows == '0' && $limit_to > 0 && $limit_from >= 0) {
        $add_query = ' LIMIT ' . ($limit_from > 0 ? $limit_from . ', ' : '') . $limit_to;
    } else {
        $add_query = '';
    }
    $_table = new Table($table, $db);
    $is_view = $_table->isView();
    if ($whatStrucOrData == 'structure' || $whatStrucOrData == 'structure_and_data') {
        if ($is_view) {
            if (isset($GLOBALS['sql_create_view'])) {
                if (!$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'create_view', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                    return;
                }
            }
        } else {
            if (isset($GLOBALS['sql_create_table'])) {
                if (!$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'create_table', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
                    return;
                }
            }
        }
    }
    // If this is an export of a single view, we have to export data;
    // for example, a PDF report
    // if it is a merge table, no data is exported
    if ($whatStrucOrData == 'data' || $whatStrucOrData == 'structure_and_data') {
        if (!empty($sql_query)) {
            // only preg_replace if needed
            if (!empty($add_query)) {
                // remove trailing semicolon before adding a LIMIT
                $sql_query = preg_replace('%;\\s*$%', '', $sql_query);
            }
            $local_query = $sql_query . $add_query;
            $GLOBALS['dbi']->selectDb($db);
        } else {
            // Data is exported only for Non-generated columns
            $tableObj = new PMA\libraries\Table($table, $db);
            $nonGeneratedCols = $tableObj->getNonGeneratedColumns(true);
            $local_query = 'SELECT ' . implode(', ', $nonGeneratedCols) . ' FROM ' . PMA\libraries\Util::backquote($db) . '.' . PMA\libraries\Util::backquote($table) . $add_query;
        }
        if (!$export_plugin->exportData($db, $table, $crlf, $err_url, $local_query, $aliases)) {
            return;
        }
    }
    // now export the triggers (needs to be done after the data because
    // triggers can modify already imported tables)
    if (isset($GLOBALS['sql_create_trigger']) && ($whatStrucOrData == 'structure' || $whatStrucOrData == 'structure_and_data')) {
        if (!$export_plugin->exportStructure($db, $table, $crlf, $err_url, 'triggers', $export_type, $do_relation, $do_comments, $do_mime, $do_dates, $aliases)) {
            return;
        }
    }
    if (!$export_plugin->exportDBFooter($db)) {
        return;
    }
    if (isset($GLOBALS['sql_metadata'])) {
        // Types of metadata to export.
        // In the future these can be allowed to be selected by the user
        $metadataTypes = PMA_getMetadataTypesToExport();
        $export_plugin->exportMetadata($db, $table, $metadataTypes);
    }
}
开发者ID:wp-cloud,项目名称:phpmyadmin,代码行数:89,代码来源:export.lib.php

示例9: _getMasterTable

 /**
  * Provides the main table to form the LEFT JOIN clause
  *
  * @param array $search_tables        Tables involved in the search
  * @param array $search_columns       Columns involved in the search
  * @param array $where_clause_columns Columns having criteria where clause
  * @param array $where_clause_tables  Tables having criteria where clause
  *
  * @return string table name
  */
 private function _getMasterTable($search_tables, $search_columns, $where_clause_columns, $where_clause_tables)
 {
     if (count($where_clause_tables) == 1) {
         // If there is exactly one column that has a decent where-clause
         // we will just use this
         $master = key($where_clause_tables);
         return $master;
     }
     // Now let's find out which of the tables has an index
     // (When the control user is the same as the normal user
     // because he is using one of his databases as pmadb,
     // the last db selected is not always the one where we need to work)
     $candidate_columns = $this->_getLeftJoinColumnCandidates($search_tables, $search_columns, $where_clause_columns);
     // Generally, we need to display all the rows of foreign (referenced)
     // table, whether they have any matching row in child table or not.
     // So we select candidate tables which are foreign tables.
     $foreign_tables = array();
     foreach ($candidate_columns as $one_table) {
         $foreigners = PMA_getForeigners($this->_db, $one_table);
         foreach ($foreigners as $key => $foreigner) {
             if ($key != 'foreign_keys_data') {
                 if (in_array($foreigner['foreign_table'], $candidate_columns)) {
                     $foreign_tables[$foreigner['foreign_table']] = $foreigner['foreign_table'];
                 }
                 continue;
             }
             foreach ($foreigner as $one_key) {
                 if (in_array($one_key['ref_table_name'], $candidate_columns)) {
                     $foreign_tables[$one_key['ref_table_name']] = $one_key['ref_table_name'];
                 }
             }
         }
     }
     if (count($foreign_tables)) {
         $candidate_columns = $foreign_tables;
     }
     // If our array of candidates has more than one member we'll just
     // find the smallest table.
     // Of course the actual query would be faster if we check for
     // the Criteria which gives the smallest result set in its table,
     // but it would take too much time to check this
     if (!(count($candidate_columns) > 1)) {
         // Only one single candidate
         return reset($candidate_columns);
     }
     // Of course we only want to check each table once
     $checked_tables = $candidate_columns;
     $tsize = array();
     $csize = array();
     foreach ($candidate_columns as $table) {
         if ($checked_tables[$table] != 1) {
             $_table = new Table($table, $this->_db);
             $tsize[$table] = $_table->countRecords();
             $checked_tables[$table] = 1;
         }
         $csize[$table] = $tsize[$table];
     }
     // Return largest table
     return array_search(max($csize), $csize);
 }
开发者ID:rclakmal,项目名称:phpmyadmin,代码行数:70,代码来源:DbQbe.php

示例10: PMA_saveDisplayField

/**
 * Saves the display field for a table.
 *
 * @param string $db    database name
 * @param string $table table name
 * @param string $field display field name
 *
 * @return boolean
 */
function PMA_saveDisplayField($db, $table, $field)
{
    $cfgRelation = PMA_getRelationsParam();
    if (!$cfgRelation['displaywork']) {
        return false;
    }
    $disp = PMA_getDisplayField($db, $table);
    if ($disp && $disp === $field) {
        $field = '';
    }
    $upd_query = new Table($table, $db, $GLOBALS['dbi']);
    $upd_query->updateDisplayField($disp, $field, $cfgRelation);
    return true;
}
开发者ID:itgsod-philip-skalander,项目名称:phpmyadmin,代码行数:23,代码来源:pmd_common.php

示例11: array

        $transformation_types = array("input_transformation", "transformation");
        foreach ($mime_map as $transformation) {
            $column_name = $transformation['column_name'];
            foreach ($transformation_types as $type) {
                $file = PMA_securePath($transformation[$type]);
                $extra_data = PMA_transformEditedValues($db, $table, $transformation, $edited_values, $file, $column_name, $extra_data, $type);
            }
        }
        // end of loop for each $mime_map
    }
    // Need to check the inline edited value can be truncated by MySQL
    // without informing while saving
    $column_name = $_REQUEST['fields_name']['multi_edit'][0][0];
    PMA_verifyWhetherValueCanBeTruncatedAndAppendExtraData($db, $table, $column_name, $extra_data);
    /**Get the total row count of the table*/
    $_table = new Table($_REQUEST['table'], $_REQUEST['db']);
    $extra_data['row_count'] = $_table->countRecords();
    $extra_data['sql_query'] = PMA\libraries\Util::getMessage($message, $GLOBALS['display_query']);
    $response = PMA\libraries\Response::getInstance();
    $response->setRequestStatus($message->isSuccess());
    $response->addJSON('message', $message);
    $response->addJSON($extra_data);
    exit;
}
if (!empty($return_to_sql_query)) {
    $disp_query = $GLOBALS['sql_query'];
    $disp_message = $message;
    unset($message);
    $GLOBALS['sql_query'] = $return_to_sql_query;
}
$scripts->addFile('tbl_change.js');
开发者ID:phpmyadmin,项目名称:phpmyadmin,代码行数:31,代码来源:tbl_replace.php

示例12: PMA_buildSQL


//.........这里部分代码省略.........
                    }
                    /* Don't put quotes around NULL fields */
                    if (!strcmp($tables[$i][ROWS][$j][$k], 'NULL')) {
                        $is_varchar = false;
                    }
                    $tempSQLStr .= $is_varchar ? "'" : "";
                    $tempSQLStr .= PMA\libraries\Util::sqlAddSlashes((string) $tables[$i][ROWS][$j][$k]);
                    $tempSQLStr .= $is_varchar ? "'" : "";
                }
                if ($k != $num_cols - 1) {
                    $tempSQLStr .= ", ";
                }
                if ($col_count == $num_cols - 1) {
                    $col_count = 0;
                } else {
                    $col_count++;
                }
                /* Delete the cell after we are done with it */
                unset($tables[$i][ROWS][$j][$k]);
            }
            $tempSQLStr .= ")";
            if ($j != $num_rows - 1) {
                $tempSQLStr .= ",\n ";
            }
            $col_count = 0;
            /* Delete the row after we are done with it */
            unset($tables[$i][ROWS][$j]);
        }
        $tempSQLStr .= ";";
        /**
         * Each SQL statement is executed immediately
         * after it is formed so that we don't have
         * to store them in a (possibly large) buffer
         */
        PMA_importRunQuery($tempSQLStr, $tempSQLStr);
    }
    /* No longer needed */
    unset($tempSQLStr);
    /**
     * A work in progress
     */
    /* Add the viewable structures from $additional_sql
     * to $tables so they are also displayed
     */
    $view_pattern = '@VIEW `[^`]+`\\.`([^`]+)@';
    $table_pattern = '@CREATE TABLE IF NOT EXISTS `([^`]+)`@';
    /* Check a third pattern to make sure its not a "USE `db_name`;" statement */
    $regs = array();
    $inTables = false;
    $additional_sql_len = count($additional_sql);
    for ($i = 0; $i < $additional_sql_len; ++$i) {
        preg_match($view_pattern, $additional_sql[$i], $regs);
        if (count($regs) == 0) {
            preg_match($table_pattern, $additional_sql[$i], $regs);
        }
        if (count($regs)) {
            for ($n = 0; $n < $num_tables; ++$n) {
                if (!strcmp($regs[1], $tables[$n][TBL_NAME])) {
                    $inTables = true;
                    break;
                }
            }
            if (!$inTables) {
                $tables[] = array(TBL_NAME => $regs[1]);
            }
        }
        /* Reset the array */
        $regs = array();
        $inTables = false;
    }
    $params = array('db' => (string) $db_name);
    $db_url = 'db_structure.php' . PMA_URL_getCommon($params);
    $db_ops_url = 'db_operations.php' . PMA_URL_getCommon($params);
    $message = '<br /><br />';
    $message .= '<strong>' . __('The following structures have either been created or altered. Here you can:') . '</strong><br />';
    $message .= '<ul><li>' . __("View a structure's contents by clicking on its name.") . '</li>';
    $message .= '<li>' . __('Change any of its settings by clicking the corresponding "Options" link.') . '</li>';
    $message .= '<li>' . __('Edit structure by following the "Structure" link.') . '</li>';
    $message .= sprintf('<br /><li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __('Options') . '</a>)</li>', $db_url, sprintf(__('Go to database: %s'), htmlspecialchars(PMA\libraries\Util::backquote($db_name))), htmlspecialchars($db_name), $db_ops_url, sprintf(__('Edit settings for %s'), htmlspecialchars(PMA\libraries\Util::backquote($db_name))));
    $message .= '<ul>';
    unset($params);
    $num_tables = count($tables);
    for ($i = 0; $i < $num_tables; ++$i) {
        $params = array('db' => (string) $db_name, 'table' => (string) $tables[$i][TBL_NAME]);
        $tbl_url = 'sql.php' . PMA_URL_getCommon($params);
        $tbl_struct_url = 'tbl_structure.php' . PMA_URL_getCommon($params);
        $tbl_ops_url = 'tbl_operations.php' . PMA_URL_getCommon($params);
        unset($params);
        $_table = new Table($tables[$i][TBL_NAME], $db_name);
        if (!$_table->isView()) {
            $message .= sprintf('<li><a href="%s" title="%s">%s</a> (<a href="%s" title="%s">' . __('Structure') . '</a>) (<a href="%s" title="%s">' . __('Options') . '</a>)</li>', $tbl_url, sprintf(__('Go to table: %s'), htmlspecialchars(PMA\libraries\Util::backquote($tables[$i][TBL_NAME]))), htmlspecialchars($tables[$i][TBL_NAME]), $tbl_struct_url, sprintf(__('Structure of %s'), htmlspecialchars(PMA\libraries\Util::backquote($tables[$i][TBL_NAME]))), $tbl_ops_url, sprintf(__('Edit settings for %s'), htmlspecialchars(PMA\libraries\Util::backquote($tables[$i][TBL_NAME]))));
        } else {
            $message .= sprintf('<li><a href="%s" title="%s">%s</a></li>', $tbl_url, sprintf(__('Go to view: %s'), htmlspecialchars(PMA\libraries\Util::backquote($tables[$i][TBL_NAME]))), htmlspecialchars($tables[$i][TBL_NAME]));
        }
    }
    $message .= '</ul></ul>';
    global $import_notice;
    $import_notice = $message;
    unset($tables);
}
开发者ID:netroby,项目名称:phpmyadmin,代码行数:101,代码来源:import.lib.php

示例13: array

             $columnMeta['Default'] = $columnMeta['DefaultValue'];
             break;
         case 'NULL':
         case 'CURRENT_TIMESTAMP':
             $columnMeta['Default'] = $columnMeta['DefaultType'];
             break;
     }
     $length = Util\get($_REQUEST, "field_length.{$columnNumber}", $length);
     $submit_attribute = Util\get($_REQUEST, "field_attribute.{$columnNumber}", false);
     $comments_map[$columnMeta['Field']] = Util\get($_REQUEST, "field_comments.{$columnNumber}");
     $mime_map[$columnMeta['Field']] = array_merge($mime_map[$columnMeta['Field']], array('mimetype' => Util\get($_REQUEST, "field_mimetype.{${$columnNumber}}"), 'transformation' => Util\get($_REQUEST, "field_transformation.{${$columnNumber}}"), 'transformation_options' => Util\get($_REQUEST, "field_transformation_options.{${$columnNumber}}")));
 } elseif (isset($fields_meta[$columnNumber])) {
     $columnMeta = $fields_meta[$columnNumber];
     $virtual = array('VIRTUAL', 'PERSISTENT', 'VIRTUAL GENERATED', 'STORED GENERATED');
     if (in_array($columnMeta['Extra'], $virtual)) {
         $tableObj = new Table($GLOBALS['table'], $GLOBALS['db']);
         $expressions = $tableObj->getColumnGenerationExpression($columnMeta['Field']);
         $columnMeta['Expression'] = $expressions[$columnMeta['Field']];
     }
     switch ($columnMeta['Default']) {
         case null:
             if (is_null($columnMeta['Default'])) {
                 // null
                 if ($columnMeta['Null'] == 'YES') {
                     $columnMeta['DefaultType'] = 'NULL';
                     $columnMeta['DefaultValue'] = '';
                 } else {
                     $columnMeta['DefaultType'] = 'NONE';
                     $columnMeta['DefaultValue'] = '';
                 }
             } else {
开发者ID:pboutin44,项目名称:maintest,代码行数:31,代码来源:tbl_columns_definition_form.inc.php

示例14: 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\libraries\Util::backquote($cfgRelation['db']) . '.' . PMA\libraries\Util::backquote($cfgRelation['relation']) . '
            WHERE `master_db`    = \'' . PMA\libraries\Util::sqlAddSlashes($db) . '\'
                AND `master_table` = \'' . PMA\libraries\Util::sqlAddSlashes($table) . '\' ';
        if (mb_strlen($column)) {
            $rel_query .= ' AND `master_field` = ' . '\'' . PMA\libraries\Util::sqlAddSlashes($column) . '\'';
        }
        $foreign = $GLOBALS['dbi']->fetchResult($rel_query, 'master_field', null, $GLOBALS['controllink']);
    }
    if (($source == 'both' || $source == 'foreign') && mb_strlen($table)) {
        $tableObj = new 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 tables
     */
    $isInformationSchema = mb_strtolower($db) == 'information_schema';
    $isMysql = mb_strtolower($db) == 'mysql';
    if (($isInformationSchema || $isMysql) && ($source == 'internal' || $source == 'both')) {
        if ($isInformationSchema) {
            $relations_key = 'information_schema_relations';
            include_once './libraries/information_schema_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:iShareLife,项目名称:phpmyadmin,代码行数:66,代码来源:relation.lib.php

示例15: updateColumns

 /**
  * Update the table's structure based on $_REQUEST
  *
  * @return boolean $regenerate              true if error occurred
  *
  */
 protected function updateColumns()
 {
     $err_url = 'tbl_structure.php' . PMA_URL_getCommon(array('db' => $this->db, 'table' => $this->table));
     $regenerate = false;
     $field_cnt = count($_REQUEST['field_name']);
     $changes = array();
     $adjust_privileges = array();
     for ($i = 0; $i < $field_cnt; $i++) {
         if (!$this->columnNeedsAlterTable($i)) {
             continue;
         }
         $changes[] = 'CHANGE ' . Table::generateAlter(Util_lib\get($_REQUEST, "field_orig.{$i}", ''), $_REQUEST['field_name'][$i], $_REQUEST['field_type'][$i], $_REQUEST['field_length'][$i], $_REQUEST['field_attribute'][$i], Util_lib\get($_REQUEST, "field_collation.{$i}", ''), Util_lib\get($_REQUEST, "field_null.{$i}", 'NOT NULL'), $_REQUEST['field_default_type'][$i], $_REQUEST['field_default_value'][$i], Util_lib\get($_REQUEST, "field_extra.{$i}", false), Util_lib\get($_REQUEST, "field_comments.{$i}", ''), Util_lib\get($_REQUEST, "field_virtuality.{$i}", ''), Util_lib\get($_REQUEST, "field_expression.{$i}", ''), Util_lib\get($_REQUEST, "field_move_to.{$i}", ''));
         // find the remembered sort expression
         $sorted_col = $this->table_obj->getUiProp(Table::PROP_SORTED_COLUMN);
         // if the old column name is part of the remembered sort expression
         if (mb_strpos($sorted_col, Util::backquote($_REQUEST['field_orig'][$i])) !== false) {
             // delete the whole remembered sort expression
             $this->table_obj->removeUiProp(Table::PROP_SORTED_COLUMN);
         }
         if (isset($_REQUEST['field_adjust_privileges'][$i]) && !empty($_REQUEST['field_adjust_privileges'][$i]) && $_REQUEST['field_orig'][$i] != $_REQUEST['field_name'][$i]) {
             $adjust_privileges[$_REQUEST['field_orig'][$i]] = $_REQUEST['field_name'][$i];
         }
     }
     // end for
     if (count($changes) > 0 || isset($_REQUEST['preview_sql'])) {
         // Builds the primary keys statements and updates the table
         $key_query = '';
         /**
          * this is a little bit more complex
          *
          * @todo if someone selects A_I when altering a column we need to check:
          *  - no other column with A_I
          *  - the column has an index, if not create one
          *
          */
         // To allow replication, we first select the db to use
         // and then run queries on this db.
         if (!$this->dbi->selectDb($this->db)) {
             Util::mysqlDie($this->dbi->getError(), 'USE ' . Util::backquote($this->db) . ';', false, $err_url);
         }
         $sql_query = 'ALTER TABLE ' . Util::backquote($this->table) . ' ';
         $sql_query .= implode(', ', $changes) . $key_query;
         $sql_query .= ';';
         // If there is a request for SQL previewing.
         if (isset($_REQUEST['preview_sql'])) {
             PMA_previewSQL(count($changes) > 0 ? $sql_query : '');
         }
         $columns_with_index = $this->dbi->getTable($this->db, $this->table)->getColumnsWithIndex(PMA_Index::PRIMARY | PMA_Index::UNIQUE | PMA_Index::INDEX | PMA_Index::SPATIAL | PMA_Index::FULLTEXT);
         $changedToBlob = array();
         // While changing the Column Collation
         // First change to BLOB
         for ($i = 0; $i < $field_cnt; $i++) {
             if (isset($_REQUEST['field_collation'][$i]) && isset($_REQUEST['field_collation_orig'][$i]) && $_REQUEST['field_collation'][$i] !== $_REQUEST['field_collation_orig'][$i] && !in_array($_REQUEST['field_orig'][$i], $columns_with_index)) {
                 $secondary_query = 'ALTER TABLE ' . Util::backquote($this->table) . ' CHANGE ' . Util::backquote($_REQUEST['field_orig'][$i]) . ' ' . Util::backquote($_REQUEST['field_orig'][$i]) . ' BLOB;';
                 $this->dbi->query($secondary_query);
                 $changedToBlob[$i] = true;
             } else {
                 $changedToBlob[$i] = false;
             }
         }
         // Then make the requested changes
         $result = $this->dbi->tryQuery($sql_query);
         if ($result !== false) {
             $changed_privileges = $this->adjustColumnPrivileges($adjust_privileges);
             if ($changed_privileges) {
                 $message = Message::success(__('Table %1$s has been altered successfully. Privileges ' . 'have been adjusted.'));
             } else {
                 $message = Message::success(__('Table %1$s has been altered successfully.'));
             }
             $message->addParam($this->table);
             $this->response->addHTML(Util::getMessage($message, $sql_query, 'success'));
         } else {
             // An error happened while inserting/updating a table definition
             // Save the Original Error
             $orig_error = $this->dbi->getError();
             $changes_revert = array();
             // Change back to Original Collation and data type
             for ($i = 0; $i < $field_cnt; $i++) {
                 if ($changedToBlob[$i]) {
                     $changes_revert[] = 'CHANGE ' . Table::generateAlter(Util_lib\get($_REQUEST, "field_orig.{$i}", ''), $_REQUEST['field_name'][$i], $_REQUEST['field_type_orig'][$i], $_REQUEST['field_length_orig'][$i], $_REQUEST['field_attribute_orig'][$i], Util_lib\get($_REQUEST, "field_collation_orig.{$i}", ''), Util_lib\get($_REQUEST, "field_null_orig.{$i}", 'NOT NULL'), $_REQUEST['field_default_type_orig'][$i], $_REQUEST['field_default_value_orig'][$i], Util_lib\get($_REQUEST, "field_extra_orig.{$i}", false), Util_lib\get($_REQUEST, "field_comments_orig.{$i}", ''), Util_lib\get($_REQUEST, "field_virtuality_orig.{$i}", ''), Util_lib\get($_REQUEST, "field_expression_orig.{$i}", ''), Util_lib\get($_REQUEST, "field_move_to_orig.{$i}", ''));
                 }
             }
             $revert_query = 'ALTER TABLE ' . Util::backquote($this->table) . ' ';
             $revert_query .= implode(', ', $changes_revert) . '';
             $revert_query .= ';';
             // Column reverted back to original
             $this->dbi->query($revert_query);
             $this->response->setRequestStatus(false);
             $this->response->addJSON('message', Message::rawError(__('Query error') . ':<br />' . $orig_error));
             $regenerate = true;
         }
     }
     // update field names in relation
     if (isset($_REQUEST['field_orig']) && is_array($_REQUEST['field_orig'])) {
//.........这里部分代码省略.........
开发者ID:Gemorroj,项目名称:phpmyadmin,代码行数:101,代码来源:TableStructureController.php


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