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


PHP PMA_Table::isView方法代码示例

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


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

示例1: _setMessageInformation

 /**
  * Set the content need to be show in message
  *
  * @param string  $sorted_column_message the message for sorted column
  * @param string  $limit_clause          the limit clause of 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 PMA_Message $message an object of PMA_Message
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _setMessageInformation($sorted_column_message, $limit_clause, $total, $pos_next, $pre_count, $after_count)
 {
     $unlim_num_rows = $this->__get('_unlim_num_rows');
     // To use in isset()
     if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
         $selectstring = ', ' . $unlim_num_rows . ' ' . __('in query');
     } else {
         $selectstring = '';
     }
     if (!empty($limit_clause)) {
         $limit_data = $this->getCommonFunctions()->analyzeLimitClause($limit_clause);
         $first_shown_rec = $limit_data['start'];
         if ($limit_data['length'] < $total) {
             $last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1;
         } else {
             $last_shown_rec = $limit_data['start'] + $total - 1;
         }
     } elseif ($_SESSION['tmp_user_values']['max_rows'] == self::ALL_ROWS || $pos_next > $total) {
         $first_shown_rec = $_SESSION['tmp_user_values']['pos'];
         $last_shown_rec = $total - 1;
     } else {
         $first_shown_rec = $_SESSION['tmp_user_values']['pos'];
         $last_shown_rec = $pos_next - 1;
     }
     if (PMA_Table::isView($this->__get('_db'), $this->__get('_table')) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
         $message = PMA_Message::notice(__('This view has at least this number of rows. ' . 'Please refer to %sdocumentation%s.'));
         $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
         $message->addParam('[/a]');
         $message_view_warning = $this->getCommonFunctions()->showHint($message);
     } else {
         $message_view_warning = false;
     }
     $message = PMA_Message::success(__('Showing rows'));
     $message->addMessage($first_shown_rec);
     if ($message_view_warning) {
         $message->addMessage('...', ' - ');
         $message->addMessage($message_view_warning);
         $message->addMessage('(');
     } else {
         $message->addMessage($last_shown_rec, ' - ');
         $message->addMessage(' (');
         $message->addMessage($pre_count . $this->getCommonFunctions()->formatNumber($total, 0));
         $message->addString(__('total'));
         if (!empty($after_count)) {
             $message->addMessage($after_count);
         }
         $message->addMessage($selectstring, '');
         $message->addMessage(', ', '');
     }
     $messagge_qt = PMA_Message::notice(__('Query took %01.4f sec') . ')');
     $messagge_qt->addParam($this->__get('_querytime'));
     $message->addMessage($messagge_qt, '');
     if (!is_null($sorted_column_message)) {
         $message->addMessage($sorted_column_message, '');
     }
     return $message;
 }
开发者ID:rajatsinghal,项目名称:phpmyadmin,代码行数:75,代码来源:DisplayResults.class.php

示例2: countRecords

 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the current database name
  * @param   string   the current table name
  * @param   boolean  whether to force an exact count
  *
  * @return  mixed    the number of records if "retain" param is true,
  *                   otherwise true
  *
  * @access  public
  */
 public static function countRecords($db, $table, $force_exact = false, $is_view = null)
 {
     if (isset(PMA_Table::$cache[$db][$table]['ExactRows'])) {
         $row_count = PMA_Table::$cache[$db][$table]['ExactRows'];
     } else {
         $row_count = false;
         if (null === $is_view) {
             $is_view = PMA_Table::isView($db, $table);
         }
         if (!$force_exact) {
             if (!isset(PMA_Table::$cache[$db][$table]['Rows']) && !$is_view) {
                 PMA_Table::$cache[$db][$table] = PMA_DBI_fetch_single_row('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\'');
             }
             $row_count = PMA_Table::$cache[$db][$table]['Rows'];
         }
         // for a VIEW, $row_count is always false at this point
         if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
             if (!$is_view) {
                 $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
             } else {
                 // For complex views, even trying to get a partial record
                 // count could bring down a server, so we offer an
                 // alternative: setting MaxExactCountViews to 0 will bypass
                 // completely the record counting for views
                 if ($GLOBALS['cfg']['MaxExactCountViews'] == 0) {
                     $row_count = 0;
                 } else {
                     // Counting all rows of a VIEW could be too long, so use
                     // a LIMIT clause.
                     // Use try_query because it can fail (when a VIEW is
                     // based on a table that no longer exists)
                     $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCountViews'], null, PMA_DBI_QUERY_STORE);
                     if (!PMA_DBI_getError()) {
                         $row_count = PMA_DBI_num_rows($result);
                         PMA_DBI_free_result($result);
                     }
                 }
             }
             PMA_Table::$cache[$db][$table]['ExactRows'] = $row_count;
         }
     }
     return $row_count;
 }
开发者ID:kolbermoorer,项目名称:edugame,代码行数:58,代码来源:Table.class.php

示例3: _setMessageInformation

 /**
  * Set the content that needs to be shown in message
  *
  * @param string  $sorted_column_message the message for sorted column
  * @param string  $limit_clause          the limit clause of 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 PMA_Message $message an object of PMA_Message
  *
  * @access  private
  *
  * @see     getTable()
  */
 private function _setMessageInformation($sorted_column_message, $limit_clause, $total, $pos_next, $pre_count, $after_count)
 {
     $unlim_num_rows = $this->__get('unlim_num_rows');
     // To use in isset()
     if (!empty($limit_clause)) {
         $limit_data = PMA_Util::analyzeLimitClause($limit_clause);
         $first_shown_rec = $limit_data['start'];
         if ($limit_data['length'] < $total) {
             $last_shown_rec = $limit_data['start'] + $limit_data['length'] - 1;
         } else {
             $last_shown_rec = $limit_data['start'] + $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;
     }
     if (PMA_Table::isView($this->__get('db'), $this->__get('table')) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
         $message = PMA_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 = PMA_Util::showHint($message);
     } else {
         $message_view_warning = false;
     }
     $message = PMA_Message::success(__('Showing rows %1s - %2s'));
     $message->addParam($first_shown_rec);
     if ($message_view_warning) {
         $message->addParam('... ' . $message_view_warning, false);
     } else {
         $message->addParam($last_shown_rec);
     }
     $message->addMessage('(');
     if (!$message_view_warning) {
         if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
             $message_total = PMA_Message::notice($pre_count . __('%1$d total, %2$d in query'));
             $message_total->addParam($total);
             $message_total->addParam($unlim_num_rows);
         } else {
             $message_total = PMA_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 = PMA_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:nkeat12,项目名称:dv,代码行数:76,代码来源:DisplayResults.class.php

示例4: PMA_displayTable


//.........这里部分代码省略.........
        // (this might be a multi-table query)
        $sorted_column_index = false;
        foreach ($fields_meta as $key => $meta) {
            if ($meta->table == $sort_table && $meta->name == $sort_column) {
                $sorted_column_index = $key;
                break;
            }
        }
        if ($sorted_column_index !== false) {
            // fetch first row of the result set
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_first_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // fetch last row of the result set
            PMA_DBI_data_seek($dt_result, $num_rows - 1);
            $row = PMA_DBI_fetch_row($dt_result);
            $column_for_last_row = substr($row[$sorted_column_index], 0, $GLOBALS['cfg']['LimitChars']);
            // reset to first row for the loop in PMA_displayTableBody()
            PMA_DBI_data_seek($dt_result, 0);
            // we could also use here $sort_expression_nodirection
            $sorted_column_message = ' [' . htmlspecialchars($sort_column) . ': <strong>' . htmlspecialchars($column_for_first_row) . ' - ' . htmlspecialchars($column_for_last_row) . '</strong>]';
            unset($row, $column_for_first_row, $column_for_last_row);
        }
        unset($sorted_column_index, $sort_table, $sort_column);
    }
    // 2. ----- Displays the top of the page -----
    // 2.1 Displays a messages with position informations
    if ($is_display['nav_bar'] == '1' && isset($pos_next)) {
        if (isset($unlim_num_rows) && $unlim_num_rows != $total) {
            $selectstring = ', ' . $unlim_num_rows . ' ' . $GLOBALS['strSelectNumRows'];
        } else {
            $selectstring = '';
        }
        $last_shown_rec = $_SESSION['tmp_user_values']['max_rows'] == 'all' || $pos_next > $total ? $total - 1 : $pos_next - 1;
        if (PMA_Table::isView($db, $table) && $total == $GLOBALS['cfg']['MaxExactCountViews']) {
            $message = PMA_Message::notice('strViewHasAtLeast');
            $message->addParam('[a@./Documentation.html#cfg_MaxExactCount@_blank]');
            $message->addParam('[/a]');
            $message_view_warning = PMA_showHint($message);
        } else {
            $message_view_warning = false;
        }
        $message = PMA_Message::success('strShowingRecords');
        $message->addMessage($_SESSION['tmp_user_values']['pos']);
        if ($message_view_warning) {
            $message->addMessage('...', ' - ');
            $message->addMessage($message_view_warning);
            $message->addMessage('(');
        } else {
            $message->addMessage($last_shown_rec, ' - ');
            $message->addMessage($pre_count . PMA_formatNumber($total, 0) . $after_count, ' (');
            $message->addString('strTotal');
            $message->addMessage($selectstring, '');
            $message->addMessage(', ', '');
        }
        $messagge_qt = PMA_Message::notice('strQueryTime');
        $messagge_qt->addParam($GLOBALS['querytime']);
        $message->addMessage($messagge_qt, '');
        $message->addMessage(')', '');
        $message->addMessage(isset($sorted_column_message) ? $sorted_column_message : '', '');
        PMA_showMessage($message, $sql_query, 'success');
    } elseif (!isset($GLOBALS['printview']) || $GLOBALS['printview'] != '1') {
        PMA_showMessage($GLOBALS['strSuccess'], $sql_query, 'success');
    }
    // 2.3 Displays the navigation bars
    if (!strlen($table)) {
        if (isset($analyzed_sql[0]['query_type']) && $analyzed_sql[0]['query_type'] == 'SELECT') {
开发者ID:kolbermoorer,项目名称:edugame,代码行数:67,代码来源:display_tbl.lib.php

示例5: PMA_getUniqueCondition

/**
 * Function to generate unique condition for specified row.
 *
 * @param resource $handle       current query result
 * @param integer  $fields_cnt   number of fields
 * @param array    $fields_meta  meta information about fields
 * @param array    $row          current row
 * @param boolean  $force_unique generate condition only on pk or unique
 *
 * @access  public
 *
 * @return  array     the calculated condition and whether condition is unique
 */
function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique = false)
{
    $primary_key = '';
    $unique_key = '';
    $nonprimary_condition = '';
    $preferred_condition = '';
    $primary_key_array = array();
    $unique_key_array = array();
    $nonprimary_condition_array = array();
    $condition_array = array();
    for ($i = 0; $i < $fields_cnt; ++$i) {
        $condition = '';
        $con_key = '';
        $con_val = '';
        $field_flags = PMA_DBI_field_flags($handle, $i);
        $meta = $fields_meta[$i];
        // do not use a column alias in a condition
        if (!isset($meta->orgname) || !strlen($meta->orgname)) {
            $meta->orgname = $meta->name;
            if (isset($GLOBALS['analyzed_sql'][0]['select_expr']) && is_array($GLOBALS['analyzed_sql'][0]['select_expr'])) {
                foreach ($GLOBALS['analyzed_sql'][0]['select_expr'] as $select_expr) {
                    // need (string) === (string)
                    // '' !== 0 but '' == 0
                    if ((string) $select_expr['alias'] === (string) $meta->name) {
                        $meta->orgname = $select_expr['column'];
                        break;
                    }
                    // end if
                }
                // end foreach
            }
        }
        // Do not use a table alias in a condition.
        // Test case is:
        // select * from galerie x WHERE
        //(select count(*) from galerie y where y.datum=x.datum)>1
        //
        // But orgtable is present only with mysqli extension so the
        // fix is only for mysqli.
        // Also, do not use the original table name if we are dealing with
        // a view because this view might be updatable.
        // (The isView() verification should not be costly in most cases
        // because there is some caching in the function).
        if (isset($meta->orgtable) && $meta->table != $meta->orgtable && !PMA_Table::isView($GLOBALS['db'], $meta->table)) {
            $meta->table = $meta->orgtable;
        }
        // to fix the bug where float fields (primary or not)
        // can't be matched because of the imprecision of
        // floating comparison, use CONCAT
        // (also, the syntax "CONCAT(field) IS NULL"
        // that we need on the next "if" will work)
        if ($meta->type == 'real') {
            $con_key = 'CONCAT(' . PMA_backquote($meta->table) . '.' . PMA_backquote($meta->orgname) . ')';
        } else {
            $con_key = PMA_backquote($meta->table) . '.' . PMA_backquote($meta->orgname);
        }
        // end if... else...
        $condition = ' ' . $con_key . ' ';
        if (!isset($row[$i]) || is_null($row[$i])) {
            $con_val = 'IS NULL';
        } else {
            // timestamp is numeric on some MySQL 4.1
            // for real we use CONCAT above and it should compare to string
            if ($meta->numeric && $meta->type != 'timestamp' && $meta->type != 'real') {
                $con_val = '= ' . $row[$i];
            } elseif (($meta->type == 'blob' || $meta->type == 'string') && stristr($field_flags, 'BINARY') && !empty($row[$i])) {
                // do not waste memory building a too big condition
                if (strlen($row[$i]) < 1000) {
                    // use a CAST if possible, to avoid problems
                    // if the field contains wildcard characters % or _
                    $con_val = '= CAST(0x' . bin2hex($row[$i]) . ' AS BINARY)';
                } else {
                    // this blob won't be part of the final condition
                    $con_val = null;
                }
            } elseif (in_array($meta->type, PMA_getGISDatatypes()) && !empty($row[$i])) {
                // do not build a too big condition
                if (strlen($row[$i]) < 5000) {
                    $condition .= '=0x' . bin2hex($row[$i]) . ' AND';
                } else {
                    $condition = '';
                }
            } elseif ($meta->type == 'bit') {
                $con_val = "= b'" . PMA_printable_bit_value($row[$i], $meta->length) . "'";
            } else {
                $con_val = '= \'' . PMA_sqlAddSlashes($row[$i], false, true) . '\'';
            }
//.........这里部分代码省略.........
开发者ID:AmberWish,项目名称:laba_web,代码行数:101,代码来源:common.lib.php

示例6: PMA_createTrackingForMultipleTables

/**
 * Create tracking version for multiple tables
 *
 * @param array $selected list of selected tables
 *
 * @return void
 */
function PMA_createTrackingForMultipleTables($selected)
{
    $tracking_set = PMA_getTrackingSet();
    foreach ($selected as $selected_table) {
        PMA_Tracker::createVersion($GLOBALS['db'], $selected_table, $_REQUEST['version'], $tracking_set, PMA_Table::isView($GLOBALS['db'], $selected_table));
    }
}
开发者ID:saisai,项目名称:phpmyadmin,代码行数:14,代码来源:tracking.lib.php

示例7: exportData

 /**
  * Outputs the content of a table in SQL format
  *
  * @param string $db        database name
  * @param string $table     table name
  * @param string $crlf      the end of line sequence
  * @param string $error_url the url to go back in case of error
  * @param string $sql_query SQL query for obtaining data
  *
  * @return bool Whether it succeeded
  */
 public function exportData($db, $table, $crlf, $error_url, $sql_query)
 {
     global $current_row, $sql_backquotes;
     if (isset($GLOBALS['sql_compatibility'])) {
         $compat = $GLOBALS['sql_compatibility'];
     } else {
         $compat = 'NONE';
     }
     $formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_Util::backquoteCompat($table, $compat) : '\'' . $table . '\'';
     // Do not export data for a VIEW
     // (For a VIEW, this is called only when exporting a single VIEW)
     if (PMA_Table::isView($db, $table)) {
         $head = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment('VIEW ' . ' ' . $formatted_table_name) . $this->_exportComment(__('Data') . ': ' . __('None')) . $this->_exportComment() . $this->_possibleCRLF();
         if (!PMA_exportOutputHandler($head)) {
             return false;
         }
         return true;
     }
     // analyze the query to get the true column names, not the aliases
     // (this fixes an undefined index, also if Complete inserts
     //  are used, we did not get the true column name in case of aliases)
     $analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($sql_query));
     $result = PMA_DBI_try_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
     // a possible error: the table has crashed
     $tmp_error = PMA_DBI_getError();
     if ($tmp_error) {
         return PMA_exportOutputHandler($this->_exportComment(__('Error reading data:') . ' (' . $tmp_error . ')'));
     }
     if ($result != false) {
         $fields_cnt = PMA_DBI_num_fields($result);
         // Get field information
         $fields_meta = PMA_DBI_get_fields_meta($result);
         $field_flags = array();
         for ($j = 0; $j < $fields_cnt; $j++) {
             $field_flags[$j] = PMA_DBI_field_flags($result, $j);
         }
         for ($j = 0; $j < $fields_cnt; $j++) {
             if (isset($analyzed_sql[0]['select_expr'][$j]['column'])) {
                 $field_set[$j] = PMA_Util::backquoteCompat($analyzed_sql[0]['select_expr'][$j]['column'], $compat, $sql_backquotes);
             } else {
                 $field_set[$j] = PMA_Util::backquoteCompat($fields_meta[$j]->name, $compat, $sql_backquotes);
             }
         }
         if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
             // update
             $schema_insert = 'UPDATE ';
             if (isset($GLOBALS['sql_ignore'])) {
                 $schema_insert .= 'IGNORE ';
             }
             // avoid EOL blank
             $schema_insert .= PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' SET';
         } else {
             // insert or replace
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'REPLACE') {
                 $sql_command = 'REPLACE';
             } else {
                 $sql_command = 'INSERT';
             }
             // delayed inserts?
             if (isset($GLOBALS['sql_delayed'])) {
                 $insert_delayed = ' DELAYED';
             } else {
                 $insert_delayed = '';
             }
             // insert ignore?
             if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'INSERT' && isset($GLOBALS['sql_ignore'])) {
                 $insert_delayed .= ' IGNORE';
             }
             //truncate table before insert
             if (isset($GLOBALS['sql_truncate']) && $GLOBALS['sql_truncate'] && $sql_command == 'INSERT') {
                 $truncate = 'TRUNCATE TABLE ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ";";
                 $truncatehead = $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('Truncate table before insert') . ' ' . $formatted_table_name) . $this->_exportComment() . $crlf;
                 PMA_exportOutputHandler($truncatehead);
                 PMA_exportOutputHandler($truncate);
             } else {
                 $truncate = '';
             }
             // scheme for inserting fields
             if ($GLOBALS['sql_insert_syntax'] == 'complete' || $GLOBALS['sql_insert_syntax'] == 'both') {
                 $fields = implode(', ', $field_set);
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' (' . $fields . ') VALUES';
             } else {
                 $schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_Util::backquoteCompat($table, $compat, $sql_backquotes) . ' VALUES';
             }
         }
         //\x08\\x09, not required
         $search = array("", "\n", "\r", "");
         $replace = array('\\0', '\\n', '\\r', '\\Z');
         $current_row = 0;
//.........这里部分代码省略.........
开发者ID:fanscky,项目名称:HTPMS,代码行数:101,代码来源:ExportSql.class.php

示例8: testIsView

 /**
  * Test for isView
  *
  * @return void
  */
 public function testIsView()
 {
     $this->assertEquals(false, PMA_Table::isView());
     //validate that it is the same as DBI fetchResult
     $this->assertEquals(true, PMA_Table::isView('PMA', 'PMA_BookMark'));
     $this->assertEquals(false, PMA_Table::isView('PMA', 'PMA_BookMark_2'));
 }
开发者ID:kfjihailong,项目名称:phpMyAdmin,代码行数:12,代码来源:PMA_Table_test.php

示例9: elseif

         }
     }
 } elseif ($export_type == 'database') {
     if (!PMA_exportDBHeader($db)) {
         break;
     }
     if (isset($table_select)) {
         $tmp_select = implode($table_select, '|');
         $tmp_select = '|' . $tmp_select . '|';
     }
     $i = 0;
     $views = array();
     foreach ($tables as $table) {
         // if this is a view, collect it for later; views must be exported after
         // the tables
         if (PMA_Table::isView($db, $table)) {
             $views[] = $table;
             continue;
         }
         $local_query = 'SELECT * FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
         if (isset($tmp_select) && strpos(' ' . $tmp_select, '|' . $table . '|') || !isset($tmp_select)) {
             if (isset($GLOBALS[$what . '_structure'])) {
                 if (!PMA_exportStructure($db, $table, $crlf, $err_url, $do_relation, $do_comments, $do_mime, $do_dates)) {
                     break 2;
                 }
             }
             if (isset($GLOBALS[$what . '_data'])) {
                 if (!PMA_exportData($db, $table, $crlf, $err_url, $local_query)) {
                     break 2;
                 }
             }
开发者ID:BGCX261,项目名称:zhss-svn-to-git,代码行数:31,代码来源:export.php

示例10: countRecords

 /**
  * Counts and returns (or displays) the number of records in a table
  *
  * Revision 13 July 2001: Patch for limiting dump size from
  * vinay@sanisoft.com & girish@sanisoft.com
  *
  * @param   string   the current database name
  * @param   string   the current table name
  * @param   boolean  whether to retain or to displays the result
  * @param   boolean  whether to force an exact count
  *
  * @return  mixed    the number of records if retain is required, true else
  *
  * @access  public
  */
 function countRecords($db, $table, $ret = false, $force_exact = false)
 {
     $row_count = false;
     if (!$force_exact) {
         $row_count = PMA_DBI_fetch_value('SHOW TABLE STATUS FROM ' . PMA_backquote($db) . ' LIKE \'' . PMA_sqlAddslashes($table, true) . '\';', 0, 'Rows');
     }
     $tbl_is_view = PMA_Table::isView($db, $table);
     if (false === $row_count || $row_count < $GLOBALS['cfg']['MaxExactCount']) {
         if (!$tbl_is_view) {
             $row_count = PMA_DBI_fetch_value('SELECT COUNT(*) FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table));
             // since counting all rows of a view could be too long
         } else {
             // try_query because it can fail ( a VIEW was based on
             // a table that no longer exists)
             $result = PMA_DBI_try_query('SELECT 1 FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table) . ' LIMIT ' . $GLOBALS['cfg']['MaxExactCount'], null, PMA_DBI_QUERY_STORE);
             if (!PMA_DBI_getError()) {
                 $row_count = PMA_DBI_num_rows($result);
                 PMA_DBI_free_result($result);
             }
         }
     }
     if ($ret) {
         return $row_count;
     }
     /**
      * @deprecated at the moment nowhere is $return = false used
      */
     // Note: as of PMA 2.8.0, we no longer seem to be using
     // PMA_Table::countRecords() in display mode.
     echo PMA_formatNumber($row_count, 0);
     if ($tbl_is_view) {
         echo '&nbsp;' . sprintf($GLOBALS['strViewMaxExactCount'], $GLOBALS['cfg']['MaxExactCount'], '[a@./Documentation.html#cfg_MaxExactCount@_blank]', '[/a]');
     }
 }
开发者ID:BGCX261,项目名称:zhss-svn-to-git,代码行数:49,代码来源:Table.class.php

示例11: PMA_sendHtmlForColumnDropdownList

/**
 * Function to send html for column dropdown list
 *
 * @return void
 */
function PMA_sendHtmlForColumnDropdownList()
{
    $response = PMA_Response::getInstance();
    $foreignTable = $_REQUEST['foreignTable'];
    $table_obj = new PMA_Table($foreignTable, $_REQUEST['foreignDb']);
    // Since views do not have keys defined on them provide the full list of columns
    if (PMA_Table::isView($_REQUEST['foreignDb'], $foreignTable)) {
        $columnList = $table_obj->getColumns(false, false);
    } else {
        $columnList = $table_obj->getIndexedColumns(false, false);
    }
    $columns = array();
    foreach ($columnList as $column) {
        $columns[] = htmlspecialchars($column);
    }
    $response->addJSON('columns', $columns);
    // @todo should be: $server->db($db)->table($table)->primary()
    $primary = PMA_Index::getPrimary($foreignTable, $_REQUEST['foreignDb']);
    if (false === $primary) {
        return;
    }
    $primarycols = array_keys($primary->getColumns());
    $response->addJSON('primary', $primarycols);
}
开发者ID:1290800466,项目名称:yiyuanduobao,代码行数:29,代码来源:tbl_relation.lib.php

示例12: exportHeader

 /**
  * Outputs export header. It is the first method to be called, so all
  * the required variables are initialized here.
  *
  * @return bool Whether it succeeded
  */
 public function exportHeader()
 {
     $this->initSpecificVariables();
     global $crlf, $cfg, $db;
     $table = $this->_getTable();
     $tables = $this->_getTables();
     $export_struct = isset($GLOBALS['xml_export_functions']) || isset($GLOBALS['xml_export_procedures']) || isset($GLOBALS['xml_export_tables']) || isset($GLOBALS['xml_export_triggers']) || isset($GLOBALS['xml_export_views']);
     $export_data = isset($GLOBALS['xml_export_contents']) ? true : false;
     if ($GLOBALS['output_charset_conversion']) {
         $charset = $GLOBALS['charset_of_file'];
     } else {
         $charset = 'utf-8';
     }
     $head = '<?xml version="1.0" encoding="' . $charset . '"?>' . $crlf . '<!--' . $crlf . '- phpMyAdmin XML Dump' . $crlf . '- version ' . PMA_VERSION . $crlf . '- http://www.phpmyadmin.net' . $crlf . '-' . $crlf . '- ' . __('Host:') . ' ' . $cfg['Server']['host'];
     if (!empty($cfg['Server']['port'])) {
         $head .= ':' . $cfg['Server']['port'];
     }
     $head .= $crlf . '- ' . __('Generation Time:') . ' ' . PMA_Util::localisedDate() . $crlf . '- ' . __('Server version:') . ' ' . PMA_MYSQL_STR_VERSION . $crlf . '- ' . __('PHP Version:') . ' ' . phpversion() . $crlf . '-->' . $crlf . $crlf;
     $head .= '<pma_xml_export version="1.0"' . ($export_struct ? ' xmlns:pma="http://www.phpmyadmin.net/some_doc_url/"' : '') . '>' . $crlf;
     if ($export_struct) {
         if (PMA_DRIZZLE) {
             $result = $GLOBALS['dbi']->fetchResult("SELECT\n                        'utf8' AS DEFAULT_CHARACTER_SET_NAME,\n                        DEFAULT_COLLATION_NAME\n                    FROM data_dictionary.SCHEMAS\n                    WHERE SCHEMA_NAME = '" . PMA_Util::sqlAddSlashes($db) . "'");
         } else {
             $result = $GLOBALS['dbi']->fetchResult('SELECT `DEFAULT_CHARACTER_SET_NAME`, `DEFAULT_COLLATION_NAME`' . ' FROM `information_schema`.`SCHEMATA` WHERE `SCHEMA_NAME`' . ' = \'' . PMA_Util::sqlAddSlashes($db) . '\' LIMIT 1');
         }
         $db_collation = $result[0]['DEFAULT_COLLATION_NAME'];
         $db_charset = $result[0]['DEFAULT_CHARACTER_SET_NAME'];
         $head .= '    <!--' . $crlf;
         $head .= '    - Structure schemas' . $crlf;
         $head .= '    -->' . $crlf;
         $head .= '    <pma:structure_schemas>' . $crlf;
         $head .= '        <pma:database name="' . htmlspecialchars($db) . '" collation="' . $db_collation . '" charset="' . $db_charset . '">' . $crlf;
         if (count($tables) == 0) {
             $tables[] = $table;
         }
         foreach ($tables as $table) {
             // Export tables and views
             $result = $GLOBALS['dbi']->fetchResult('SHOW CREATE TABLE ' . PMA_Util::backquote($db) . '.' . PMA_Util::backquote($table), 0);
             $tbl = $result[$table][1];
             $is_view = PMA_Table::isView($db, $table);
             if ($is_view) {
                 $type = 'view';
             } else {
                 $type = 'table';
             }
             if ($is_view && !isset($GLOBALS['xml_export_views'])) {
                 continue;
             }
             if (!$is_view && !isset($GLOBALS['xml_export_tables'])) {
                 continue;
             }
             $head .= '            <pma:' . $type . ' name="' . $table . '">' . $crlf;
             $tbl = "                " . htmlspecialchars($tbl);
             $tbl = str_replace("\n", "\n                ", $tbl);
             $head .= $tbl . ';' . $crlf;
             $head .= '            </pma:' . $type . '>' . $crlf;
             if (isset($GLOBALS['xml_export_triggers']) && $GLOBALS['xml_export_triggers']) {
                 // Export triggers
                 $triggers = $GLOBALS['dbi']->getTriggers($db, $table);
                 if ($triggers) {
                     foreach ($triggers as $trigger) {
                         $code = $trigger['create'];
                         $head .= '            <pma:trigger name="' . $trigger['name'] . '">' . $crlf;
                         // Do some formatting
                         $code = substr(rtrim($code), 0, -3);
                         $code = "                " . htmlspecialchars($code);
                         $code = str_replace("\n", "\n                ", $code);
                         $head .= $code . $crlf;
                         $head .= '            </pma:trigger>' . $crlf;
                     }
                     unset($trigger);
                     unset($triggers);
                 }
             }
         }
         if (isset($GLOBALS['xml_export_functions']) && $GLOBALS['xml_export_functions']) {
             // Export functions
             $functions = $GLOBALS['dbi']->getProceduresOrFunctions($db, 'FUNCTION');
             if ($functions) {
                 foreach ($functions as $function) {
                     $head .= '            <pma:function name="' . $function . '">' . $crlf;
                     // Do some formatting
                     $sql = $GLOBALS['dbi']->getDefinition($db, 'FUNCTION', $function);
                     $sql = rtrim($sql);
                     $sql = "                " . htmlspecialchars($sql);
                     $sql = str_replace("\n", "\n                ", $sql);
                     $head .= $sql . $crlf;
                     $head .= '            </pma:function>' . $crlf;
                 }
                 unset($function);
                 unset($functions);
             }
         }
         if (isset($GLOBALS['xml_export_procedures']) && $GLOBALS['xml_export_procedures']) {
//.........这里部分代码省略.........
开发者ID:yszar,项目名称:linuxwp,代码行数:101,代码来源:ExportXml.class.php

示例13: moveCopy


//.........这里部分代码省略.........
         if (isset($_POST['sql_auto_increment'])) {
             $GLOBALS['sql_auto_increment'] = $_POST['sql_auto_increment'];
         }
         /**
          * The old structure of the table..
          * @var string $sql_structure
          */
         $sql_structure = $export_sql_plugin->getTableDef($source_db, $source_table, "\n", $err_url, false, false);
         unset($no_constraints_comments);
         // -----------------------------------------------------------------
         // Phase 0: Preparing structures used.
         /**
          * The destination where the table is moved or copied to.
          * @var SqlParser\Components\Expression
          */
         $destination = new SqlParser\Components\Expression($target_db, $target_table, '');
         // Find server's SQL mode so the builder can generate correct
         // queries.
         // One of the options that alters the behaviour is `ANSI_QUOTES`.
         // This is not availabile for Drizzle.
         if (!PMA_DRIZZLE) {
             SqlParser\Context::setMode($GLOBALS['dbi']->fetchValue("SELECT @@sql_mode"));
         }
         // -----------------------------------------------------------------
         // Phase 1: Dropping existent element of the same name (if exists
         // and required).
         if (isset($_REQUEST['drop_if_exists']) && $_REQUEST['drop_if_exists'] == 'true') {
             /**
              * Drop statement used for building the query.
              * @var SqlParser\Statements\DropStatement $statement
              */
             $statement = new SqlParser\Statements\DropStatement();
             $tbl = new PMA_Table($target_db, $target_table);
             $statement->options = new SqlParser\Components\OptionsArray(array($tbl->isView() ? 'VIEW' : 'TABLE', 'IF EXISTS'));
             $statement->fields = array($destination);
             // Building the query.
             $drop_query = $statement->build() . ';';
             // Executing it.
             $GLOBALS['dbi']->query($drop_query);
             $GLOBALS['sql_query'] .= "\n" . $drop_query;
             // If an existing table gets deleted, maintain any entries for
             // the PMA_* tables.
             $maintain_relations = true;
         }
         // -----------------------------------------------------------------
         // Phase 2: Generating the new query of this structure.
         /**
          * The parser responsible for parsing the old queries.
          * @var SqlParser\Parser $parser
          */
         $parser = new SqlParser\Parser($sql_structure);
         if (!empty($parser->statements[0])) {
             /**
              * The CREATE statement of this structure.
              * @var SqlParser\Statements\CreateStatement $statement
              */
             $statement = $parser->statements[0];
             // Changing the destination.
             $statement->name = $destination;
             // Building back the query.
             $sql_structure = $statement->build() . ';';
             // Executing it.
             $GLOBALS['dbi']->query($sql_structure);
             $GLOBALS['sql_query'] .= "\n" . $sql_structure;
         }
         // -----------------------------------------------------------------
开发者ID:TheBlackBloodyUnicorn,项目名称:pico_wanderblog,代码行数:67,代码来源:Table.class.php

示例14: PMA_buildSQL


//.........这里部分代码省略.........
                        $is_varchar = !is_numeric($tables[$i][ROWS][$j][$k]);
                    }
                    /* Don't put quotes around NULL fields */
                    if (!strcmp($tables[$i][ROWS][$j][$k], 'NULL')) {
                        $is_varchar = false;
                    }
                    $tempSQLStr .= $is_varchar ? "'" : "";
                    $tempSQLStr .= PMA_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_Util::backquote($db_name))), htmlspecialchars($db_name), $db_ops_url, sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_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);
        if (!PMA_Table::isView($db_name, $tables[$i][TBL_NAME])) {
            $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_Util::backquote($tables[$i][TBL_NAME]))), htmlspecialchars($tables[$i][TBL_NAME]), $tbl_struct_url, sprintf(__('Structure of %s'), htmlspecialchars(PMA_Util::backquote($tables[$i][TBL_NAME]))), $tbl_ops_url, sprintf(__('Edit settings for %s'), htmlspecialchars(PMA_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_Util::backquote($tables[$i][TBL_NAME]))), htmlspecialchars($tables[$i][TBL_NAME]));
        }
    }
    $message .= '</ul></ul>';
    global $import_notice;
    $import_notice = $message;
    unset($tables);
}
开发者ID:sruthikudaravalli,项目名称:QuickCabs,代码行数:101,代码来源:import.lib.php

示例15: _getTableTabs

 /**
  * Returns the table tabs as an array
  *
  * @return array Data for generating table tabs
  */
 private function _getTableTabs()
 {
     $db_is_system_schema = $GLOBALS['dbi']->isSystemSchema($this->_db);
     $tbl_is_view = PMA_Table::isView($this->_db, $this->_table);
     $is_superuser = $GLOBALS['dbi']->isSuperuser();
     $isCreateOrGrantUser = $GLOBALS['dbi']->isUserType('grant') || $GLOBALS['dbi']->isUserType('create');
     $tabs = array();
     $tabs['browse']['icon'] = 'b_browse.png';
     $tabs['browse']['text'] = __('Browse');
     $tabs['browse']['link'] = 'sql.php';
     $tabs['browse']['args']['pos'] = 0;
     $tabs['structure']['icon'] = 'b_props.png';
     $tabs['structure']['link'] = 'tbl_structure.php';
     $tabs['structure']['text'] = __('Structure');
     $tabs['sql']['icon'] = 'b_sql.png';
     $tabs['sql']['link'] = 'tbl_sql.php';
     $tabs['sql']['text'] = __('SQL');
     $tabs['search']['icon'] = 'b_search.png';
     $tabs['search']['text'] = __('Search');
     $tabs['search']['link'] = 'tbl_select.php';
     $tabs['search']['active'] = in_array(basename($GLOBALS['PMA_PHP_SELF']), array('tbl_select.php', 'tbl_zoom_select.php', 'tbl_find_replace.php'));
     if (!$db_is_system_schema) {
         $tabs['insert']['icon'] = 'b_insrow.png';
         $tabs['insert']['link'] = 'tbl_change.php';
         $tabs['insert']['text'] = __('Insert');
     }
     $tabs['export']['icon'] = 'b_tblexport.png';
     $tabs['export']['link'] = 'tbl_export.php';
     $tabs['export']['args']['single_table'] = 'true';
     $tabs['export']['text'] = __('Export');
     /**
      * Don't display "Import" for views and information_schema
      */
     if (!$tbl_is_view && !$db_is_system_schema) {
         $tabs['import']['icon'] = 'b_tblimport.png';
         $tabs['import']['link'] = 'tbl_import.php';
         $tabs['import']['text'] = __('Import');
     }
     if (($is_superuser || $isCreateOrGrantUser) && !PMA_DRIZZLE && !$db_is_system_schema) {
         $tabs['privileges']['link'] = 'server_privileges.php';
         $tabs['privileges']['args']['checkprivsdb'] = $this->_db;
         $tabs['privileges']['args']['checkprivstable'] = $this->_table;
         // stay on table view
         $tabs['privileges']['args']['viewing_mode'] = 'table';
         $tabs['privileges']['text'] = __('Privileges');
         $tabs['privileges']['icon'] = 's_rights.png';
     }
     /**
      * Don't display "Operations" for views and information_schema
      */
     if (!$tbl_is_view && !$db_is_system_schema) {
         $tabs['operation']['icon'] = 'b_tblops.png';
         $tabs['operation']['link'] = 'tbl_operations.php';
         $tabs['operation']['text'] = __('Operations');
     }
     if (PMA_Tracker::isActive()) {
         $tabs['tracking']['icon'] = 'eye.png';
         $tabs['tracking']['text'] = __('Tracking');
         $tabs['tracking']['link'] = 'tbl_tracking.php';
     }
     if (!$db_is_system_schema && !PMA_DRIZZLE && PMA_Util::currentUserHasPrivilege('TRIGGER', $this->_db, $this->_table) && !$tbl_is_view) {
         $tabs['triggers']['link'] = 'tbl_triggers.php';
         $tabs['triggers']['text'] = __('Triggers');
         $tabs['triggers']['icon'] = 'b_triggers.png';
     }
     /**
      * Views support a limited number of operations
      */
     if ($tbl_is_view && !$db_is_system_schema) {
         $tabs['operation']['icon'] = 'b_tblops.png';
         $tabs['operation']['link'] = 'view_operations.php';
         $tabs['operation']['text'] = __('Operations');
     }
     return $tabs;
 }
开发者ID:Sorekk,项目名称:cvillecouncilus,代码行数:80,代码来源:Menu.class.php


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