本文整理汇总了PHP中PMA_DBI_get_fields函数的典型用法代码示例。如果您正苦于以下问题:PHP PMA_DBI_get_fields函数的具体用法?PHP PMA_DBI_get_fields怎么用?PHP PMA_DBI_get_fields使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PMA_DBI_get_fields函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: PMA_DBI_query
/**
* Prepares the form
*/
$tbl_result = PMA_DBI_query('SHOW TABLES FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE);
$tbl_result_cnt = PMA_DBI_num_rows($tbl_result);
if (0 == $tbl_result_cnt) {
echo '<div class="warning">' . $strNoTablesFound . '</div>';
require_once './libs/footer.inc.php';
exit;
}
$i = 0;
$k = 0;
// The tables list gets from MySQL
while ($i < $tbl_result_cnt) {
list($tbl) = PMA_DBI_fetch_row($tbl_result);
$fld_results = PMA_DBI_get_fields($db, $tbl);
$fld_results_cnt = $fld_results ? count($fld_results) : 0;
$j = 0;
if (empty($tbl_names[$tbl]) && !empty($TableList)) {
$tbl_names[$tbl] = '';
} else {
$tbl_names[$tbl] = ' selected="selected"';
}
// end if
// The fields list per selected tables
if ($tbl_names[$tbl] == ' selected="selected"') {
$fld[$k++] = PMA_backquote($tbl) . '.*';
while ($j < $fld_results_cnt) {
$fld[$k] = PMA_convert_display_charset($fld_results[$j]['Field']);
$fld[$k] = PMA_backquote($tbl) . '.' . PMA_backquote($fld[$k]);
// increase the width if necessary
示例2: PMA_mysqlDie
} else {
PMA_mysqlDie('', '', '', $err_url, false);
// garvin: An error happened while inserting/updating a table definition.
// to prevent total loss of that data, we embed the form once again.
// The variable $regenerate will be used to restore data in libs/tbl_properties.inc.php
$num_fields = $orig_num_fields;
$regenerate = true;
}
}
// end do create table
/**
* Displays the form used to define the structure of the table
*/
if ($abort == false) {
if (isset($num_fields)) {
$num_fields = intval($num_fields);
}
// No table name
if (!isset($table) || trim($table) == '') {
PMA_mysqlDie($strTableEmpty, '', '', $err_url);
} elseif (empty($num_fields) || !is_int($num_fields)) {
PMA_mysqlDie($strFieldsEmpty, '', '', $err_url);
} elseif (!(PMA_DBI_get_fields($db, $table) === false)) {
PMA_mysqlDie(sprintf($strTableAlreadyExists, htmlspecialchars($table)), '', '', $err_url);
} else {
$action = 'tbl_create.php';
require './libs/tbl_properties.inc.php';
// Displays the footer
require_once './libs/footer.inc.php';
}
}
示例3: PMA_displayLoginInformationFields
/**
* Displays the fields used by the "new user" form as well as the
* "change login information / copy user" form.
*
* @param string $mode are we creating a new user or are we just
* changing one? (allowed values: 'new', 'change')
* @param int $indent the indenting level of the code
*
* @global array $cfg the phpMyAdmin configuration
* @global ressource $user_link the database connection
*
* @return void
*/
function PMA_displayLoginInformationFields($mode = 'new', $indent = 0)
{
$spaces = str_repeat(' ', $indent);
// Get user/host name lengths
$fields_info = PMA_DBI_get_fields('mysql', 'user');
$username_length = 16;
$hostname_length = 41;
foreach ($fields_info as $key => $val) {
if ($val['Field'] == 'User') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$hostname_length = $v;
}
}
}
unset($fields_info);
if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
$GLOBALS['pred_username'] = 'any';
}
echo $spaces . '<fieldset id="fieldset_add_user_login">' . "\n" . $spaces . '<legend>' . $GLOBALS['strLoginInformation'] . '</legend>' . "\n" . $spaces . '<div class="item">' . "\n" . $spaces . '<label for="select_pred_username">' . "\n" . $spaces . ' ' . $GLOBALS['strUserName'] . ':' . "\n" . $spaces . '</label>' . "\n" . $spaces . '<span class="options">' . "\n" . $spaces . ' <select name="pred_username" id="select_pred_username" title="' . $GLOBALS['strUserName'] . '"' . "\n" . $spaces . ' onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . "\n" . $spaces . ' <option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyUser'] . '</option>' . "\n" . $spaces . ' <option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n" . $spaces . ' </select>' . "\n" . $spaces . '</span>' . "\n" . $spaces . '<input type="text" name="username" maxlength="' . $username_length . '" title="' . $GLOBALS['strUserName'] . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . (isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\';" />' . "\n" . $spaces . '</div>' . "\n" . $spaces . '<div class="item">' . "\n" . $spaces . '<label for="select_pred_hostname">' . "\n" . $spaces . ' ' . $GLOBALS['strHost'] . ':' . "\n" . $spaces . '</label>' . "\n" . $spaces . '<span class="options">' . "\n" . $spaces . ' <select name="pred_hostname" id="select_pred_hostname" title="' . $GLOBALS['strHost'] . '"' . "\n";
$res = PMA_DBI_query('SELECT USER();');
$row = PMA_DBI_fetch_row($res);
PMA_DBI_free_result($res);
unset($res);
if (!empty($row[0])) {
$thishost = str_replace("'", '', substr($row[0], strrpos($row[0], '@') + 1));
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
unset($thishost);
}
}
echo $spaces . ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } ' . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ') . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
unset($row);
// when we start editing a user, $GLOBALS['pred_hostname'] is not defined
if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
switch (strtolower($GLOBALS['hostname'])) {
case 'localhost':
case '127.0.0.1':
$GLOBALS['pred_hostname'] = 'localhost';
break;
case '%':
$GLOBALS['pred_hostname'] = 'any';
break;
default:
$GLOBALS['pred_hostname'] = 'userdefined';
break;
}
}
echo $spaces . ' <option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . $GLOBALS['strAnyHost'] . '</option>' . "\n" . $spaces . ' <option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . $GLOBALS['strLocalhost'] . '</option>' . "\n";
if (!empty($thishost)) {
echo $spaces . ' <option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . $GLOBALS['strThisHost'] . '</option>' . "\n";
}
unset($thishost);
echo $spaces . ' <option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseHostTable'] . '</option>' . "\n" . $spaces . ' <option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n" . $spaces . ' </select>' . "\n" . $spaces . '</span>' . "\n" . $spaces . '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . (isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '') . '" title="' . $GLOBALS['strHost'] . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n" . $spaces . '</div>' . "\n" . $spaces . '<div class="item">' . "\n" . $spaces . '<label for="select_pred_password">' . "\n" . $spaces . ' ' . $GLOBALS['strPassword'] . ':' . "\n" . $spaces . '</label>' . "\n" . $spaces . '<span class="options">' . "\n" . $spaces . ' <select name="pred_password" id="select_pred_password" title="' . $GLOBALS['strPassword'] . '"' . "\n" . $spaces . ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . "\n" . ($mode == 'change' ? $spaces . ' <option value="keep" selected="selected">' . $GLOBALS['strKeepPass'] . '</option>' . "\n" : '') . $spaces . ' <option value="none"';
if (isset($GLOBALS['username']) && $mode != 'change') {
echo ' selected="selected"';
}
echo $spaces . '>' . $GLOBALS['strNoPassword'] . '</option>' . "\n" . $spaces . ' <option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . $GLOBALS['strUseTextField'] . ':</option>' . "\n" . $spaces . ' </select>' . "\n" . $spaces . '</span>' . "\n" . $spaces . '<input type="password" id="text_pma_pw" name="pma_pw" title="' . $GLOBALS['strPassword'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n" . $spaces . '</div>' . "\n" . $spaces . '<div class="item">' . "\n" . $spaces . '<label for="text_pma_pw2">' . "\n" . $spaces . ' ' . $GLOBALS['strReType'] . ':' . "\n" . $spaces . '</label>' . "\n" . $spaces . '<span class="options"> </span>' . "\n" . $spaces . '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . $GLOBALS['strReType'] . '" onchange="pred_password.value = \'userdefined\';" />' . "\n" . $spaces . '</div>' . "\n" . $spaces . '<div class="item">' . "\n" . $spaces . '<label for="button_generate_password">' . "\n" . $spaces . ' ' . $GLOBALS['strGeneratePassword'] . ':' . "\n" . $spaces . '</label>' . "\n" . $spaces . '<span class="options">' . "\n" . $spaces . ' <input type="button" id="button_generate_password" value="' . $GLOBALS['strGenerate'] . '" onclick="suggestPassword()" />' . "\n" . $spaces . ' <input type="button" id="button_copy_password" value="' . $GLOBALS['strCopy'] . '" onclick="suggestPasswordCopy(this.form)" />' . "\n" . $spaces . '</span>' . "\n" . $spaces . '<input type="text" name="generated_pw" id="generated_pw" />' . "\n" . $spaces . '</div>' . "\n" . $spaces . '</fieldset>' . "\n";
}
示例4: array
* Displays index edit/creation form and handles it
*
* @version $Id: tbl_indexes.php 30792 2010-03-05 22:55:26Z mehrwert $
* @package phpMyAdmin
*/
/**
* Gets some core libraries
*/
require_once './libraries/common.inc.php';
require_once './libraries/Index.class.php';
require_once './libraries/tbl_common.php';
// Get fields and stores their name/type
$fields = array();
foreach (PMA_DBI_get_fields($db, $table) as $row) {
if (preg_match('@^(set|enum)\((.+)\)$@i', $row['Type'], $tmp)) {
$tmp[2] = substr(preg_replace('@([^,])\'\'@', '\\1\\\'',
',' . $tmp[2]), 1);
$fields[$row['Field']] = $tmp[1] . '(' . str_replace(',', ', ', $tmp[2]) . ')';
} else {
$fields[$row['Field']] = $row['Type'];
}
} // end while
// Prepares the form values
if (isset($_REQUEST['index'])) {
if (is_array($_REQUEST['index'])) {
// coming already from form
$index = new PMA_Index($_REQUEST['index']);
} else {
示例5: PMA_getComments
/**
* Gets the comments for all rows of a table
*
* @param string the name of the db to check for
* @param string the name of the table to check for
*
* @return array [field_name] = comment
*
* @global array the list of relations settings
*
* @access public
*
* @authors Mike Beck <mikebeck@users.sourceforge.net>
* and lem9
*/
function PMA_getComments($db, $table = '')
{
global $cfgRelation;
if ($table != '') {
// MySQL 4.1.x native column comments
if (PMA_MYSQL_INT_VERSION >= 40100) {
$fields = PMA_DBI_get_fields($db, $table);
if ($fields) {
foreach ($fields as $key => $field) {
$tmp_col = $field['Field'];
if (!empty($field['Comment'])) {
$native_comment[$tmp_col] = $field['Comment'];
}
}
if (isset($native_comment)) {
$comment = $native_comment;
}
}
}
// pmadb internal column comments
// (this function can be called even if $cfgRelation['commwork'] is
// FALSE, to get native column comments, so recheck here)
if ($cfgRelation['commwork']) {
$com_qry = '
SELECT column_name,
comment
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'
AND table_name = \'' . PMA_sqlAddslashes($table) . '\'';
$com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
}
} else {
// pmadb internal db comments
$com_qry = '
SELECT ' . PMA_backquote('comment') . '
FROM ' . PMA_backquote($cfgRelation['db']) . '.' . PMA_backquote($cfgRelation['column_info']) . '
WHERE db_name = \'' . PMA_sqlAddslashes($db) . '\'
AND table_name = \'\'
AND column_name = \'(db_comment)\'';
$com_rs = PMA_query_as_cu($com_qry, TRUE, PMA_DBI_QUERY_STORE);
}
if (isset($com_rs) && PMA_DBI_num_rows($com_rs) > 0) {
$i = 0;
while ($row = PMA_DBI_fetch_assoc($com_rs)) {
$i++;
$col = $table != '' ? $row['column_name'] : $i;
if (strlen($row['comment']) > 0) {
$comment[$col] = $row['comment'];
// if this version supports native comments and this function
// was called with a table parameter
if (PMA_MYSQL_INT_VERSION >= 40100 && isset($table) && strlen($table)) {
// if native comment found, use it instead of pmadb
if (!empty($native_comment[$col])) {
$comment[$col] = $native_comment[$col];
} else {
// no native comment, so migrate pmadb-style to native
PMA_setComment($db, $table, $col, $comment[$col], '', 'native');
// and erase the pmadb-style comment
PMA_setComment($db, $table, $col, '', '', 'pmadb');
}
}
}
}
// end while
PMA_DBI_free_result($com_rs);
unset($com_rs);
}
if (isset($comment) && is_array($comment)) {
return $comment;
} else {
return FALSE;
}
}
示例6: elseif
} elseif (strlen($csv_new_line) != 1 && $csv_new_line != 'auto') {
$message = PMA_Message::error('strInvalidCSVParameter');
$message->addParam('strLinesTerminatedBy', false);
$error = TRUE;
}
$buffer = '';
if (isset($csv_replace)) {
$sql_template = 'REPLACE';
} else {
$sql_template = 'INSERT';
if (isset($csv_ignore)) {
$sql_template .= ' IGNORE';
}
}
$sql_template .= ' INTO ' . PMA_backquote($table);
$tmp_fields = PMA_DBI_get_fields($db, $table);
if (empty($csv_columns)) {
$fields = $tmp_fields;
} else {
$sql_template .= ' (';
$fields = array();
$tmp = split(',( ?)', $csv_columns);
foreach ($tmp as $key => $val) {
if (count($fields) > 0) {
$sql_template .= ', ';
}
/* Trim also `, if user already included backquoted fields */
$val = trim($val, " \t\r\n\v`");
$found = FALSE;
foreach ($tmp_fields as $id => $field) {
if ($field['Field'] == $val) {
示例7: PMA_getComments
/**
* Gets the comments for all rows of a table or the db itself
*
* @author Mike Beck <mikebeck@users.sourceforge.net>
* @author lem9
* @access public
* @uses PMA_DBI_get_fields()
* @uses PMA_getDbComment()
* @param string the name of the db to check for
* @param string the name of the table to check for
* @return array [field_name] = comment
*/
function PMA_getComments($db, $table = '')
{
$comments = array();
if ($table != '') {
// MySQL native column comments
$fields = PMA_DBI_get_fields($db, $table);
if ($fields) {
foreach ($fields as $key => $field) {
if (! empty($field['Comment'])) {
$comments[$field['Field']] = $field['Comment'];
}
}
}
} else {
$comments[] = PMA_getDbComment($db);
}
return $comments;
} // end of the 'PMA_getComments()' function
示例8: PMA_createTargetTables
/**
* PMA_createTargetTables() Create the missing table $uncommon_table in target database
*
* @uses PMA_DBI_get_fields()
* @uses PMA_backquote()
* @uses PMA_DBI_fetch_result()
*
* @param $src_db name of source database
* @param $trg_db name of target database
* @param $trg_link connection established with target server
* @param $src_link connection established with source server
* @param $uncommon_table name of table present in source but not in target
* @param $table_index index of table in matching_table_array
* @param $uncommon_tables_fields field names of the uncommon table
* @param $display true/false value
*/
function PMA_createTargetTables($src_db, $trg_db, $src_link, $trg_link, &$uncommon_tables, $table_index, &$uncommon_tables_fields, $display)
{
if (isset($uncommon_tables[$table_index])) {
$fields_result = PMA_DBI_get_fields($src_db, $uncommon_tables[$table_index], $src_link);
$fields = array();
foreach ($fields_result as $each_field) {
$field_name = $each_field['Field'];
$fields[] = $field_name;
}
$uncommon_tables_fields[$table_index] = $fields;
$Create_Query = PMA_DBI_fetch_value("SHOW CREATE TABLE " . PMA_backquote($src_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), 0, 1, $src_link);
// Replace the src table name with a `dbname`.`tablename`
$Create_Table_Query = preg_replace('/' . PMA_backquote($uncommon_tables[$table_index]) . '/', PMA_backquote($trg_db) . '.' . PMA_backquote($uncommon_tables[$table_index]), $Create_Query, $limit = 1);
$is_fk_query = "SELECT * FROM information_schema.KEY_COLUMN_USAGE WHERE TABLE_SCHEMA = '" . $src_db . "' \n AND TABLE_NAME = '" . $uncommon_tables[$table_index] . "' AND TABLE_NAME <> REFERENCED_TABLE_NAME;";
$is_fk_result = PMA_DBI_fetch_result($is_fk_query, null, null, $src_link);
if (sizeof($is_fk_result) > 0) {
for ($j = 0; $j < sizeof($is_fk_result); $j++) {
if (in_array($is_fk_result[$j]['REFERENCED_TABLE_NAME'], $uncommon_tables)) {
$table_index = array_keys($uncommon_tables, $is_fk_result[$j]['REFERENCED_TABLE_NAME']);
PMA_createTargetTables($src_db, $trg_db, $trg_link, $src_link, $uncommon_tables, $table_index[0], $uncommon_tables_fields, $display);
unset($uncommon_tables[$table_index[0]]);
}
}
}
if ($display == true) {
echo '<p>' . $Create_Table_Query . '</p>';
}
PMA_DBI_try_query($Create_Table_Query, $trg_link, 0);
}
}
示例9: PMA_setComment
/**
* Set a single comment to a certain value.
*
* @param string the name of the db
* @param string the name of the table (may be empty in case of a db comment)
* @param string the name of the column
* @param string the value of the column
* @param string (optional) if a column is renamed, this is the name of the former key which will get deleted
* @param string whether we set pmadb comments, native comments or both
*
* @return boolean true, if comment-query was made.
*
* @global array the list of relations settings
*
* @access public
*/
function PMA_setComment($db, $table, $col, $comment, $removekey = '', $mode = 'auto')
{
global $cfgRelation;
if ($mode == 'auto') {
if (PMA_MYSQL_INT_VERSION >= 40100) {
$mode = 'native';
} else {
$mode = 'pmadb';
}
}
// native mode is only for column comments so we need a table name
if ($mode == 'native' && !empty($table)) {
$fields = PMA_DBI_get_fields($db, $table);
// Get more complete field information
// For now, this is done just for MySQL 4.1.2+ new TIMESTAMP options
// but later, if the analyser returns more information, it
// could be executed for any MySQL version and replace
// the info given by SHOW FULL FIELDS FROM.
// TODO: put this code into a require()
// or maybe make it part of PMA_DBI_get_fields();
if (PMA_MYSQL_INT_VERSION >= 40102) {
$show_create_table_query = 'SHOW CREATE TABLE ' . PMA_backquote($db) . '.' . PMA_backquote($table);
$show_create_table_res = PMA_DBI_query($show_create_table_query);
list(, $show_create_table) = PMA_DBI_fetch_row($show_create_table_res);
PMA_DBI_free_result($show_create_table_res);
unset($show_create_table_res, $show_create_table_query);
$analyzed_sql = PMA_SQP_analyze(PMA_SQP_parse($show_create_table));
}
// TODO: get directly the information of $col
foreach ($fields as $key => $field) {
$tmp_col = $field['Field'];
$types[$tmp_col] = $field['Type'];
$collations[$tmp_col] = $field['Collation'];
$nulls[$tmp_col] = $field['Null'];
$defaults[$tmp_col] = $field['Default'];
$extras[$tmp_col] = $field['Extra'];
if (PMA_MYSQL_INT_VERSION >= 40102 && isset($analyzed_sql[0]['create_table_fields'][$tmp_col]['on_update_current_timestamp'])) {
$extras[$tmp_col] = 'ON UPDATE CURRENT_TIMESTAMP';
}
if (PMA_MYSQL_INT_VERSION >= 40102 && isset($analyzed_sql[0]['create_table_fields'][$tmp_col]['default_current_timestamp'])) {
$default_current_timestamps[$tmp_col] = TRUE;
} else {
$default_current_timestamps[$tmp_col] = FALSE;
}
if ($tmp_col == $col) {
break;
}
}
if ($nulls[$col] == 'YES') {
$nulls[$col] = '';
} else {
$nulls[$col] = 'NOT NULL';
}
$query = 'ALTER TABLE ' . PMA_backquote($table) . ' CHANGE ' . PMA_generateAlterTable($col, $col, $types[$col], $collations[$col], $nulls[$col], $defaults[$col], $default_current_timestamps[$col], $extras[$col], $comment);
PMA_DBI_try_query($query, NULL, PMA_DBI_QUERY_STORE);
return TRUE;
}
// $mode == 'pmadb' section:
$cols = array('db_name' => 'db_name ', 'table_name' => 'table_name ', 'column_name' => 'column_name');
if ($removekey != '' and $removekey != $col) {
$remove_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) . ' WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($removekey) . '\'';
PMA_query_as_cu($remove_query);
unset($remove_query);
}
$test_qry = 'SELECT ' . PMA_backquote('comment') . ', mimetype, transformation, transformation_options FROM ' . PMA_backquote($cfgRelation['column_info']) . ' WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';
$test_rs = PMA_query_as_cu($test_qry, TRUE, PMA_DBI_QUERY_STORE);
if ($test_rs && PMA_DBI_num_rows($test_rs) > 0) {
$row = PMA_DBI_fetch_assoc($test_rs);
PMA_DBI_free_result($test_rs);
if (strlen($comment) > 0 || strlen($row['mimetype']) > 0 || strlen($row['transformation']) > 0 || strlen($row['transformation_options']) > 0) {
$upd_query = 'UPDATE ' . PMA_backquote($cfgRelation['column_info']) . ' SET ' . PMA_backquote('comment') . ' = \'' . PMA_sqlAddslashes($comment) . '\'' . ' WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddSlashes($col) . '\'';
} else {
$upd_query = 'DELETE FROM ' . PMA_backquote($cfgRelation['column_info']) . ' WHERE ' . $cols['db_name'] . ' = \'' . PMA_sqlAddslashes($db) . '\'' . ' AND ' . $cols['table_name'] . ' = \'' . PMA_sqlAddslashes($table) . '\'' . ' AND ' . $cols['column_name'] . ' = \'' . PMA_sqlAddslashes($col) . '\'';
}
} else {
if (strlen($comment) > 0) {
$upd_query = 'INSERT INTO ' . PMA_backquote($cfgRelation['column_info']) . ' (db_name, table_name, column_name, ' . PMA_backquote('comment') . ') ' . ' VALUES(' . '\'' . PMA_sqlAddslashes($db) . '\',' . '\'' . PMA_sqlAddslashes($table) . '\',' . '\'' . PMA_sqlAddslashes($col) . '\',' . '\'' . PMA_sqlAddslashes($comment) . '\')';
}
}
if (isset($upd_query)) {
$upd_rs = PMA_query_as_cu($upd_query);
unset($upd_query);
return true;
} else {
//.........这里部分代码省略.........
示例10: PMA_displayLoginInformationFields
/**
* Displays the fields used by the "new user" form as well as the
* "change login information / copy user" form.
*
* @param string $mode are we creating a new user or are we just
* changing one? (allowed values: 'new', 'change')
* @global array $cfg the phpMyAdmin configuration
* @global ressource $user_link the database connection
*
* @return void
*/
function PMA_displayLoginInformationFields($mode = 'new')
{
// Get user/host name lengths
$fields_info = PMA_DBI_get_fields('mysql', 'user');
$username_length = 16;
$hostname_length = 41;
foreach ($fields_info as $key => $val) {
if ($val['Field'] == 'User') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$hostname_length = $v;
}
}
}
unset($fields_info);
if (isset($GLOBALS['username']) && strlen($GLOBALS['username']) === 0) {
$GLOBALS['pred_username'] = 'any';
}
echo '<fieldset id="fieldset_add_user_login">' . "\n" . '<legend>' . __('Login Information') . '</legend>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_username">' . "\n" . ' ' . __('User name') . ':' . "\n" . '</label>' . "\n" . '<span class="options">' . "\n" . ' <select name="pred_username" id="select_pred_username" title="' . __('User name') . '"' . "\n" . ' onchange="if (this.value == \'any\') { username.value = \'\'; } else if (this.value == \'userdefined\') { username.focus(); username.select(); }">' . "\n" . ' <option value="any"' . (isset($GLOBALS['pred_username']) && $GLOBALS['pred_username'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any user') . '</option>' . "\n" . ' <option value="userdefined"' . (!isset($GLOBALS['pred_username']) || $GLOBALS['pred_username'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . "\n" . ' </select>' . "\n" . '</span>' . "\n" . '<input type="text" name="username" maxlength="' . $username_length . '" title="' . __('User name') . '"' . (empty($GLOBALS['username']) ? '' : ' value="' . htmlspecialchars(isset($GLOBALS['new_username']) ? $GLOBALS['new_username'] : $GLOBALS['username']) . '"') . ' onchange="pred_username.value = \'userdefined\';" />' . "\n" . '</div>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_hostname">' . "\n" . ' ' . __('Host') . ':' . "\n" . '</label>' . "\n" . '<span class="options">' . "\n" . ' <select name="pred_hostname" id="select_pred_hostname" title="' . __('Host') . '"' . "\n";
$_current_user = PMA_DBI_fetch_value('SELECT USER();');
if (!empty($_current_user)) {
$thishost = str_replace("'", '', substr($_current_user, strrpos($_current_user, '@') + 1));
if ($thishost == 'localhost' || $thishost == '127.0.0.1') {
unset($thishost);
}
}
echo ' onchange="if (this.value == \'any\') { hostname.value = \'%\'; } else if (this.value == \'localhost\') { hostname.value = \'localhost\'; } ' . (empty($thishost) ? '' : 'else if (this.value == \'thishost\') { hostname.value = \'' . addslashes(htmlspecialchars($thishost)) . '\'; } ') . 'else if (this.value == \'hosttable\') { hostname.value = \'\'; } else if (this.value == \'userdefined\') { hostname.focus(); hostname.select(); }">' . "\n";
unset($_current_user);
// when we start editing a user, $GLOBALS['pred_hostname'] is not defined
if (!isset($GLOBALS['pred_hostname']) && isset($GLOBALS['hostname'])) {
switch (strtolower($GLOBALS['hostname'])) {
case 'localhost':
case '127.0.0.1':
$GLOBALS['pred_hostname'] = 'localhost';
break;
case '%':
$GLOBALS['pred_hostname'] = 'any';
break;
default:
$GLOBALS['pred_hostname'] = 'userdefined';
break;
}
}
echo ' <option value="any"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'any' ? ' selected="selected"' : '') . '>' . __('Any host') . '</option>' . "\n" . ' <option value="localhost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'localhost' ? ' selected="selected"' : '') . '>' . __('Local') . '</option>' . "\n";
if (!empty($thishost)) {
echo ' <option value="thishost"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'thishost' ? ' selected="selected"' : '') . '>' . __('This Host') . '</option>' . "\n";
}
unset($thishost);
echo ' <option value="hosttable"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'hosttable' ? ' selected="selected"' : '') . '>' . __('Use Host Table') . '</option>' . "\n" . ' <option value="userdefined"' . (isset($GLOBALS['pred_hostname']) && $GLOBALS['pred_hostname'] == 'userdefined' ? ' selected="selected"' : '') . '>' . __('Use text field') . ':</option>' . "\n" . ' </select>' . "\n" . '</span>' . "\n" . '<input type="text" name="hostname" maxlength="' . $hostname_length . '" value="' . htmlspecialchars(isset($GLOBALS['hostname']) ? $GLOBALS['hostname'] : '') . '" title="' . __('Host') . '" onchange="pred_hostname.value = \'userdefined\';" />' . "\n" . PMA_showHint(__('When Host table is used, this field is ignored and values stored in Host table are used instead.')) . '</div>' . "\n" . '<div class="item">' . "\n" . '<label for="select_pred_password">' . "\n" . ' ' . __('Password') . ':' . "\n" . '</label>' . "\n" . '<span class="options">' . "\n" . ' <select name="pred_password" id="select_pred_password" title="' . __('Password') . '"' . "\n" . ' onchange="if (this.value == \'none\') { pma_pw.value = \'\'; pma_pw2.value = \'\'; } else if (this.value == \'userdefined\') { pma_pw.focus(); pma_pw.select(); }">' . "\n" . ($mode == 'change' ? ' <option value="keep" selected="selected">' . __('Do not change the password') . '</option>' . "\n" : '') . ' <option value="none"';
if (isset($GLOBALS['username']) && $mode != 'change') {
echo ' selected="selected"';
}
echo '>' . __('No Password') . '</option>' . "\n" . ' <option value="userdefined"' . (isset($GLOBALS['username']) ? '' : ' selected="selected"') . '>' . __('Use text field') . ':</option>' . "\n" . ' </select>' . "\n" . '</span>' . "\n" . '<input type="password" id="text_pma_pw" name="pma_pw" title="' . __('Password') . '" onchange="pred_password.value = \'userdefined\';" />' . "\n" . '</div>' . "\n" . '<div class="item" id="div_element_before_generate_password">' . "\n" . '<label for="text_pma_pw2">' . "\n" . ' ' . __('Re-type') . ':' . "\n" . '</label>' . "\n" . '<span class="options"> </span>' . "\n" . '<input type="password" name="pma_pw2" id="text_pma_pw2" title="' . __('Re-type') . '" onchange="pred_password.value = \'userdefined\';" />' . "\n" . '</div>' . "\n" . '</fieldset>' . "\n";
}
示例11: PMA_replication_get_username_hostname_length
/**
* get the correct username and hostname lengths for this MySQL server
*
* @uses strtok()
* @return array username length, hostname length
*/
function PMA_replication_get_username_hostname_length()
{
$fields_info = PMA_DBI_get_fields('mysql', 'user');
$username_length = 16;
$hostname_length = 41;
foreach ($fields_info as $key => $val) {
if ($val['Field'] == 'User') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$username_length = $v;
}
} elseif ($val['Field'] == 'Host') {
strtok($val['Type'], '()');
$v = strtok('()');
if (is_int($v)) {
$hostname_length = $v;
}
}
}
return array($username_length, $hostname_length);
}
示例12: intval
$regenerate = TRUE;
}
}
}
// end do create table
/**
* Displays the form used to define the structure of the table
*/
if ($abort == FALSE) {
if (isset($num_fields)) {
$num_fields = intval($num_fields);
}
// No table name
if (!isset($table) || trim($table) == '') {
PMA_mysqlDie($strTableEmpty, '', '', $err_url);
} else {
if (empty($num_fields) || !is_int($num_fields)) {
PMA_mysqlDie($strFieldsEmpty, '', '', $err_url);
} else {
if (!(PMA_DBI_get_fields($db, $table) === FALSE)) {
PMA_mysqlDie(sprintf($strTableAlreadyExists, htmlspecialchars($table)), '', '', $err_url);
} else {
$action = 'tbl_create.php';
require './tbl_properties.inc.php';
// Displays the footer
echo "\n";
require_once './footer.inc.php';
}
}
}
}
示例13: PMA_mysqlDie
//.........这里部分代码省略.........
}
// ---
echo "\n" . '<!-- PMA-SQL-ERROR -->' . "\n";
echo ' <table border="0" cellpadding="2" cellspacing="1">' . ' <tr>' . "\n" . ' <th class="tblHeadError"><div class="errorhead">' . $GLOBALS['strError'] . '</div></th>' . "\n" . ' </tr>' . "\n" . ' <tr>' . "\n" . ' <td>';
// if the config password is wrong, or the MySQL server does not
// respond, do not show the query that would reveal the
// username/password
if (!empty($the_query) && !strstr($the_query, 'connect')) {
// --- Added to solve bug #641765
// Robbat2 - 12 January 2003, 9:46PM
// Revised, Robbat2 - 13 January 2003, 2:59PM
if (function_exists('PMA_SQP_isError') && PMA_SQP_isError()) {
echo PMA_SQP_getErrorString();
}
// ---
// modified to show me the help on sql errors (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n";
echo ' <b>' . $GLOBALS['strSQLQuery'] . ':</b>' . "\n";
if (strstr(strtolower($formatted_sql), 'select')) {
// please show me help to the error on select
echo PMA_showMySQLDocu('Reference', 'SELECT');
}
if ($is_modify_link && isset($db)) {
if (isset($table)) {
$doedit_goto = '<a href="tbl_properties.php?' . PMA_generate_common_url($db, $table) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
} else {
$doedit_goto = '<a href="db_details.php?' . PMA_generate_common_url($db) . '&sql_query=' . urlencode($the_query) . '&show_query=1">';
}
if ($GLOBALS['cfg']['PropertiesIconic']) {
echo $doedit_goto . '<img src=" ' . $GLOBALS['pmaThemeImage'] . 'b_edit.png" width="16" height="16" border="0" hspace="2" align="middle" alt="' . $GLOBALS['strEdit'] . '" />' . '</a>';
} else {
echo ' [' . $doedit_goto . $GLOBALS['strEdit'] . '</a>' . ']' . "\n";
}
}
// end if
echo '</p>' . "\n" . '<p>' . "\n" . ' ' . $formatted_sql . "\n" . '</p></div>' . "\n";
}
// end if
$tmp_mysql_error = '';
// for saving the original $error_message
if (!empty($error_message)) {
$tmp_mysql_error = strtolower($error_message);
// save the original $error_message
$error_message = htmlspecialchars($error_message);
$error_message = preg_replace("@((\r\n)|(\r)|(\n)){3,}@", "\n\n", $error_message);
}
// modified to show me the help on error-returns (Michael Keck)
echo '<div class="tblWarn"><p>' . "\n" . ' <b>' . $GLOBALS['strMySQLSaid'] . '</b>' . PMA_showMySQLDocu('Error-returns', 'Error-returns') . "\n" . '</p>' . "\n";
// The error message will be displayed within a CODE segment.
// To preserve original formatting, but allow wordwrapping, we do a couple of replacements
// Replace all non-single blanks with their HTML-counterpart
$error_message = str_replace(' ', ' ', $error_message);
// Replace TAB-characters with their HTML-counterpart
$error_message = str_replace("\t", ' ', $error_message);
// Replace linebreaks
$error_message = nl2br($error_message);
echo '<code>' . "\n" . $error_message . "\n" . '</code><br />' . "\n";
// feature request #1036254:
// Add a link by MySQL-Error #1062 - Duplicate entry
// 2004-10-20 by mkkeck
// 2005-01-17 modified by mkkeck bugfix
if (substr($error_message, 1, 4) == '1062') {
// get the duplicate entry
$mysql_error_values = array();
$mysql_error_words = explode(' ', $tmp_mysql_error);
foreach ($mysql_error_words as $mysql_error_word) {
if (strstr($mysql_error_word, "'")) {
$mysql_error_values = explode('-', preg_replace("/'/", "", $mysql_error_word));
break;
// exit 'foreach'
}
}
$duplicate_sql_query = '';
if (isset($mysql_error_values[0])) {
$tmp_fields = PMA_DBI_get_fields($db, $table, NULL);
if ($tmp_fields) {
foreach ($tmp_fields as $tmp_field) {
$duplicate_sql_query .= ($duplicate_sql_query != '' ? ' OR ' : '') . PMA_backquote($tmp_field['Field']) . " LIKE '" . $mysql_error_values[0] . "'";
}
}
}
if ($duplicate_sql_query != '') {
$duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . " WHERE (" . $duplicate_sql_query . ")";
} else {
$duplicate_sql_query = "SELECT * FROM " . PMA_backquote($table) . "";
}
echo ' <form method="post" action="read_dump.php" style="padding: 0px; margin: 0px">' . "\n" . ' <input type="hidden" name="sql_query" value="' . $duplicate_sql_query . '" />' . "\n" . ' ' . PMA_generate_common_hidden_inputs($db, $table) . "\n" . ' <input type="submit" name="submit" value="' . $GLOBALS['strBrowse'] . '" />' . "\n" . ' </form>' . "\n";
}
// end of show duplicate entry
echo '</div>';
if (!empty($back_url) && $exit) {
$goto_back_url = '<a href="' . (strstr($back_url, '?') ? $back_url . '&no_history=true' : $back_url . '?no_history=true') . '"> ';
echo ' </td> ' . "\n" . ' </tr>' . "\n" . ' <tr><td class="tblHeaders" align="center">';
echo '[' . $goto_back_url . $GLOBALS['strBack'] . ' </a>]';
}
echo ' </td>' . "\n" . ' </tr>' . "\n" . ' </table>' . "\n\n";
if ($exit) {
require_once './footer.inc.php';
}
}