本文整理汇总了PHP中PMA_getComments函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getComments函数的具体用法?PHP PMA_getComments怎么用?PHP PMA_getComments使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getComments函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_getHtmlForCreateNewColumn
/**
* get the html of the form to add the new column to given table
*
* @param integer $num_fields number of columns to add
* @param string $db current database
* @param string $table current table
* @param array $columnMeta array containing default values for the fields
*
* @return string HTML
*/
function PMA_getHtmlForCreateNewColumn($num_fields, $db, $table, $columnMeta = array())
{
$cfgRelation = PMA_getRelationsParam();
$content_cells = array();
$available_mime = array();
$mime_map = array();
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($db, $table);
$available_mime = PMA_getAvailableMIMEtypes();
}
$comments_map = PMA_getComments($db, $table);
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$content_cells[$columnNumber] = array('columnNumber' => $columnNumber, 'columnMeta' => $columnMeta, 'type_upper' => '', 'length_values_input_size' => 8, 'length' => '', 'extracted_columnspec' => array(), 'submit_attribute' => null, 'comments_map' => $comments_map, 'fields_meta' => null, 'is_backup' => true, 'move_columns' => array(), 'cfgRelation' => $cfgRelation, 'available_mime' => isset($available_mime) ? $available_mime : array(), 'mime_map' => $mime_map);
}
return PMA\libraries\Template::get('columns_definitions/table_fields_definitions')->render(array('is_backup' => true, 'fields_meta' => null, 'mimework' => $cfgRelation['mimework'], 'content_cells' => $content_cells));
}
示例2: PMA_getHtmlForCreateNewColumn
/**
* get the html of the form to add the new column to given table
*
* @param integer $num_fields number of columns to add
* @param string $db current database
* @param string $table current table
* @param array $columnMeta array containing default values for the fields
*
* @return HTML
*/
function PMA_getHtmlForCreateNewColumn($num_fields, $db, $table, $columnMeta = array())
{
$cfgRelation = PMA_getRelationsParam();
$content_cells = array();
$available_mime = array();
$mime_map = array();
$header_cells = PMA_getHeaderCells(true, null, $cfgRelation['mimework'], $db, $table);
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($db, $table);
$available_mime = PMA_getAvailableMIMEtypes();
}
$comments_map = PMA_getComments($db, $table);
for ($columnNumber = 0; $columnNumber < $num_fields; $columnNumber++) {
$content_cells[$columnNumber] = PMA_getHtmlForColumnAttributes($columnNumber, $columnMeta, '', 8, '', null, array(), null, null, null, $comments_map, null, true, array(), $cfgRelation, isset($available_mime) ? $available_mime : array(), $mime_map);
}
return PMA_getHtmlForTableFieldDefinitions($header_cells, $content_cells);
}
示例3: PMA_exportStructure
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $dummy)
{
global $cfgRelation;
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
}
// end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . $GLOBALS['strStructure'] . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .= 'l|';
}
$buffer = $alignment . '} ' . $crlf;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strField'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strType'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strNull'] . '}} & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strDefault'] . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strLinksTo'] . '}}';
}
if ($do_comments && ($cfgRelation['commwork'] || PMA_MYSQL_INT_VERSION >= 40100)) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . $GLOBALS['strComments'] . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
$local_buffer = PMA_texEscape($table);
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_caption']) . '} \\label{' . str_replace('__TABLE__', $table, $GLOBALS['latex_structure_label']) . '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . str_replace('__TABLE__', PMA_texEscape($table), $GLOBALS['latex_structure_continued_caption']) . '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return FALSE;
}
while ($row = PMA_DBI_fetch_assoc($result)) {
$type = $row['Type'];
// reformat mysql query output - staybyte - 9. June 2001
// loic1: set or enum types: slashes single quotes inside options
if (eregi('^(set|enum)\\((.+)\\)$', $type, $tmp)) {
$tmp[2] = substr(ereg_replace('([^,])\'\'', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = eregi_replace('BINARY', '', $type);
$type = eregi_replace('ZEROFILL', '', $type);
//.........这里部分代码省略.........
示例4: preg_replace
$show_comment = preg_replace('@; InnoDB free:.*?$@', '', $show_comment);
}
echo '<span class="table_comment" id="span_table_comment">' . '"' . htmlspecialchars($show_comment) . '"</span>' . "\n";
}
// end if
} else {
// no table selected, display database comment if present
/**
* Settings for relations stuff
*/
require_once './libraries/relation.lib.php';
$cfgRelation = PMA_getRelationsParam();
// Get additional information about tables for tooltip is done
// in libraries/db_info.inc.php only once
if ($cfgRelation['commwork']) {
$comment = PMA_getComments($GLOBALS['db']);
/**
* Displays table comment
*/
if (is_array($comment)) {
echo '<span class="table_comment"' . ' id="span_table_comment">"' . htmlspecialchars(implode(' ', $comment)) . '"</span>' . "\n";
}
// end if
}
}
}
echo '</div>';
}
/**
* Sets a variable to remember headers have been sent
*/
示例5: _getTableCommentsArray
/**
* Get table comments as array
*
* @param array $analyzed_sql the analyzed query
*
* @return array $comments_map table comments when condition true
* null when condition falls
*
* @access private
*
* @see _getTableHeaders()
*/
private function _getTableCommentsArray($analyzed_sql)
{
$comments_map = null;
if ($GLOBALS['cfg']['ShowBrowseComments']) {
$comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0]) && isset($analyzed_sql[0]['table_ref'])) {
foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
$tb = $tbl['table_true_name'];
$comments_map[$tb] = PMA_getComments($this->__get('db'), $tb);
unset($tb);
}
}
}
return $comments_map;
}
示例6: PMA_displayTableHeaders
//.........这里部分代码省略.........
><?php
echo $full_or_partial_text_link;
?>
</th>
<?php
} else {
$vertical_display['textbtn'] = ' <th ' . $rowspan . ' valign="middle">' . "\n" . ' ' . "\n" . ' </th>' . "\n";
}
// end vertical mode
} elseif ($GLOBALS['cfg']['ModifyDeleteAtLeft'] && ($is_display['edit_lnk'] != 'nn' || $is_display['del_lnk'] != 'nn')) {
$vertical_display['emptypre'] = $is_display['edit_lnk'] != 'nn' && $is_display['del_lnk'] != 'nn' ? 3 : 0;
if ($_SESSION['tmp_user_values']['disp_direction'] == 'horizontal' || $_SESSION['tmp_user_values']['disp_direction'] == 'horizontalflipped') {
?>
<td<?php
echo $colspan;
?>
></td>
<?php
} else {
$vertical_display['textbtn'] = ' <td' . $rowspan . '></td>' . "\n";
}
// end vertical mode
}
// 2. Displays the fields' name
// 2.0 If sorting links should be used, checks if the query is a "JOIN"
// statement (see 2.1.3)
// 2.0.1 Prepare Display column comments if enabled ($GLOBALS['cfg']['ShowBrowseComments']).
// Do not show comments, if using horizontalflipped mode, because of space usage
if ($GLOBALS['cfg']['ShowBrowseComments'] && $_SESSION['tmp_user_values']['disp_direction'] != 'horizontalflipped') {
$comments_map = array();
if (isset($analyzed_sql[0]) && is_array($analyzed_sql[0])) {
foreach ($analyzed_sql[0]['table_ref'] as $tbl) {
$tb = $tbl['table_true_name'];
$comments_map[$tb] = PMA_getComments($db, $tb);
unset($tb);
}
}
}
if ($GLOBALS['cfgRelation']['commwork'] && $GLOBALS['cfgRelation']['mimework'] && $GLOBALS['cfg']['BrowseMIME'] && !$_SESSION['tmp_user_values']['hide_transformation']) {
require_once './libraries/transformations.lib.php';
$GLOBALS['mime_map'] = PMA_getMIME($db, $table);
}
if ($is_display['sort_lnk'] == '1') {
$select_expr = $analyzed_sql[0]['select_expr_clause'];
}
// garvin: See if we have to highlight any header fields of a WHERE query.
// Uses SQL-Parser results.
$highlight_columns = array();
if (isset($analyzed_sql) && isset($analyzed_sql[0]) && isset($analyzed_sql[0]['where_clause_identifiers'])) {
$wi = 0;
if (isset($analyzed_sql[0]['where_clause_identifiers']) && is_array($analyzed_sql[0]['where_clause_identifiers'])) {
foreach ($analyzed_sql[0]['where_clause_identifiers'] as $wci_nr => $wci) {
$highlight_columns[$wci] = 'true';
}
}
}
for ($i = 0; $i < $fields_cnt; $i++) {
// garvin: See if this column should get highlight because it's used in the
// where-query.
if (isset($highlight_columns[$fields_meta[$i]->name]) || isset($highlight_columns[PMA_backquote($fields_meta[$i]->name)])) {
$condition_field = true;
} else {
$condition_field = false;
}
// 2.0 Prepare comment-HTML-wrappers for each row, if defined/enabled.
if (isset($comments_map) && isset($comments_map[$fields_meta[$i]->table]) && isset($comments_map[$fields_meta[$i]->table][$fields_meta[$i]->name])) {
示例7: _getTableCommentsArray
/**
* Get table comments as array
*
* @param array $analyzed_sql_results analyzed sql results
*
* @return array $comments_map table comments
*
* @access private
*
* @see _getTableHeaders()
*/
private function _getTableCommentsArray($analyzed_sql_results)
{
if (!$GLOBALS['cfg']['ShowBrowseComments'] || empty($analyzed_sql_results['statement']->from)) {
return array();
}
$ret = array();
foreach ($analyzed_sql_results['statement']->from as $field) {
if (empty($field->table)) {
continue;
}
$ret[$field->table] = PMA_getComments(empty($field->database) ? $this->__get('db') : $field->database, $field->table);
}
return $ret;
}
示例8: __
/**
* Displays DB comment
*/
if ($comment) {
echo '<p>', __('Database comment'), '<br /><i>', htmlspecialchars($comment), '</i></p>';
}
// end if
}
/**
* Selects the database and gets tables names
*/
$GLOBALS['dbi']->selectDb($db);
$tables = $GLOBALS['dbi']->getTables($db);
$count = 0;
foreach ($tables as $table) {
$comments = PMA_getComments($db, $table);
echo '<div>', "\n";
echo '<h2>', htmlspecialchars($table), '</h2>', "\n";
/**
* Gets table information
*/
$show_comment = $GLOBALS['dbi']->getTable($db, $table)->getStatusInfo('TABLE_COMMENT');
/**
* Gets table keys and retains them
*/
$GLOBALS['dbi']->selectDb($db);
$indexes = $GLOBALS['dbi']->getTableIndexes($db, $table);
list($primary, $pk_array, $indexes_info, $indexes_data) = PMA\libraries\Util::processIndexData($indexes);
/**
* Gets columns properties
*/
示例9: getTableDef
/**
* Print $table's CREATE definition
*
* @param string $db the database name
* @param string $table the table name
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because export.php calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $view whether we're handling a view
* @param array $aliases aliases of db/table/columns
*
* @return void
*/
public function getTableDef($db, $table, $do_relation, $do_comments, $do_mime, $view = false, $aliases = array())
{
// set $cfgRelation here, because there is a chance that it's modified
// since the class initialization
global $cfgRelation;
unset($this->tablewidths);
unset($this->colTitles);
unset($this->titleWidth);
unset($this->colFits);
unset($this->display_column);
unset($this->colAlign);
/**
* Gets fields properties
*/
$GLOBALS['dbi']->selectDb($db);
/**
* All these three checks do_relation, do_comment and do_mime is
* not required. As presently all are set true by default.
* But when, methods to take user input will be developed,
* it will be of use
*/
// Check if we can use Relations
if ($do_relation) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
}
// end if
//column count and table heading
$this->colTitles[0] = __('Column');
$this->tablewidths[0] = 90;
$this->colTitles[1] = __('Type');
$this->tablewidths[1] = 80;
$this->colTitles[2] = __('Null');
$this->tablewidths[2] = 40;
$this->colTitles[3] = __('Default');
$this->tablewidths[3] = 120;
for ($columns_cnt = 0; $columns_cnt < 4; $columns_cnt++) {
$this->colAlign[$columns_cnt] = 'L';
$this->display_column[$columns_cnt] = true;
}
if ($do_relation && $have_rel) {
$this->colTitles[$columns_cnt] = __('Links to');
$this->display_column[$columns_cnt] = true;
$this->colAlign[$columns_cnt] = 'L';
$this->tablewidths[$columns_cnt] = 120;
$columns_cnt++;
}
if ($do_comments) {
$this->colTitles[$columns_cnt] = __('Comments');
$this->display_column[$columns_cnt] = true;
$this->colAlign[$columns_cnt] = 'L';
$this->tablewidths[$columns_cnt] = 120;
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$this->colTitles[$columns_cnt] = __('MIME');
$this->display_column[$columns_cnt] = true;
$this->colAlign[$columns_cnt] = 'L';
$this->tablewidths[$columns_cnt] = 120;
$columns_cnt++;
}
// Starting to fill table with required info
$this->setY($this->tMargin);
$this->AddPage();
$this->SetFont(PMA_PDF_FONT, '', 9);
// Now let's start to write the table structure
if ($do_comments) {
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$mime_map = PMA_getMIME($db, $table, true);
}
$columns = $GLOBALS['dbi']->getColumns($db, $table);
/**
//.........这里部分代码省略.........
示例10: PMA_exportStructure
/**
* Outputs table's structure
*
* @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 bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column comments
* as comments in the structure; this is deprecated
* but the parameter is left here because export.php
* calls PMA_exportStructure() also for other export
* types which use this parameter
* @param bool $do_mime whether to include mime comments
* @param bool $dates whether to include creation/update/check dates
* @param string $export_mode 'create_table', 'triggers', 'create_view', 'stand_in'
* @param string $export_type 'server', 'database', 'table'
*
* @return bool Whether it succeeded
*
* @access public
*/
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $export_mode, $export_type)
{
global $cfgRelation;
/* We do not export triggers */
if ($export_mode == 'triggers') {
return true;
}
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = PMA_DBI_get_table_indexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
}
// end if
/**
* Displays the table structure
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure') . ': ' . $table . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$columns_cnt = 4;
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_comments) {
$columns_cnt++;
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
$alignment .= 'l|';
}
$buffer = $alignment . '} ' . $crlf;
$header = ' \\hline ';
$header .= '\\multicolumn{1}{|c|}{\\textbf{' . __('Column') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Type') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Null') . '}} & \\multicolumn{1}{|c|}{\\textbf{' . __('Default') . '}}';
if ($do_relation && $have_rel) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Links to') . '}}';
}
if ($do_comments) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{' . __('Comments') . '}}';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$header .= ' & \\multicolumn{1}{|c|}{\\textbf{MIME}}';
$mime_map = PMA_getMIME($db, $table, true);
}
// Table caption for first page and label
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\label{' . PMA_expandUserString($GLOBALS['latex_structure_label'], null, array('table' => $table, 'database' => $db)) . '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_expandUserString($GLOBALS['latex_structure_continued_caption'], 'PMA_texEscape', array('table' => $table, 'database' => $db)) . '} \\\\ ' . $crlf;
//.........这里部分代码省略.........
示例11: PMA_exportStructure
function PMA_exportStructure($db, $table, $crlf, $error_url, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $dummy)
{
global $cfgRelation;
/* Heading */
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Table structure for table') . ' ' . $table) . '</text:h>';
/**
* Get the unique keys in the table
*/
$keys_query = 'SHOW KEYS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db);
$keys_result = PMA_DBI_query($keys_query);
$unique_keys = array();
while ($key = PMA_DBI_fetch_assoc($keys_result)) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
PMA_DBI_free_result($keys_result);
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
$local_query = 'SHOW FIELDS FROM ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$result = PMA_DBI_query($local_query);
$fields_cnt = PMA_DBI_num_rows($result);
// Check if we can use Relations (Mike Beck)
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = TRUE;
} else {
$have_rel = FALSE;
}
} else {
$have_rel = FALSE;
}
// end if
/**
* Displays the table structure
*/
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_data">';
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $columns_cnt . '"/>';
/* Header */
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Column')) . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Type')) . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Null')) . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Default')) . '</text:p>' . '</table:table-cell>';
if ($do_relation && $have_rel) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Links to')) . '</text:p>' . '</table:table-cell>';
}
if ($do_comments) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('Comments')) . '</text:p>' . '</table:table-cell>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(__('MIME type')) . '</text:p>' . '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
while ($row = PMA_DBI_fetch_assoc($result)) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row['Field']) . '</text:p>' . '</table:table-cell>';
// reformat mysql query output
// set or enum types: slashes single quotes inside options
$field_name = $row['Field'];
$type = $row['Type'];
if (preg_match('/^(set|enum)\\((.+)\\)$/i', $type, $tmp)) {
$tmp[2] = substr(preg_replace('/([^,])\'\'/', '\\1\\\'', ',' . $tmp[2]), 1);
$type = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
$type_nowrap = '';
$binary = 0;
$unsigned = 0;
$zerofill = 0;
} else {
$type_nowrap = ' nowrap="nowrap"';
$type = preg_replace('/BINARY/i', '', $type);
$type = preg_replace('/ZEROFILL/i', '', $type);
$type = preg_replace('/UNSIGNED/i', '', $type);
if (empty($type)) {
$type = ' ';
}
$binary = preg_match('/BINARY/i', $row['Type']);
$unsigned = preg_match('/UNSIGNED/i', $row['Type']);
$zerofill = preg_match('/ZEROFILL/i', $row['Type']);
}
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($type) . '</text:p>' . '</table:table-cell>';
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
//.........这里部分代码省略.........
示例12: getTableDef
/**
* Returns $table's CREATE definition
*
* @param string $db the database name
* @param string $table the table name
* @param string $crlf the end of line sequence
* @param string $error_url the url to go back in case of error
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because export.php calls
* PMA_exportStructure() also for other
* @param bool $do_mime whether to include mime comments
* @param bool $show_dates whether to include creation/update/check dates
* @param bool $add_semicolon whether to add semicolon and end-of-line at
* the end
* @param bool $view whether we're handling a view
*
* @return bool true
*/
public function getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $show_dates = false, $add_semicolon = true, $view = false)
{
global $cfgRelation;
/**
* Gets fields properties
*/
PMA_DBI_select_db($db);
// Check if we can use Relations
if ($do_relation && !empty($cfgRelation['relation'])) {
// Find which tables are related with the current one and write it in
// an array
$res_rel = PMA_getForeigners($db, $table);
if ($res_rel && count($res_rel) > 0) {
$have_rel = true;
} else {
$have_rel = false;
}
} else {
$have_rel = false;
}
// end if
/**
* Displays the table structure
*/
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$GLOBALS['odt_buffer'] .= '<table:table-column' . ' table:number-columns-repeated="' . $columns_cnt . '"/>';
/* Header */
$GLOBALS['odt_buffer'] .= '<table:table-row>' . '<table:table-cell office:value-type="string">' . '<text:p>' . __('Column') . '</text:p>' . '</table:table-cell>' . '<table:table-cell office:value-type="string">' . '<text:p>' . __('Type') . '</text:p>' . '</table:table-cell>' . '<table:table-cell office:value-type="string">' . '<text:p>' . __('Null') . '</text:p>' . '</table:table-cell>' . '<table:table-cell office:value-type="string">' . '<text:p>' . __('Default') . '</text:p>' . '</table:table-cell>';
if ($do_relation && $have_rel) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . __('Links to') . '</text:p>' . '</table:table-cell>';
}
if ($do_comments) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . __('Comments') . '</text:p>' . '</table:table-cell>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . __('MIME type') . '</text:p>' . '</table:table-cell>';
$mime_map = PMA_getMIME($db, $table, true);
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$field_name = $column['Field'];
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column);
if ($do_relation && $have_rel) {
if (isset($res_rel[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')') . '</text:p>' . '</table:table-cell>';
}
}
if ($do_comments) {
if (isset($comments[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($comments[$field_name]) . '</text:p>' . '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
}
}
if ($do_mime && $cfgRelation['mimework']) {
if (isset($mime_map[$field_name])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) . '</text:p>' . '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
}
}
$GLOBALS['odt_buffer'] .= '</table:table-row>';
}
// end foreach
$GLOBALS['odt_buffer'] .= '</table:table>';
return true;
}
示例13: toggle
// '$GLOBALS['cfg']['ServerDefault'] = 0' is set. In that case, we want the welcome
// screen to appear with no database info displayed.
// 2. there is only one database available (ie either only one database exists
// or $GLOBALS['cfg']['Servers']['only_db'] is defined and is not an array)
// In this case, the database should not be collapsible/expandable
$img_plus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_plus.png"' . ' width="9" height="9" alt="+" />';
$img_minus = '<img class="icon" id="el%dImg" src="' . $pmaThemeImage . 'b_minus.png"' . ' width="9" height="9" alt="-" />';
$href_left = '<a onclick="if ( toggle(\'%d\') ) return false;"' . ' href="left.php?%s" target="_self">';
$element_counter = 0;
if ($GLOBALS['cfg']['LeftFrameLight'] && isset($db) && strlen($db)) {
// show selected databasename as link to DefaultTabDatabase-page
// with table count in ()
$common_url_query = PMA_generate_common_url($db);
$db_tooltip = '';
if ($GLOBALS['cfg']['ShowTooltip'] && $GLOBALS['cfgRelation']['commwork']) {
$_db_tooltip = PMA_getComments($db);
if (is_array($_db_tooltip)) {
$db_tooltip = implode(' ', $_db_tooltip);
}
}
$disp_name = $db;
if ($db_tooltip && $GLOBALS['cfg']['ShowTooltipAliasDB']) {
$disp_name = $db_tooltip;
$disp_name_cut = $db_tooltip;
$db_tooltip = $db;
}
?>
<p><a class="item"
href="<?php
echo $GLOBALS['cfg']['DefaultTabDatabase'] . '?' . $common_url_query;
?>
示例14: displayStructure
/**
* Displays the table structure ('show table' works correct since 3.23.03)
*
* @param array $cfgRelation current relation parameters
* @param array $columns_with_unique_index Columns with unique index
* @param mixed $url_params Contains an associative
* array with url params
* @param PMA_Index|false $primary_index primary index or false if
* no one exists
* @param array $fields Fields
* @param array $columns_with_index Columns with index
* @param array $create_table_fields Fields of the table.
*
* @return string
*/
protected function displayStructure($cfgRelation, $columns_with_unique_index, $url_params, $primary_index, $fields, $columns_with_index, $create_table_fields)
{
/* TABLE INFORMATION */
$HideStructureActions = '';
if ($GLOBALS['cfg']['HideStructureActions'] === true) {
$HideStructureActions .= ' HideStructureActions';
}
// prepare comments
$comments_map = array();
$mime_map = array();
if ($GLOBALS['cfg']['ShowPropertyComments']) {
include_once 'libraries/transformations.lib.php';
$comments_map = PMA_getComments($this->db, $this->table);
if ($cfgRelation['mimework'] && $GLOBALS['cfg']['BrowseMIME']) {
$mime_map = PMA_getMIME($this->db, $this->table, true);
}
}
include_once 'libraries/central_columns.lib.php';
$central_list = PMA_getCentralColumnsFromTable($this->db, $this->table);
$columns_list = array();
$titles = array('Change' => PMA_Util::getIcon('b_edit.png', __('Change')), 'Drop' => PMA_Util::getIcon('b_drop.png', __('Drop')), 'NoDrop' => PMA_Util::getIcon('b_drop.png', __('Drop')), 'Primary' => PMA_Util::getIcon('b_primary.png', __('Primary')), 'Index' => PMA_Util::getIcon('b_index.png', __('Index')), 'Unique' => PMA_Util::getIcon('b_unique.png', __('Unique')), 'Spatial' => PMA_Util::getIcon('b_spatial.png', __('Spatial')), 'IdxFulltext' => PMA_Util::getIcon('b_ftext.png', __('Fulltext')), 'NoPrimary' => PMA_Util::getIcon('bd_primary.png', __('Primary')), 'NoIndex' => PMA_Util::getIcon('bd_index.png', __('Index')), 'NoUnique' => PMA_Util::getIcon('bd_unique.png', __('Unique')), 'NoSpatial' => PMA_Util::getIcon('bd_spatial.png', __('Spatial')), 'NoIdxFulltext' => PMA_Util::getIcon('bd_ftext.png', __('Fulltext')), 'DistinctValues' => PMA_Util::getIcon('b_browse.png', __('Distinct values')));
/**
* Work on the table
*/
if ($this->_tbl_is_view) {
$item = $this->dbi->fetchSingleRow(sprintf("SELECT `VIEW_DEFINITION`, `CHECK_OPTION`, `DEFINER`,\n `SECURITY_TYPE`\n FROM `INFORMATION_SCHEMA`.`VIEWS`\n WHERE TABLE_SCHEMA='%s'\n AND TABLE_NAME='%s';", PMA_Util::sqlAddSlashes($this->db), PMA_Util::sqlAddSlashes($this->table)));
$createView = $this->dbi->getTable($this->db, $this->table)->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' => $this->table, 'as' => $item['VIEW_DEFINITION'], 'with' => $item['CHECK_OPTION'], 'algorithm' => $item['ALGORITHM']);
$edit_view_url = 'view_create.php' . PMA_URL_getCommon($url_params) . '&' . implode('&', array_map(function ($key, $val) {
return 'view[' . urlencode($key) . ']=' . urlencode($val);
}, array_keys($view), $view));
}
/**
* Displays Space usage and row statistics
*/
// BEGIN - Calc Table Space
// Get valid statistics whatever is the table type
if ($GLOBALS['cfg']['ShowStats']) {
//get table stats in HTML format
$tablestats = $this->getTableStats();
//returning the response in JSON format to be used by Ajax
$this->response->addJSON('tableStat', $tablestats);
}
// END - Calc Table Space
return Template::get('table/structure/display_structure')->render(array('HideStructureActions' => $HideStructureActions, 'db' => $this->db, 'table' => $this->table, 'db_is_system_schema' => $this->_db_is_system_schema, 'tbl_is_view' => $this->_tbl_is_view, 'mime_map' => $mime_map, 'url_query' => $this->_url_query, 'titles' => $titles, 'tbl_storage_engine' => $this->_tbl_storage_engine, 'primary' => $primary_index, 'columns_with_unique_index' => $columns_with_unique_index, 'edit_view_url' => isset($edit_view_url) ? $edit_view_url : null, 'columns_list' => $columns_list, 'tablestats' => isset($tablestats) ? $tablestats : null, 'fields' => $fields, 'columns_with_index' => $columns_with_index, 'central_list' => $central_list, 'create_table_fields' => $create_table_fields));
}
示例15: getTableDef
/**
* Returns $table's CREATE definition
*
* @param string $db the database name
* @param string $table the table name
* @param bool $do_relation whether to include relation comments
* @param bool $do_comments whether to include the pmadb-style column
* comments as comments in the structure;
* this is deprecated but the parameter is
* left here because export.php calls
* PMA_exportStructure() also for other
* export types which use this parameter
* @param bool $do_mime whether to include mime comments
* at the end
* @param bool $view whether we're handling a view
* @param array $aliases Aliases of db/table/columns
*
* @return string resulting schema
*/
public function getTableDef($db, $table, $do_relation, $do_comments, $do_mime, $view = false, $aliases = array())
{
// set $cfgRelation here, because there is a chance that it's modified
// since the class initialization
global $cfgRelation;
$schema_insert = '';
/**
* Gets fields properties
*/
$GLOBALS['dbi']->selectDb($db);
// Check if we can use Relations
list($res_rel, $have_rel) = PMA_getRelationsAndStatus($do_relation && !empty($cfgRelation['relation']), $db, $table);
/**
* Displays the table structure
*/
$schema_insert .= '<table class="width100" cellspacing="1">';
$schema_insert .= '<tr class="print-category">';
$schema_insert .= '<th class="print">' . __('Column') . '</th>';
$schema_insert .= '<td class="print"><strong>' . __('Type') . '</strong></td>';
$schema_insert .= '<td class="print"><strong>' . __('Null') . '</strong></td>';
$schema_insert .= '<td class="print"><strong>' . __('Default') . '</strong></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><strong>' . __('Links to') . '</strong></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><strong>' . __('Comments') . '</strong></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><strong>' . htmlspecialchars('MIME') . '</strong></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
$columns = $GLOBALS['dbi']->getColumns($db, $table);
/**
* Get the unique keys in the table
*/
$unique_keys = array();
$keys = $GLOBALS['dbi']->getTableIndexes($db, $table);
foreach ($keys as $key) {
if ($key['Non_unique'] == 0) {
$unique_keys[] = $key['Column_name'];
}
}
foreach ($columns as $column) {
$col_as = $column['Field'];
if (!empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
$col_as = $aliases[$db]['tables'][$table]['columns'][$col_as];
}
$schema_insert .= $this->formatOneColumnDefinition($column, $unique_keys, $col_as);
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print">' . htmlspecialchars($this->getRelationString($res_rel, $field_name, $db, $aliases)) . '</td>';
}
if ($do_comments && $cfgRelation['commwork']) {
$schema_insert .= '<td class="print">' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '') . '</td>';
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print">' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '') . '</td>';
}
$schema_insert .= '</tr>';
}
// end foreach
$schema_insert .= '</table>';
return $schema_insert;
}