本文整理汇总了PHP中PMA_getRelationsAndStatus函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_getRelationsAndStatus函数的具体用法?PHP PMA_getRelationsAndStatus怎么用?PHP PMA_getRelationsAndStatus使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_getRelationsAndStatus函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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
* $this->exportStructure() also for other
* export types which use this parameter
* @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
* @param array $aliases Aliases of db/table/columns
*
* @return string resulting schema
*/
public function getTableDef($db, $table, $crlf, $error_url, $do_relation, $do_comments, $do_mime, $show_dates = false, $add_semicolon = true, $view = false, $aliases = array())
{
global $cfgRelation;
$text_output = '';
/**
* 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'];
}
}
/**
* 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
*/
$text_output .= "|------\n";
$text_output .= '|' . __('Column');
$text_output .= '|' . __('Type');
$text_output .= '|' . __('Null');
$text_output .= '|' . __('Default');
if ($do_relation && $have_rel) {
$text_output .= '|' . __('Links to');
}
if ($do_comments) {
$text_output .= '|' . __('Comments');
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . htmlspecialchars('MIME');
$mime_map = PMA_getMIME($db, $table, true);
}
$text_output .= "\n|------\n";
$columns = $GLOBALS['dbi']->getColumns($db, $table);
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];
}
$text_output .= $this->formatOneColumnDefinition($column, $unique_keys, $col_as);
$field_name = $column['Field'];
if ($do_relation && $have_rel) {
$text_output .= '|' . htmlspecialchars($this->getRelationString($res_rel, $field_name, $db, $aliases));
}
if ($do_comments && $cfgRelation['commwork']) {
$text_output .= '|' . (isset($comments[$field_name]) ? htmlspecialchars($comments[$field_name]) : '');
}
if ($do_mime && $cfgRelation['mimework']) {
$text_output .= '|' . (isset($mime_map[$field_name]) ? htmlspecialchars(str_replace('_', '/', $mime_map[$field_name]['mimetype'])) : '');
}
$text_output .= "\n";
}
// end foreach
return $text_output;
}
示例2: list
/**
* 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
*/
$columns = $GLOBALS['dbi']->getColumns($db, $table);
// Check if we can use Relations
list($res_rel, $have_rel) = PMA_getRelationsAndStatus(!empty($cfgRelation['relation']), $db, $table);
/**
* Displays the comments of the table if MySQL >= 3.23
*/
if (!empty($show_comment)) {
echo __('Table comments:'), ' ';
echo htmlspecialchars($show_comment), '<br /><br />';
}
/**
* Displays the table structure
*/
echo '<table width="100%" class="print">';
echo '<tr><th width="50">', __('Column'), '</th>';
echo '<th width="80">', __('Type'), '</th>';
echo '<th width="40">', __('Null'), '</th>';
echo '<th width="70">', __('Default'), '</th>';
示例3: 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 string $export_mode 'create_table', 'triggers', 'create_view',
* 'stand_in'
* @param string $export_type 'server', 'database', 'table'
* @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
* 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 array $aliases Aliases of db/table/columns
*
* @return bool Whether it succeeded
*/
public function exportStructure($db, $table, $crlf, $error_url, $export_mode, $export_type, $do_relation = false, $do_comments = false, $do_mime = false, $dates = false, $aliases = array())
{
$db_alias = $db;
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
global $cfgRelation;
/* We do not export triggers */
if ($export_mode == 'triggers') {
return true;
}
/**
* 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'];
}
}
/**
* 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
*/
$buffer = $crlf . '%' . $crlf . '% ' . __('Structure:') . ' ' . $table_alias . $crlf . '%' . $crlf . ' \\begin{longtable}{';
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$alignment = '|l|c|c|c|';
if ($do_relation && $have_rel) {
$alignment .= 'l|';
}
if ($do_comments) {
$alignment .= 'l|';
}
if ($do_mime && $cfgRelation['mimework']) {
$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_Util::expandUserString($GLOBALS['latex_structure_caption'], array('texEscape', get_class($this), 'libraries/plugins/export/' . get_class($this) . ".class.php"), array('table' => $table_alias, 'database' => $db_alias)) . '} \\label{' . PMA_Util::expandUserString($GLOBALS['latex_structure_label'], null, array('table' => $table_alias, 'database' => $db_alias)) . '} \\\\' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline' . $crlf . '\\endfirsthead' . $crlf;
// Table caption on next pages
if (isset($GLOBALS['latex_caption'])) {
$buffer .= ' \\caption{' . PMA_Util::expandUserString($GLOBALS['latex_structure_continued_caption'], array('texEscape', get_class($this), 'libraries/plugins/export/' . get_class($this) . ".class.php"), array('table' => $table_alias, 'database' => $db_alias)) . '} \\\\ ' . $crlf;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$fields = $GLOBALS['dbi']->getColumns($db, $table);
foreach ($fields as $row) {
$extracted_columnspec = PMA_Util::extractColumnSpec($row['Type']);
$type = $extracted_columnspec['print_type'];
if (empty($type)) {
$type = ' ';
}
//.........这里部分代码省略.........
示例4: _getTableComments
/**
* Returns $table's comments, relations etc.
*
* @param string $db database name
* @param string $table table name
* @param string $crlf end of line sequence
* @param bool $do_relation whether to include relation comments
* @param bool $do_mime whether to include mime comments
* @param array $aliases Aliases of db/table/columns
*
* @return string resulting comments
*/
private function _getTableComments($db, $table, $crlf, $do_relation = false, $do_mime = false, $aliases = array())
{
global $cfgRelation, $sql_backquotes;
$db_alias = $db;
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
$schema_create = '';
// Check if we can use Relations
list($res_rel, $have_rel) = PMA_getRelationsAndStatus($do_relation && !empty($cfgRelation['relation']), $db, $table);
if ($do_mime && $cfgRelation['mimework']) {
if (!($mime_map = PMA_getMIME($db, $table, true))) {
unset($mime_map);
}
}
if (isset($mime_map) && count($mime_map) > 0) {
$schema_create .= $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('MIME TYPES FOR TABLE') . ' ' . PMA_Util::backquote($table, $sql_backquotes) . ':');
@reset($mime_map);
foreach ($mime_map as $mime_field => $mime) {
$schema_create .= $this->_exportComment(' ' . PMA_Util::backquote($mime_field, $sql_backquotes)) . $this->_exportComment(' ' . PMA_Util::backquote($mime['mimetype'], $sql_backquotes));
}
$schema_create .= $this->_exportComment();
}
if ($have_rel) {
$schema_create .= $this->_possibleCRLF() . $this->_exportComment() . $this->_exportComment(__('RELATIONS FOR TABLE') . ' ' . PMA_Util::backquote($table_alias, $sql_backquotes) . ':');
foreach ($res_rel as $rel_field => $rel) {
if ($rel_field != 'foreign_keys_data') {
$rel_field_alias = !empty($aliases[$db]['tables'][$table]['columns'][$rel_field]) ? $aliases[$db]['tables'][$table]['columns'][$rel_field] : $rel_field;
$schema_create .= $this->_exportComment(' ' . PMA_Util::backquote($rel_field_alias, $sql_backquotes)) . $this->_exportComment(' ' . PMA_Util::backquote($rel['foreign_table'], $sql_backquotes) . ' -> ' . PMA_Util::backquote($rel['foreign_field'], $sql_backquotes));
} else {
foreach ($rel as $one_key) {
foreach ($one_key['index_list'] as $index => $field) {
$rel_field_alias = !empty($aliases[$db]['tables'][$table]['columns'][$field]) ? $aliases[$db]['tables'][$table]['columns'][$field] : $field;
$schema_create .= $this->_exportComment(' ' . PMA_Util::backquote($rel_field_alias, $sql_backquotes)) . $this->_exportComment(' ' . PMA_Util::backquote($one_key['ref_table_name'], $sql_backquotes) . ' -> ' . PMA_Util::backquote($one_key['ref_index_list'][$index], $sql_backquotes));
}
}
}
}
$schema_create .= $this->_exportComment();
}
return $schema_create;
}
示例5: 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;
}
示例6: 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
* @param array $aliases Aliases of db/table/columns
*
* @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, $aliases = array())
{
global $cfgRelation;
$db_alias = $db;
$table_alias = $table;
$this->initAlias($aliases, $db_alias, $table_alias);
/**
* 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
*/
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table_alias) . '_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 = $GLOBALS['dbi']->getColumns($db, $table);
foreach ($columns as $column) {
$col_as = $field_name = $column['Field'];
if (!empty($aliases[$db]['tables'][$table]['columns'][$col_as])) {
$col_as = $aliases[$db]['tables'][$table]['columns'][$col_as];
}
$GLOBALS['odt_buffer'] .= $this->formatOneColumnDefinition($column, $col_as);
if ($do_relation && $have_rel) {
$foreigner = PMA_searchColumnInForeigners($res_rel, $field_name);
if ($foreigner) {
$rtable = $foreigner['foreign_table'];
$rfield = $foreigner['foreign_field'];
if (!empty($aliases[$db]['tables'][$rtable]['columns'][$rfield])) {
$rfield = $aliases[$db]['tables'][$rtable]['columns'][$rfield];
}
if (!empty($aliases[$db]['tables'][$rtable]['alias'])) {
$rtable = $aliases[$db]['tables'][$rtable]['alias'];
}
$relation = htmlspecialchars($rtable . ' (' . $rfield . ')');
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($relation) . '</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>';
//.........这里部分代码省略.........