本文整理汇总了PHP中PMA_extractFieldSpec函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_extractFieldSpec函数的具体用法?PHP PMA_extractFieldSpec怎么用?PHP PMA_extractFieldSpec使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_extractFieldSpec函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: testParsing
/**
* Test case for parsing SHOW COLUMNS output
*
* @dataProvider provider
*/
public function testParsing($in, $out)
{
$this->assertEquals($out, PMA_extractFieldSpec($in));
}
示例2: PMA_extractFieldSpec
if (!$timestamp_seen) {
// can only occur once per table
$timestamp_seen = 1;
$table_fields[$i]['first_timestamp'] = true;
}
$table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
$table_fields[$i]['wrap'] = ' nowrap="nowrap"';
break;
default:
$table_fields[$i]['pma_type'] = $table_fields[$i]['Type'];
$table_fields[$i]['wrap'] = ' nowrap="nowrap"';
break;
}
}
$field = $table_fields[$i];
$extracted_fieldspec = PMA_extractFieldSpec($field['Type']);
if (-1 === $field['len']) {
$field['len'] = PMA_DBI_field_len($vresult, $i);
}
$unnullify_trigger = $chg_evt_handler . "=\"return unNullify('" . PMA_escapeJsString($field['Field_md5']) . "', '" . PMA_escapeJsString($jsvkey) . "')\"";
// Use an MD5 as an array index to avoid having special characters in the name atttibute (see bug #1746964 )
$field_name_appendix = $vkey . '[' . $field['Field_md5'] . ']';
$field_name_appendix_md5 = $field['Field_md5'] . $vkey . '[]';
if ($field['Type'] == 'datetime' && !isset($field['Default']) && !is_null($field['Default']) && ($insert_mode || !isset($vrow[$field['Field']]))) {
// INSERT case or
// UPDATE case with an NULL value
$vrow[$field['Field']] = date('Y-m-d H:i:s', time());
}
?>
<tr class="<?php
echo $odd_row ? 'odd' : 'even';
示例3: PMA_exportStructure
//.........这里部分代码省略.........
// 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;
}
$buffer .= $header . ' \\\\ \\hline \\hline \\endhead \\endfoot ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
$fields = PMA_DBI_get_columns($db, $table);
foreach ($fields as $row) {
$extracted_fieldspec = PMA_extractFieldSpec($row['Type']);
$type = $extracted_fieldspec['print_type'];
if (empty($type)) {
$type = ' ';
}
if (!isset($row['Default'])) {
if ($row['Null'] != 'NO') {
$row['Default'] = 'NULL';
}
}
$field_name = $row['Field'];
$local_buffer = $field_name . "" . $type . "" . ($row['Null'] == '' || $row['Null'] == 'NO' ? __('No') : __('Yes')) . "" . (isset($row['Default']) ? $row['Default'] : '');
if ($do_relation && $have_rel) {
$local_buffer .= "";
if (isset($res_rel[$field_name])) {
$local_buffer .= $res_rel[$field_name]['foreign_table'] . ' (' . $res_rel[$field_name]['foreign_field'] . ')';
}
}
if ($do_comments && $cfgRelation['commwork']) {
$local_buffer .= "";
if (isset($comments[$field_name])) {
$local_buffer .= $comments[$field_name];
}
}
if ($do_mime && $cfgRelation['mimework']) {
$local_buffer .= "";
if (isset($mime_map[$field_name])) {
$local_buffer .= str_replace('_', '/', $mime_map[$field_name]['mimetype']);
}
}
$local_buffer = PMA_texEscape($local_buffer);
if ($row['Key'] == 'PRI') {
$pos = strpos($local_buffer, "");
$local_buffer = '\\textit{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
if (in_array($field_name, $unique_keys)) {
$pos = strpos($local_buffer, "");
$local_buffer = '\\textbf{' . substr($local_buffer, 0, $pos) . '}' . substr($local_buffer, $pos);
}
$buffer = str_replace("", ' & ', $local_buffer);
$buffer .= ' \\\\ \\hline ' . $crlf;
if (!PMA_exportOutputHandler($buffer)) {
return false;
}
}
// end while
$buffer = ' \\end{longtable}' . $crlf;
return PMA_exportOutputHandler($buffer);
}
示例4: 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;
}
/* Heading */
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</text:h>';
/**
* 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
*/
$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>' . __('Column') . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . __('Type') . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . __('Null') . '</text:p>' . '</table:table-cell>';
$GLOBALS['odt_buffer'] .= '<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'] .= '<table:table-row>';
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($field_name) . '</text:p>' . '</table:table-cell>';
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = htmlspecialchars($extracted_fieldspec['print_type']);
if (empty($type)) {
//.........这里部分代码省略.........
示例5: 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;
if (!PMA_exportOutputHandler('<h2>' . __('Table structure for table') . ' ' . htmlspecialchars($table) . '</h2>')) {
return false;
}
/**
* 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
*/
if (!PMA_exportOutputHandler('<table class="width100" cellspacing="1">')) {
return false;
}
$columns_cnt = 4;
if ($do_relation && $have_rel) {
$columns_cnt++;
}
if ($do_comments && $cfgRelation['commwork']) {
$columns_cnt++;
}
if ($do_mime && $cfgRelation['mimework']) {
$columns_cnt++;
}
$schema_insert = '<tr class="print-category">';
$schema_insert .= '<th class="print">' . __('Column') . '</th>';
$schema_insert .= '<td class="print"><b>' . __('Type') . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Null') . '</b></td>';
$schema_insert .= '<td class="print"><b>' . __('Default') . '</b></td>';
if ($do_relation && $have_rel) {
$schema_insert .= '<td class="print"><b>' . __('Links to') . '</b></td>';
}
if ($do_comments) {
$schema_insert .= '<td class="print"><b>' . __('Comments') . '</b></td>';
$comments = PMA_getComments($db, $table);
}
if ($do_mime && $cfgRelation['mimework']) {
$schema_insert .= '<td class="print"><b>' . htmlspecialchars('MIME') . '</b></td>';
$mime_map = PMA_getMIME($db, $table, true);
}
$schema_insert .= '</tr>';
if (!PMA_exportOutputHandler($schema_insert)) {
return false;
}
$columns = PMA_DBI_get_columns($db, $table);
foreach ($columns as $column) {
$schema_insert = '<tr class="print-category">';
$extracted_fieldspec = PMA_extractFieldSpec($column['Type']);
$type = htmlspecialchars($extracted_fieldspec['print_type']);
if (empty($type)) {
$type = ' ';
}
if (!isset($column['Default'])) {
//.........这里部分代码省略.........
示例6: preg_replace
$arr['type'] = preg_replace('@BINARY([^\\(])@i', '', $arr['type']);
$arr['type'] = preg_replace('@ZEROFILL@i', '', $arr['type']);
$arr['type'] = preg_replace('@UNSIGNED@i', '', $arr['type']);
// some types, for example longtext, are reported as
// "longtext character set latin7" when their charset and / or collation
// differs from the ones of the corresponding database.
$tmp = strpos($arr['type'], 'character set');
if ($tmp) {
$arr['type'] = substr($arr['type'], 0, $tmp - 1);
}
$c['Default'] = $r_data[$c['Field']];
$col[$c['Field']] = array_merge($arr, array('Default' => $c['Default']));
}
} else {
while ($c = $cl->fetch_assoc()) {
$arr = PMA_extractFieldSpec($c['Type']);
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
$arr['type'] = preg_replace('@BINARY([^\\(])@i', '', $arr['type']);
$arr['type'] = preg_replace('@ZEROFILL@i', '', $arr['type']);
$arr['type'] = preg_replace('@UNSIGNED@i', '', $arr['type']);
// some types, for example longtext, are reported as
// "longtext character set latin7" when their charset and / or collation
// differs from the ones of the corresponding database.
$tmp = strpos($arr['type'], 'character set');
if ($tmp) {
$arr['type'] = substr($arr['type'], 0, $tmp - 1);
}
if ($arr['type'] == 'date' and $c['Default'] == '') {
$c['Default'] = date("Y-m-d", time());
}
示例7: htmlentities
$_msg = htmlentities($_POST['name']);
} else {
$_err = 1;
$_msg = $db->error;
}
} else {
$col_data = $check_cl->fetch_array();
$_q = "SHOW FULL COLUMNS FROM " . PMA_bkq($tb_name);
if ($data = $db->query($_q)) {
while ($_d = $data->fetch_object()) {
$_cols[] = $_d->Field;
}
}
//ok here we go :)
//grab the type and lenght
$extracted_fieldspec = PMA_extractFieldSpec($col_data['Type']);
$type = $extracted_fieldspec['type'];
if ('set' == $extracted_fieldspec['type'] || 'enum' == $extracted_fieldspec['type']) {
$length = $extracted_fieldspec['spec_in_brackets'];
} else {
// strip the "BINARY" attribute, except if we find "BINARY(" because
// this would be a BINARY or VARBINARY field type
$type = preg_replace('@BINARY([^\\(])@i', '', $type);
$type = preg_replace('@ZEROFILL@i', '', $type);
$type = preg_replace('@UNSIGNED@i', '', $type);
$length = $extracted_fieldspec['spec_in_brackets'];
}
// end if else
// some types, for example longtext, are reported as
// "longtext character set latin7" when their charset and / or collation
// differs from the ones of the corresponding database.