本文整理汇总了PHP中PMA_Util::printableBitValue方法的典型用法代码示例。如果您正苦于以下问题:PHP PMA_Util::printableBitValue方法的具体用法?PHP PMA_Util::printableBitValue怎么用?PHP PMA_Util::printableBitValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PMA_Util
的用法示例。
在下文中一共展示了PMA_Util::printableBitValue方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_TableSearch
$table_search = new PMA_TableSearch($db, $table, "zoom");
/**
* Handle AJAX request for data row on point select
* @var post_params Object containing parameters for the POST request
*/
if (isset($_REQUEST['get_data_row']) && $_REQUEST['get_data_row'] == true) {
$extra_data = array();
$row_info_query = 'SELECT * FROM `' . $_REQUEST['db'] . '`.`' . $_REQUEST['table'] . '` WHERE ' . $_REQUEST['where_clause'];
$result = $GLOBALS['dbi']->query($row_info_query . ";", null, PMA_DatabaseInterface::QUERY_STORE);
$fields_meta = $GLOBALS['dbi']->getFieldsMeta($result);
while ($row = $GLOBALS['dbi']->fetchAssoc($result)) {
// for bit fields we need to convert them to printable form
$i = 0;
foreach ($row as $col => $val) {
if ($fields_meta[$i]->type == 'bit') {
$row[$col] = PMA_Util::printableBitValue($val, $fields_meta[$i]->length);
}
$i++;
}
$extra_data['row_info'] = $row;
}
PMA_Response::getInstance()->addJSON($extra_data);
exit;
}
/**
* Handle AJAX request for changing field information
* (value,collation,operators,field values) in input form
* @var post_params Object containing parameters for the POST request
*/
if (isset($_REQUEST['change_tbl_info']) && $_REQUEST['change_tbl_info'] == true) {
$response = PMA_Response::getInstance();
示例2: _getDataCellForNonNumericColumns
/**
* Get data cell for non numeric type fields
*
* @param string $column the relevant 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 object|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 is data truncated due to
* LimitChars
* @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 _getDataCellForNonNumericColumns($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 = $GLOBALS['dbi']->fieldFlags($dt_result, $col_index);
$bIsText = gettype($transformation_plugin) === 'object' && strpos($transformation_plugin->getMIMEtype(), 'Text') === false;
// disable inline grid editing
// if binary fields are protected
// or transformation plugin is of non text type
// such as image
if (stristr($field_flags, self::BINARY_FIELD) && ($GLOBALS['cfg']['ProtectBinary'] === 'all' || $GLOBALS['cfg']['ProtectBinary'] === 'noblob' && !stristr($meta->type, self::BLOB_FIELD) || $GLOBALS['cfg']['ProtectBinary'] === 'blob' && stristr($meta->type, self::BLOB_FIELD)) || $bIsText) {
$class = str_replace('grid_edit', '', $class);
}
if (!isset($column) || is_null($column)) {
$cell = $this->_buildNullDisplay($class, $condition_field, $meta);
return $cell;
}
if ($column == '') {
$cell = $this->_buildEmptyDisplay($class, $condition_field, $meta);
return $cell;
}
// Cut all fields to $GLOBALS['cfg']['LimitChars']
// (unless it's a link-type transformation or binary)
if (!(gettype($transformation_plugin) === "object" && strpos($transformation_plugin->getName(), 'Link') !== false) && !stristr($field_flags, self::BINARY_FIELD)) {
$is_field_truncated = $this->_getPartialText($column);
}
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = PMA_Util::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) && !(isset($is_analyse) && $is_analyse)) {
// we show the BINARY or BLOB message and field's size
// (or maybe use a transformation)
$binary_or_blob = self::BLOB_FIELD;
if ($meta->type === self::STRING_FIELD) {
$binary_or_blob = self::BINARY_FIELD;
}
$column = $this->_handleNonPrintableContents($binary_or_blob, $column, $transformation_plugin, $transform_options, $default_function, $meta, $_url_params, $is_field_truncated);
$class = $this->_addClass($class, $condition_field, $meta, '', $is_field_truncated, $transformation_plugin, $default_function);
$result = strip_tags($column);
// disable inline grid editing
// if binary or blob data is not shown
if (stristr($result, $binary_or_blob)) {
$class = str_replace('grid_edit', '', $class);
}
$formatted = true;
}
if ($formatted) {
$cell = $this->_buildValueDisplay($class, $condition_field, $column);
return $cell;
}
// 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 = ' = \'' . PMA_Util::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);
return $cell;
}
示例3: exportData
//.........这里部分代码省略.........
}
// We need to SET IDENTITY_INSERT ON for MSSQL
if (isset($GLOBALS['sql_compatibility']) && $GLOBALS['sql_compatibility'] == 'MSSQL' && $current_row == 0) {
if (!PMA_exportOutputHandler('SET IDENTITY_INSERT ' . PMA_Util::backquoteCompat($table, $compat) . ' ON ;' . $crlf)) {
return false;
}
}
$current_row++;
for ($j = 0; $j < $fields_cnt; $j++) {
// NULL
if (!isset($row[$j]) || is_null($row[$j])) {
$values[] = 'NULL';
} elseif ($fields_meta[$j]->numeric && $fields_meta[$j]->type != 'timestamp' && !$fields_meta[$j]->blob) {
// a number
// timestamp is numeric on some MySQL 4.1, BLOBs are
// sometimes numeric
$values[] = $row[$j];
} elseif (stristr($field_flags[$j], 'BINARY') && $fields_meta[$j]->blob && isset($GLOBALS['sql_hex_for_blob'])) {
// a true BLOB
// - mysqldump only generates hex data when the --hex-blob
// option is used, for fields having the binary attribute
// no hex is generated
// - a TEXT field returns type blob but a real blob
// returns also the 'binary' flag
// empty blobs need to be different, but '0' is also empty
// :-(
if (empty($row[$j]) && $row[$j] != '0') {
$values[] = '\'\'';
} else {
$values[] = '0x' . bin2hex($row[$j]);
}
} elseif ($fields_meta[$j]->type == 'bit') {
// detection of 'bit' works only on mysqli extension
$values[] = "b'" . PMA_Util::sqlAddSlashes(PMA_Util::printableBitValue($row[$j], $fields_meta[$j]->length)) . "'";
} else {
// something else -> treat as a string
$values[] = '\'' . str_replace($search, $replace, PMA_Util::sqlAddSlashes($row[$j])) . '\'';
}
// end if
}
// end for
// should we make update?
if (isset($GLOBALS['sql_type']) && $GLOBALS['sql_type'] == 'UPDATE') {
$insert_line = $schema_insert;
for ($i = 0; $i < $fields_cnt; $i++) {
if (0 == $i) {
$insert_line .= ' ';
}
if ($i > 0) {
// avoid EOL blank
$insert_line .= ',';
}
$insert_line .= $field_set[$i] . ' = ' . $values[$i];
}
list($tmp_unique_condition, $tmp_clause_is_unique) = PMA_Util::getUniqueCondition($result, $fields_cnt, $fields_meta, $row);
$insert_line .= ' WHERE ' . $tmp_unique_condition;
unset($tmp_unique_condition, $tmp_clause_is_unique);
} else {
// Extended inserts case
if ($GLOBALS['sql_insert_syntax'] == 'extended' || $GLOBALS['sql_insert_syntax'] == 'both') {
if ($current_row == 1) {
$insert_line = $schema_insert . '(' . implode(', ', $values) . ')';
} else {
$insert_line = '(' . implode(', ', $values) . ')';
$sql_max_size = $GLOBALS['sql_max_query_size'];
if (isset($sql_max_size) && $sql_max_size > 0 && $query_size + strlen($insert_line) > $sql_max_size) {
示例4: _getDataCellForNonNumericAndNonBlobColumns
/**
* Get data cell for non numeric and non blob type fields
*
* @param string $column the relevant 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)
{
$limitChars = $GLOBALS['cfg']['LimitChars'];
$is_analyse = $this->__get('is_analyse');
$field_flags = $GLOBALS['dbi']->fieldFlags($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 ($GLOBALS['PMA_String']->strlen($column) > $limitChars && $_SESSION['tmpval']['pftext'] == self::DISPLAY_PARTIAL_TEXT && !(gettype($transformation_plugin) == "object" && strpos($transformation_plugin->getName(), 'Link') !== false)) {
$column = $GLOBALS['PMA_String']->substr($column, 0, $GLOBALS['cfg']['LimitChars']) . '...';
$is_field_truncated = true;
}
$formatted = false;
if (isset($meta->_type) && $meta->_type === MYSQLI_TYPE_BIT) {
$column = PMA_Util::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['tmpval']['display_binary']) {
// user asked to see the real contents of BINARY
// fields
$column = $this->_displayBinaryAsPrintable($column, 'binary');
} 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;
}
} elseif ((substr($meta->type, 0, 9) == self::TIMESTAMP_FIELD || $meta->type == self::DATETIME_FIELD || $meta->type == self::TIME_FIELD || $meta->type == self::TIME_FIELD) && strpos($column, ".") === true) {
$column = PMA_Util::addMicroseconds($column);
}
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 = ' = \'' . PMA_Util::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;
}
示例5: PMA_getSpecialCharsAndBackupFieldForExistingRow
/**
* Prepares the field value and retrieve special chars, backup field and data array
*
* @param array $current_row a row of the table
* @param array $column description of column in given table
* @param array $extracted_columnspec associative array containing type,
* spec_in_brackets and possibly
* enum_set_values (another array)
* @param boolean $real_null_value whether column value null or not null
* @param array $gis_data_types list of GIS data types
* @param string $column_name_appendix string to append to column name in input
* @param bool $as_is use the data as is, used in repopulating
*
* @return array $real_null_value, $data, $special_chars, $backup_field,
* $special_chars_encoded
*/
function PMA_getSpecialCharsAndBackupFieldForExistingRow($current_row, $column, $extracted_columnspec, $real_null_value, $gis_data_types, $column_name_appendix, $as_is)
{
$special_chars_encoded = '';
$data = null;
// (we are editing)
if (!isset($current_row[$column['Field']])) {
$real_null_value = true;
$current_row[$column['Field']] = '';
$special_chars = '';
$data = $current_row[$column['Field']];
} elseif ($column['True_Type'] == 'bit') {
$special_chars = $as_is ? $current_row[$column['Field']] : PMA_Util::printableBitValue($current_row[$column['Field']], $extracted_columnspec['spec_in_brackets']);
} elseif ((substr($column['True_Type'], 0, 9) == 'timestamp' || $column['True_Type'] == 'datetime' || $column['True_Type'] == 'time') && mb_strpos($current_row[$column['Field']], ".") !== false) {
$current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : PMA_Util::addMicroseconds($current_row[$column['Field']]);
$special_chars = htmlspecialchars($current_row[$column['Field']]);
} elseif (in_array($column['True_Type'], $gis_data_types)) {
// Convert gis data to Well Know Text format
$current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : PMA_Util::asWKT($current_row[$column['Field']], true);
$special_chars = htmlspecialchars($current_row[$column['Field']]);
} else {
// special binary "characters"
if ($column['is_binary'] || $column['is_blob'] && $GLOBALS['cfg']['ProtectBinary'] !== 'all') {
$current_row[$column['Field']] = $as_is ? $current_row[$column['Field']] : bin2hex($current_row[$column['Field']]);
}
// end if
$special_chars = htmlspecialchars($current_row[$column['Field']]);
//We need to duplicate the first \n or otherwise we will lose
//the first newline entered in a VARCHAR or TEXT column
$special_chars_encoded = PMA_Util::duplicateFirstNewline($special_chars);
$data = $current_row[$column['Field']];
}
// end if... else...
//when copying row, it is useful to empty auto-increment column
// to prevent duplicate key error
if (isset($_REQUEST['default_action']) && $_REQUEST['default_action'] === 'insert') {
if ($column['Key'] === 'PRI' && mb_strpos($column['Extra'], 'auto_increment') !== false) {
$data = $special_chars_encoded = $special_chars = null;
}
}
// If a timestamp field value is not included in an update
// statement MySQL auto-update it to the current timestamp;
// however, things have changed since MySQL 4.1, so
// it's better to set a fields_prev in this situation
$backup_field = '<input type="hidden" name="fields_prev' . $column_name_appendix . '" value="' . htmlspecialchars($current_row[$column['Field']]) . '" />';
return array($real_null_value, $special_chars_encoded, $special_chars, $data, $backup_field);
}
示例6: testPrintableBitValue
/**
* test for generating string contains printable bit value of selected data
*
* @param number $a Value
* @param int $b Length
* @param string $e Expected output
*
* @return void
*
* @dataProvider printableBitValueDataProvider
*/
public function testPrintableBitValue($a, $b, $e)
{
$this->assertEquals($e, PMA_Util::printableBitValue($a, $b));
}