本文整理汇总了PHP中PMA_DBI_field_flags函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_field_flags函数的具体用法?PHP PMA_DBI_field_flags怎么用?PHP PMA_DBI_field_flags使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_field_flags函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_displayTableBody
//.........这里部分代码省略.........
$transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : '');
$meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
}
}
// end if file_exists
}
// end if transformation is set
}
// end if mime/transformation works.
$_url_params = array('db' => $db, 'table' => $table, 'where_clause' => $where_clause, 'transform_key' => $meta->name);
if (!empty($sql_query)) {
$_url_params['sql_query'] = $url_sql_query;
}
$transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
// n u m e r i c
if ($meta->numeric == 1) {
// lem9: if two fields have the same name (this is possible
// with self-join queries, for example), using $meta->name
// will show both fields NULL even if only one is NULL,
// so use the $pointer
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
$nowrap = ' nowrap';
$where_comparison = ' = ' . $row[$i];
$vertical_display['data'][$row_no][$i] = '<td align="right"' . PMA_prepare_row_data($mouse_events, $class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options);
} else {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '"> </td>' . "\n";
}
// b l o b
} elseif (stristr($meta->type, 'BLOB')) {
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type so we have to ensure it's really a BLOB
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
// rajk - for blobstreaming
$bs_reference_exists = $allBSTablesExist = FALSE;
// load PMA configuration
$PMA_Config = $_SESSION['PMA_Config'];
// if PMA configuration exists
if ($PMA_Config) {
// load BS variables
$pluginsExist = $PMA_Config->get('BLOBSTREAMING_PLUGINS_EXIST');
// if BS plugins exist
if ($pluginsExist) {
// load BS databases
$bs_tables = $PMA_Config->get('BLOBSTREAMABLE_DATABASES');
// if BS db array and specified db string not empty and valid
if (!empty($bs_tables) && strlen($db) > 0) {
$bs_tables = $bs_tables[$db];
if (isset($bs_tables)) {
$allBSTablesExist = TRUE;
// check if BS tables exist for given database
foreach ($bs_tables as $table_key => $bs_tbl) {
if (!$bs_tables[$table_key]['Exists']) {
$allBSTablesExist = FALSE;
break;
}
}
}
}
}
}
// if necessary BS tables exist
if ($allBSTablesExist) {
$bs_reference_exists = PMA_BS_ReferenceExists($row[$i], $db);
示例2: 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) . '\'';
}
//.........这里部分代码省略.........
示例3: PMA_DBI_get_fields_meta
/**
* returns metainfo for fields in $result
*
* @todo preserve orignal flags value
* @uses PMA_DBI_field_flags()
* @uses MYSQLI_TYPE_*
* @uses MYSQLI_MULTIPLE_KEY_FLAG
* @uses MYSQLI_PRI_KEY_FLAG
* @uses MYSQLI_UNIQUE_KEY_FLAG
* @uses MYSQLI_NOT_NULL_FLAG
* @uses MYSQLI_UNSIGNED_FLAG
* @uses MYSQLI_ZEROFILL_FLAG
* @uses MYSQLI_NUM_FLAG
* @uses MYSQLI_TYPE_BLOB
* @uses MYSQLI_BLOB_FLAG
* @uses defined()
* @uses mysqli_fetch_fields()
* @uses is_array()
* @param object mysqli result $result
* @return array meta info for fields in $result
*/
function PMA_DBI_get_fields_meta($result)
{
// Build an associative array for a type look up
$typeAr = array();
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_NEWDECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_BIT] = 'bool';
$typeAr[MYSQLI_TYPE_TINY] = 'int';
$typeAr[MYSQLI_TYPE_SHORT] = 'int';
$typeAr[MYSQLI_TYPE_LONG] = 'int';
$typeAr[MYSQLI_TYPE_FLOAT] = 'real';
$typeAr[MYSQLI_TYPE_DOUBLE] = 'real';
$typeAr[MYSQLI_TYPE_NULL] = 'null';
$typeAr[MYSQLI_TYPE_TIMESTAMP] = 'timestamp';
$typeAr[MYSQLI_TYPE_LONGLONG] = 'int';
$typeAr[MYSQLI_TYPE_INT24] = 'int';
$typeAr[MYSQLI_TYPE_DATE] = 'date';
$typeAr[MYSQLI_TYPE_TIME] = 'time';
$typeAr[MYSQLI_TYPE_DATETIME] = 'datetime';
$typeAr[MYSQLI_TYPE_YEAR] = 'year';
$typeAr[MYSQLI_TYPE_NEWDATE] = 'date';
$typeAr[MYSQLI_TYPE_ENUM] = 'unknown';
$typeAr[MYSQLI_TYPE_SET] = 'unknown';
$typeAr[MYSQLI_TYPE_TINY_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_MEDIUM_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_LONG_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_VAR_STRING] = 'string';
$typeAr[MYSQLI_TYPE_STRING] = 'string';
// MySQL returns MYSQLI_TYPE_STRING for CHAR
// and MYSQLI_TYPE_CHAR === MYSQLI_TYPE_TINY
// so this would override TINYINT and mark all TINYINT as string
// https://sf.net/tracker/?func=detail&aid=1532111&group_id=23067&atid=377408
//$typeAr[MYSQLI_TYPE_CHAR] = 'string';
$typeAr[MYSQLI_TYPE_GEOMETRY] = 'unknown';
$fields = mysqli_fetch_fields($result);
// this happens sometimes (seen under MySQL 4.0.25)
if (!is_array($fields)) {
return false;
}
foreach ($fields as $k => $field) {
$fields[$k]->_type = $field->type;
$fields[$k]->type = $typeAr[$field->type];
$fields[$k]->_flags = $field->flags;
$fields[$k]->flags = PMA_DBI_field_flags($result, $k);
// Enhance the field objects for mysql-extension compatibilty
//$flags = explode(' ', $fields[$k]->flags);
//array_unshift($flags, 'dummy');
$fields[$k]->multiple_key = (int) (bool) ($fields[$k]->_flags & MYSQLI_MULTIPLE_KEY_FLAG);
$fields[$k]->primary_key = (int) (bool) ($fields[$k]->_flags & MYSQLI_PRI_KEY_FLAG);
$fields[$k]->unique_key = (int) (bool) ($fields[$k]->_flags & MYSQLI_UNIQUE_KEY_FLAG);
$fields[$k]->not_null = (int) (bool) ($fields[$k]->_flags & MYSQLI_NOT_NULL_FLAG);
$fields[$k]->unsigned = (int) (bool) ($fields[$k]->_flags & MYSQLI_UNSIGNED_FLAG);
$fields[$k]->zerofill = (int) (bool) ($fields[$k]->_flags & MYSQLI_ZEROFILL_FLAG);
$fields[$k]->numeric = (int) (bool) ($fields[$k]->_flags & MYSQLI_NUM_FLAG);
$fields[$k]->blob = (int) (bool) ($fields[$k]->_flags & MYSQLI_BLOB_FLAG);
}
return $fields;
}
示例4: 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;
//.........这里部分代码省略.........
示例5: PMA_displayTableBody
//.........这里部分代码省略.........
$transform_options = PMA_transformation_getOptions(isset($GLOBALS['mime_map'][$meta->name]['transformation_options']) ? $GLOBALS['mime_map'][$meta->name]['transformation_options'] : '');
$meta->mimetype = str_replace('_', '/', $GLOBALS['mime_map'][$meta->name]['mimetype']);
}
}
// end if file_exists
}
// end if transformation is set
}
// end if mime/transformation works.
$_url_params = array('db' => $db, 'table' => $table, 'where_clause' => $where_clause, 'transform_key' => $meta->name);
if (!empty($sql_query)) {
$_url_params['sql_query'] = $url_sql_query;
}
$transform_options['wrapper_link'] = PMA_generate_common_url($_url_params);
// n u m e r i c
if ($meta->numeric == 1) {
// if two fields have the same name (this is possible
// with self-join queries, for example), using $meta->name
// will show both fields NULL even if only one is NULL,
// so use the $pointer
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field, $meta, 'align="right"');
} elseif ($row[$i] != '') {
$nowrap = ' nowrap';
$where_comparison = ' = ' . $row[$i];
$vertical_display['data'][$row_no][$i] = '<td align="right"' . PMA_prepare_row_data($class, $condition_field, $analyzed_sql, $meta, $map, $row[$i], $transform_function, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated);
} else {
$vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta, 'align="right"');
}
// b l o b
} elseif (stristr($meta->type, 'BLOB')) {
// PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type so we have to ensure it's really a BLOB
$field_flags = PMA_DBI_field_flags($dt_result, $i);
// remove 'inline_edit' from $class as we can't edit binary data.
$class = str_replace('inline_edit', '', $class);
if (stristr($field_flags, 'BINARY')) {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field, $meta);
} else {
// for blobstreaming
// if valid BS reference exists
if (PMA_BS_IsPBMSReference($row[$i], $db)) {
$blobtext = PMA_BS_CreateReferenceLink($row[$i], $db);
} else {
$blobtext = PMA_handle_non_printable_contents('BLOB', isset($row[$i]) ? $row[$i] : '', $transform_function, $transform_options, $default_function, $meta, $_url_params);
}
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $blobtext);
unset($blobtext);
}
// not binary:
} else {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = PMA_buildNullDisplay($class, $condition_field, $meta);
} elseif ($row[$i] != '') {
// if a transform function for blob is set, none of these replacements will be made
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == 'P') {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
$is_field_truncated = true;
}
// displays all space characters, 4 space
// characters for tabulations and <cr>/<lf>
$row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta);
$vertical_display['data'][$row_no][$i] = PMA_buildValueDisplay($class, $condition_field, $row[$i]);
} else {
$vertical_display['data'][$row_no][$i] = PMA_buildEmptyDisplay($class, $condition_field, $meta);
示例6: _getDataCellForNonNumericAndNonBlobColumns
/**
* Get data cell for non numeric and non blob type fields
*
* @param string $column the relavent column in data row
* @param string $class the html class for column
* @param object $meta the meta-information about the field
* @param array $map the list of relations
* @param array $_url_params the parameters for generate url
* @param boolean $condition_field the column should highlighted
* or not
* @param string $transformation_plugin the name of transformation function
* @param string $default_function the default transformation function
* @param string $transform_options the transformation parameters
* @param boolean $is_field_truncated the condition for blob data
* replacements
* @param array $analyzed_sql the analyzed query
* @param integer &$dt_result the link id associated to the query
* which results have to be displayed
* @param integer $col_index the column index
*
* @return string $cell the prepared data cell, html content
*
* @access private
*
* @see _getTableBody()
*/
private function _getDataCellForNonNumericAndNonBlobColumns($column, $class, $meta, $map, $_url_params, $condition_field, $transformation_plugin, $default_function, $transform_options, $is_field_truncated, $analyzed_sql, &$dt_result, $col_index)
{
$is_analyse = $this->__get('_is_analyse');
$field_flags = PMA_DBI_field_flags($dt_result, $col_index);
if (stristr($field_flags, self::BINARY_FIELD) && ($GLOBALS['cfg']['ProtectBinary'] == 'all' || $GLOBALS['cfg']['ProtectBinary'] == 'noblob')) {
$class = str_replace('grid_edit', '', $class);
}
if (!isset($column) || is_null($column)) {
$cell = $this->_buildNullDisplay($class, $condition_field, $meta);
} elseif ($column != '') {
// Cut all fields to $GLOBALS['cfg']['LimitChars']
// (unless it's a link-type transformation)
if (PMA_strlen($column) > $GLOBALS['cfg']['LimitChars'] && $_SESSION['tmp_user_values']['display_text'] == self::DISPLAY_PARTIAL_TEXT && gettype($transformation_plugin) == "object" && !strpos($transformation_plugin::getName(), 'Link') === true) {
$column = PMA_substr($column, 0, $GLOBALS['cfg']['LimitChars']) . '...';
$is_field_truncated = true;
}
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = $this->getCommonFunctions()->printableBitValue($column, $meta->length);
// some results of PROCEDURE ANALYSE() are reported as
// being BINARY but they are quite readable,
// so don't treat them as BINARY
} elseif (stristr($field_flags, self::BINARY_FIELD) && $meta->type == self::STRING_FIELD && !(isset($is_analyse) && $is_analyse)) {
if ($_SESSION['tmp_user_values']['display_binary']) {
// user asked to see the real contents of BINARY
// fields
if ($_SESSION['tmp_user_values']['display_binary_as_hex'] && $this->getCommonFunctions()->containsNonPrintableAscii($column)) {
$column = bin2hex($column);
} else {
$column = htmlspecialchars($this->getCommonFunctions()->replaceBinaryContents($column));
}
} else {
// we show the BINARY message and field's size
// (or maybe use a transformation)
$column = $this->_handleNonPrintableContents(self::BINARY_FIELD, $column, $transformation_plugin, $transform_options, $default_function, $meta, $_url_params);
$formatted = true;
}
}
if ($formatted) {
$cell = $this->_buildValueDisplay($class, $condition_field, $column);
} else {
// transform functions may enable no-wrapping:
$function_nowrap = 'applyTransformationNoWrap';
$bool_nowrap = $default_function != $transformation_plugin && function_exists($transformation_plugin->{$function_nowrap}()) ? $transformation_plugin->{$function_nowrap}($transform_options) : false;
// do not wrap if date field type
$nowrap = preg_match('@DATE|TIME@i', $meta->type) || $bool_nowrap ? ' nowrap' : '';
$where_comparison = ' = \'' . $this->getCommonFunctions()->sqlAddSlashes($column) . '\'';
$cell = $this->_getRowData($class, $condition_field, $analyzed_sql, $meta, $map, $column, $transformation_plugin, $default_function, $nowrap, $where_comparison, $transform_options, $is_field_truncated);
}
} else {
$cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
}
return $cell;
}
示例7: PMA_exportData
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$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);
}
$GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
}
// end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
}
// end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
// ignore binary field
// Note: with mysqli, under MySQL 4.1.3, we get the flag
// "binary" for those field types (I don't know why)
} elseif (stristr($field_flags[$j], 'BINARY') && isset($GLOBALS['sql_hex_for_binary']) && $fields_meta[$j]->type != 'datetime' && $fields_meta[$j]->type != 'date' && $fields_meta[$j]->type != 'time' && $fields_meta[$j]->type != 'timestamp') {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} else {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
}
}
// end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
}
// end while
PMA_DBI_free_result($result);
$GLOBALS['ods_buffer'] .= '</table:table>';
return TRUE;
}
示例8: PMA_exportData
/**
* Dispatches between the versions of 'getTableContent' to use depending
* on the php version
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @global boolean whether to use backquotes to allow the use of special
* characters in database, table and fields names or not
* @global integer the number of records
* @global integer the current record position
*
* @access public
*
* @see PMA_getTableContentFast(), PMA_getTableContentOld()
*
* @author staybyte
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $sql_backquotes;
global $rows_cnt;
global $current_row;
$formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_backquote($table) : '\'' . $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 = $crlf . PMA_exportComment() . PMA_exportComment('VIEW ' . ' ' . $formatted_table_name) . PMA_exportComment($GLOBALS['strData'] . ': ' . $GLOBALS['strNone']) . PMA_exportComment() . $crlf;
if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
return true;
}
// it's not a VIEW
$head = $crlf . PMA_exportComment() . PMA_exportComment($GLOBALS['strDumpingData'] . ' ' . $formatted_table_name) . PMA_exportComment() . $crlf;
if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
$buffer = '';
// 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_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
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_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $sql_backquotes);
} else {
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $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_backquote($table, $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';
}
// scheme for inserting fields
if (isset($GLOBALS['sql_columns'])) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $sql_backquotes) . ' (' . $fields . ') VALUES';
} else {
$schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $sql_backquotes) . ' VALUES';
}
}
$search = array("", "\n", "\r", "");
//\x08\\x09, not required
$replace = array('\\0', '\\n', '\\r', '\\Z');
//.........这里部分代码省略.........
示例9: PMA_getUniqueCondition
/**
* Function to generate unique condition for specified row.
*
* @uses PMA_MYSQL_INT_VERSION
* @uses $GLOBALS['analyzed_sql'][0]
* @uses PMA_DBI_field_flags()
* @uses PMA_backquote()
* @uses PMA_sqlAddslashes()
* @uses stristr()
* @uses bin2hex()
* @uses preg_replace()
* @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
* @author Michal Cihar (michal@cihar.com) and others...
* @return string calculated condition
*/
function PMA_getUniqueCondition($handle, $fields_cnt, $fields_meta, $row, $force_unique = false)
{
$primary_key = '';
$unique_key = '';
$nonprimary_condition = '';
$preferred_condition = '';
for ($i = 0; $i < $fields_cnt; ++$i) {
$condition = '';
$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.
if (isset($meta->orgtable) && $meta->table != $meta->orgtable) {
$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') {
$condition = ' CONCAT(' . PMA_backquote($meta->table) . '.' . PMA_backquote($meta->orgname) . ') ';
} else {
// string and blob fields have to be converted using
// the system character set (always utf8) since
// mysql4.1 can use different charset for fields.
if (PMA_MYSQL_INT_VERSION >= 40100 && ($meta->type == 'string' || $meta->type == 'blob')) {
$condition = ' CONVERT(' . PMA_backquote($meta->table) . '.' . PMA_backquote($meta->orgname) . ' USING utf8) ';
} else {
$condition = ' ' . PMA_backquote($meta->table) . '.' . PMA_backquote($meta->orgname) . ' ';
}
}
// end if... else...
if (!isset($row[$i]) || is_null($row[$i])) {
$condition .= 'IS NULL AND';
} else {
// timestamp is numeric on some MySQL 4.1
if ($meta->numeric && $meta->type != 'timestamp') {
$condition .= '= ' . $row[$i] . ' AND';
} 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) {
if (PMA_MYSQL_INT_VERSION < 40002) {
$condition .= 'LIKE 0x' . bin2hex($row[$i]) . ' AND';
} else {
// use a CAST if possible, to avoid problems
// if the field contains wildcard characters % or _
$condition .= '= CAST(0x' . bin2hex($row[$i]) . ' AS BINARY) AND';
}
} else {
// this blob won't be part of the final condition
$condition = '';
}
} else {
$condition .= '= \'' . PMA_sqlAddslashes($row[$i], false, true) . '\' AND';
}
}
if ($meta->primary_key > 0) {
//.........这里部分代码省略.........
示例10: PMA_exportData
/**
* Dispatches between the versions of 'getTableContent' to use depending
* on the php version
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @global boolean whether to use backquotes to allow the use of special
* characters in database, table and fields names or not
* @global integer the number of records
* @global integer the current record position
*
* @access public
*
* @see PMA_getTableContentFast(), PMA_getTableContentOld()
*
* @author staybyte
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $sql_backquotes;
global $rows_cnt;
global $current_row;
$formatted_table_name = isset($GLOBALS['sql_backquotes']) ? PMA_backquote($table) : '\'' . $table . '\'';
$head = $crlf . $GLOBALS['comment_marker'] . $crlf . $GLOBALS['comment_marker'] . $GLOBALS['strDumpingData'] . ' ' . $formatted_table_name . $crlf . $GLOBALS['comment_marker'] . $crlf . $crlf;
if (!PMA_exportOutputHandler($head)) {
return FALSE;
}
$buffer = '';
// 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_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
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_backquote($analyzed_sql[0]['select_expr'][$j]['column'], $sql_backquotes);
} else {
$field_set[$j] = PMA_backquote($fields_meta[$j]->name, $sql_backquotes);
}
}
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
// update
$schema_insert = 'UPDATE ';
if (isset($GLOBALS['sql_ignore'])) {
$schema_insert .= 'IGNORE ';
}
$schema_insert .= PMA_backquote($table, $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';
}
// scheme for inserting fields
if (isset($GLOBALS['sql_columns'])) {
$fields = implode(', ', $field_set);
$schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $sql_backquotes) . ' (' . $fields . ') VALUES ';
} else {
$schema_insert = $sql_command . $insert_delayed . ' INTO ' . PMA_backquote($table, $sql_backquotes) . ' VALUES ';
}
}
$search = array("", "\n", "\r", "");
//\x08\\x09, not required
$replace = array('\\0', '\\n', '\\r', '\\Z');
$current_row = 0;
$query_size = 0;
if (isset($GLOBALS['sql_extended']) && (!isset($GLOBALS['sql_type']) || $GLOBALS['sql_type'] != 'UPDATE')) {
$separator = ',';
$schema_insert .= $crlf;
} else {
$separator = ';';
}
while ($row = PMA_DBI_fetch_row($result)) {
$current_row++;
for ($j = 0; $j < $fields_cnt; $j++) {
//.........这里部分代码省略.........
示例11: PMA_exportData
/**
* Outputs the content of a table in ODS 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
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$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);
}
$GLOBALS['ods_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '">';
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
}
// end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
}
// end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['ods_buffer'] .= '<table:table-row>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "date") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d", strtotime($row[$j])) . '" table:style-name="DateCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "time") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="time" office:time-value="' . date("\\P\\TH\\Hi\\Ms\\S", strtotime($row[$j])) . '" table:style-name="TimeCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->type == "datetime") {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="date" office:date-value="' . date("Y-m-d\\TH:i:s", strtotime($row[$j])) . '" table:style-name="DateTimeCell">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} else {
$GLOBALS['ods_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
}
}
// end for
$GLOBALS['ods_buffer'] .= '</table:table-row>';
}
// end while
PMA_DBI_free_result($result);
$GLOBALS['ods_buffer'] .= '</table:table>';
return true;
}
示例12: PMA_DBI_get_fields_meta
function PMA_DBI_get_fields_meta($result)
{
// Build an associative array for a type look up
$typeAr = array();
$typeAr[MYSQLI_TYPE_DECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_NEWDECIMAL] = 'real';
$typeAr[MYSQLI_TYPE_BIT] = 'bool';
$typeAr[MYSQLI_TYPE_TINY] = 'int';
$typeAr[MYSQLI_TYPE_SHORT] = 'int';
$typeAr[MYSQLI_TYPE_LONG] = 'int';
$typeAr[MYSQLI_TYPE_FLOAT] = 'real';
$typeAr[MYSQLI_TYPE_DOUBLE] = 'real';
$typeAr[MYSQLI_TYPE_NULL] = 'null';
$typeAr[MYSQLI_TYPE_TIMESTAMP] = 'timestamp';
$typeAr[MYSQLI_TYPE_LONGLONG] = 'int';
$typeAr[MYSQLI_TYPE_INT24] = 'int';
$typeAr[MYSQLI_TYPE_DATE] = 'date';
$typeAr[MYSQLI_TYPE_TIME] = 'time';
$typeAr[MYSQLI_TYPE_DATETIME] = 'datetime';
$typeAr[MYSQLI_TYPE_YEAR] = 'year';
$typeAr[MYSQLI_TYPE_NEWDATE] = 'date';
$typeAr[MYSQLI_TYPE_ENUM] = 'unknown';
$typeAr[MYSQLI_TYPE_SET] = 'unknown';
$typeAr[MYSQLI_TYPE_TINY_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_MEDIUM_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_LONG_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_BLOB] = 'blob';
$typeAr[MYSQLI_TYPE_VAR_STRING] = 'string';
$typeAr[MYSQLI_TYPE_STRING] = 'string';
$typeAr[MYSQLI_TYPE_CHAR] = 'string';
$typeAr[MYSQLI_TYPE_GEOMETRY] = 'unknown';
$fields = mysqli_fetch_fields($result);
// this happens sometimes (seen under MySQL 4.0.25)
if (!is_array($fields)) {
return FALSE;
}
foreach ($fields as $k => $field) {
$fields[$k]->type = $typeAr[$fields[$k]->type];
$fields[$k]->flags = PMA_DBI_field_flags($result, $k);
// Enhance the field objects for mysql-extension compatibilty
$flags = explode(' ', $fields[$k]->flags);
array_unshift($flags, 'dummy');
$fields[$k]->multiple_key = (int) (array_search('multiple_key', $flags, true) > 0);
$fields[$k]->primary_key = (int) (array_search('primary_key', $flags, true) > 0);
$fields[$k]->unique_key = (int) (array_search('unique_key', $flags, true) > 0);
$fields[$k]->not_null = (int) (array_search('not_null', $flags, true) > 0);
$fields[$k]->unsigned = (int) (array_search('unsigned', $flags, true) > 0);
$fields[$k]->zerofill = (int) (array_search('zerofill', $flags, true) > 0);
$fields[$k]->numeric = (int) (array_search('num', $flags, true) > 0);
$fields[$k]->blob = (int) (array_search('blob', $flags, true) > 0);
}
return $fields;
}
示例13: PMA_displayTableBody
//.........这里部分代码省略.........
// Field to display from the foreign table?
if (isset($map[$meta->name][2]) && strlen($map[$meta->name][2])) {
$dispsql = 'SELECT ' . PMA_backquote($map[$meta->name][2]) . ' FROM ' . PMA_backquote($map[$meta->name][3]) . '.' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i];
$dispresult = PMA_DBI_try_query($dispsql, null, PMA_DBI_QUERY_STORE);
if ($dispresult && PMA_DBI_num_rows($dispresult) > 0) {
list($dispval) = PMA_DBI_fetch_row($dispresult, 0);
} else {
$dispval = $GLOBALS['strLinkNotFound'];
}
@PMA_DBI_free_result($dispresult);
} else {
$dispval = '';
}
// end if... else...
if (isset($GLOBALS['printview']) && $GLOBALS['printview'] == '1') {
$vertical_display['data'][$row_no][$i] .= ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . ' <code>[->' . $dispval . ']</code>';
} else {
$title = !empty($dispval) ? ' title="' . htmlspecialchars($dispval) . '"' : '';
$vertical_display['data'][$row_no][$i] .= '<a href="sql.php?' . PMA_generate_common_url($map[$meta->name][3], $map[$meta->name][0]) . '&pos=0&session_max_rows=' . $session_max_rows . '&dontlimitchars=' . $dontlimitchars . '&sql_query=' . urlencode('SELECT * FROM ' . PMA_backquote($map[$meta->name][0]) . ' WHERE ' . PMA_backquote($map[$meta->name][1]) . ' = ' . $row[$i]) . '"' . $title . '>' . ($transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta)) . '</a>';
}
} else {
$vertical_display['data'][$row_no][$i] .= $transform_function != $default_function ? $transform_function($row[$i], $transform_options, $meta) : $transform_function($row[$i], array(), $meta);
}
$vertical_display['data'][$row_no][$i] .= '</td>' . "\n";
} else {
$vertical_display['data'][$row_no][$i] = ' <td align="right"' . $mouse_events . ' class="' . $class . ' nowrap' . ($condition_field ? ' condition' : '') . '"> </td>' . "\n";
}
// b l o b
} elseif ($GLOBALS['cfg']['ShowBlob'] == false && stristr($meta->type, 'BLOB')) {
// loic1 : PMA_mysql_fetch_fields returns BLOB in place of
// TEXT fields type, however TEXT fields must be displayed
// even if $GLOBALS['cfg']['ShowBlob'] is false -> get the true type
// of the fields.
$field_flags = PMA_DBI_field_flags($dt_result, $i);
if (stristr($field_flags, 'BINARY')) {
$blobtext = '[BLOB';
if (!isset($row[$i]) || is_null($row[$i])) {
$blobtext .= ' - NULL';
$blob_size = 0;
} elseif (isset($row[$i])) {
$blob_size = strlen($row[$i]);
$display_blob_size = PMA_formatByteDown($blob_size, 3, 1);
$blobtext .= ' - ' . $display_blob_size[0] . ' ' . $display_blob_size[1];
unset($display_blob_size);
}
$blobtext .= ']';
if (strpos($transform_function, 'octetstream')) {
$blobtext = $row[$i];
}
if ($blob_size > 0) {
$blobtext = $default_function != $transform_function ? $transform_function($blobtext, $transform_options, $meta) : $default_function($blobtext, array(), $meta);
}
unset($blob_size);
$vertical_display['data'][$row_no][$i] = ' <td align="left"' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $blobtext . '</td>';
} else {
if (!isset($row[$i]) || is_null($row[$i])) {
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '"><i>NULL</i></td>' . "\n";
} elseif ($row[$i] != '') {
// garvin: if a transform function for blob is set, none of these replacements will be made
if (PMA_strlen($row[$i]) > $GLOBALS['cfg']['LimitChars'] && $dontlimitchars != 1) {
$row[$i] = PMA_substr($row[$i], 0, $GLOBALS['cfg']['LimitChars']) . '...';
}
// loic1: displays all space characters, 4 space
// characters for tabulations and <cr>/<lf>
$row[$i] = $default_function != $transform_function ? $transform_function($row[$i], $transform_options, $meta) : $default_function($row[$i], array(), $meta);
$vertical_display['data'][$row_no][$i] = ' <td' . $mouse_events . ' class="' . $class . ($condition_field ? ' condition' : '') . '">' . $row[$i] . '</td>' . "\n";
示例14: PMA_exportData
/**
* Outputs the content of a table in CSV format
*
* @param string the database name
* @param string the table name
* @param string the end of line sequence
* @param string the url to go back in case of error
* @param string SQL query for obtaining data
*
* @return bool Whether it suceeded
*
* @access public
*/
function PMA_exportData($db, $table, $crlf, $error_url, $sql_query)
{
global $what;
// Gets the data from the database
$result = PMA_DBI_query($sql_query, null, PMA_DBI_QUERY_UNBUFFERED);
$fields_cnt = PMA_DBI_num_fields($result);
$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);
}
$GLOBALS['odt_buffer'] .= '<text:h text:outline-level="2" text:style-name="Heading_2" text:is-list-header="true">' . htmlspecialchars(__('Dumping data for table') . ' ' . $table) . '</text:h>';
$GLOBALS['odt_buffer'] .= '<table:table table:name="' . htmlspecialchars($table) . '_structure">';
$GLOBALS['odt_buffer'] .= '<table:table-column table:number-columns-repeated="' . $fields_cnt . '"/>';
// If required, get fields name at the first line
if (isset($GLOBALS[$what . '_columns'])) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
for ($i = 0; $i < $fields_cnt; $i++) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars(stripslashes(PMA_DBI_field_name($result, $i))) . '</text:p>' . '</table:table-cell>';
}
// end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
}
// end if
// Format the data
while ($row = PMA_DBI_fetch_row($result)) {
$GLOBALS['odt_buffer'] .= '<table:table-row>';
for ($j = 0; $j < $fields_cnt; $j++) {
if (!isset($row[$j]) || is_null($row[$j])) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($GLOBALS[$what . '_null']) . '</text:p>' . '</table:table-cell>';
// ignore BLOB
} elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p></text:p>' . '</table:table-cell>';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="float" office:value="' . $row[$j] . '" >' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
} else {
$GLOBALS['odt_buffer'] .= '<table:table-cell office:value-type="string">' . '<text:p>' . htmlspecialchars($row[$j]) . '</text:p>' . '</table:table-cell>';
}
}
// end for
$GLOBALS['odt_buffer'] .= '</table:table-row>';
}
// end while
PMA_DBI_free_result($result);
$GLOBALS['odt_buffer'] .= '</table:table>';
return TRUE;
}
示例15: PMA_getUvaCondition
/**
* Function to generate unique condition for specified row.
*
* @param resource handle for current query
* @param integer number of fields
* @param array meta information about fields
* @param array current row
*
* @access public
* @author Michal Cihar (michal@cihar.com)
* @return string calculated condition
*/
function PMA_getUvaCondition($handle, $fields_cnt, $fields_meta, $row)
{
$primary_key = '';
$unique_key = '';
$uva_nonprimary_condition = '';
for ($i = 0; $i < $fields_cnt; ++$i) {
$field_flags = PMA_DBI_field_flags($handle, $i);
$meta = $fields_meta[$i];
// do not use an alias in a condition
$column_for_condition = $meta->name;
if (isset($analyzed_sql[0]['select_expr']) && is_array($analyzed_sql[0]['select_expr'])) {
foreach ($analyzed_sql[0]['select_expr'] as $select_expr_position => $select_expr) {
$alias = $analyzed_sql[0]['select_expr'][$select_expr_position]['alias'];
if (!empty($alias)) {
$true_column = $analyzed_sql[0]['select_expr'][$select_expr_position]['column'];
if ($alias == $meta->name) {
$column_for_condition = $true_column;
}
// end if
}
// end if
}
// end while
}
// 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') {
$condition = ' CONCAT(' . PMA_backquote($column_for_condition) . ') ';
} else {
// string and blob fields have to be converted using
// the system character set (always utf8) since
// mysql4.1 can use different charset for fields.
if (PMA_MYSQL_INT_VERSION >= 40100 && ($meta->type == 'string' || $meta->type == 'blob')) {
$condition = ' CONVERT(' . PMA_backquote($column_for_condition) . ' USING utf8) ';
} else {
$condition = ' ' . PMA_backquote($column_for_condition) . ' ';
}
}
// end if... else...
if (!isset($row[$i]) || is_null($row[$i])) {
$condition .= 'IS NULL AND';
} else {
// timestamp is numeric on some MySQL 4.1
if ($meta->numeric && $meta->type != 'timestamp') {
$condition .= '= ' . $row[$i] . ' AND';
} elseif ($meta->type == 'blob' && stristr($field_flags, 'BINARY') && !empty($row[$i])) {
// use a CAST if possible, to avoid problems
// if the field contains wildcard characters % or _
if (PMA_MYSQL_INT_VERSION < 40002) {
$condition .= 'LIKE 0x' . bin2hex($row[$i]) . ' AND';
} else {
$condition .= '= CAST(0x' . bin2hex($row[$i]) . ' AS BINARY) AND';
}
} else {
$condition .= '= \'' . PMA_sqlAddslashes($row[$i], FALSE, TRUE) . '\' AND';
}
}
if ($meta->primary_key > 0) {
$primary_key .= $condition;
} else {
if ($meta->unique_key > 0) {
$unique_key .= $condition;
}
}
$uva_nonprimary_condition .= $condition;
}
// end for
// Correction uva 19991216: prefer primary or unique keys
// for condition, but use conjunction of all values if no
// primary key
if ($primary_key) {
$uva_condition = $primary_key;
} else {
if ($unique_key) {
$uva_condition = $unique_key;
} else {
$uva_condition = $uva_nonprimary_condition;
}
}
return preg_replace('|\\s?AND$|', '', $uva_condition);
}