'; if ($GLOBALS['cfg']['PropertiesIconic'] === 'both') { $titles['Browse'] .= $strBrowseForeignValues; } } else { $titles['Browse'] = $strBrowseForeignValues; } /** * Not selection yet required -> displays the selection form */ if (!isset($param) || $param[0] == '') { // Gets some core libraries require_once './libraries/tbl_common.php'; //$err_url = 'tbl_select.php' . $err_url; $url_query .= '&goto=tbl_select.php&back=tbl_select.php'; /** * Gets tables informations */ require_once './libraries/tbl_info.inc.php'; /** * Displays top menu links */ require_once './libraries/tbl_links.inc.php'; if (!isset($goto)) { $goto = $GLOBALS['cfg']['DefaultTabTable']; } // Defines the url to return to in case of error in the next sql statement $err_url = $goto . '?' . PMA_generate_common_url($db, $table); // Gets the list and number of fields $result = PMA_DBI_query('SHOW FULL FIELDS FROM ' . PMA_backquote($table) . ' FROM ' . PMA_backquote($db) . ';', null, PMA_DBI_QUERY_STORE); $fields_cnt = PMA_DBI_num_rows($result); // rabue: we'd better ensure, that all arrays are empty. $fields_list = $fields_null = $fields_type = $fields_collation = array(); while ($row = PMA_DBI_fetch_assoc($result)) { $fields_list[] = $row['Field']; $type = $row['Type']; // reformat mysql query output - staybyte - 9. June 2001 if (strncasecmp($type, 'set', 3) == 0 || strncasecmp($type, 'enum', 4) == 0) { $type = str_replace(',', ', ', $type); } else { // strip the "BINARY" attribute, except if we find "BINARY(" because // this would be a BINARY or VARBINARY field type if (!preg_match('@BINARY[\(]@i', $type)) { $type = preg_replace('@BINARY@i', '', $type); } $type = preg_replace('@ZEROFILL@i', '', $type); $type = preg_replace('@UNSIGNED@i', '', $type); $type = strtolower($type); } if (empty($type)) { $type = ' '; } $fields_null[] = $row['Null']; $fields_type[] = $type; $fields_collation[] = !empty($row['Collation']) && $row['Collation'] != 'NULL' ? $row['Collation'] : ''; } // end while PMA_DBI_free_result($result); unset($result, $type); // // retrieve keys into foreign fields, if any // check also foreigners even if relwork is FALSE (to get // foreign keys from innodb) $foreigners = PMA_getForeigners($db, $table); ?>
do the work */ else { // Builds the query $sql_query = 'SELECT ' . (isset($distinct) ? 'DISTINCT ' : ''); // if all fields were selected to display, we do a SELECT * // (more efficient and this helps prevent a problem in IE // if one of the rows is edited and we come back to the Select results) if (count($param) == $max_number_of_fields) { $sql_query .= '* '; } else { $param = PMA_backquote($param); $sql_query .= implode(', ', $param); unset($param); } // end if $sql_query .= ' FROM ' . PMA_backquote($table); // The where clause if (trim($where) != '') { $sql_query .= ' WHERE ' . $where; } else { $w = $charsets = array(); $cnt_func = count($func); reset($func); while (list($i, $func_type) = each($func)) { list($charsets[$i]) = explode('_', $collations[$i]); if (isset($GLOBALS['cfg']['UnaryOperators'][$func_type]) && $GLOBALS['cfg']['UnaryOperators'][$func_type] == 1) { $fields[$i] = ''; $w[] = PMA_backquote($names[$i]) . ' ' . $func_type; } elseif (strncasecmp($types[$i], 'enum', 4) == 0) { if (!empty($fields[$i])) { if (!is_array($fields[$i])) { $fields[$i] = explode(',', $fields[$i]); } $enum_selected_count = count($fields[$i]); if ($func_type == '=' && $enum_selected_count > 1) { $func_type = $func[$i] = 'IN'; $parens_open = '('; $parens_close = ')'; } elseif ($func_type == '!=' && $enum_selected_count > 1) { $func_type = $func[$i] = 'NOT IN'; $parens_open = '('; $parens_close = ')'; } else { $parens_open = ''; $parens_close = ''; } $enum_where = '\'' . PMA_sqlAddslashes($fields[$i][0]) . '\''; for ($e = 1; $e < $enum_selected_count; $e++) { $enum_where .= ', \'' . PMA_sqlAddslashes($fields[$i][$e]) . '\''; } $w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $parens_open . $enum_where . $parens_close; } } elseif ($fields[$i] != '') { // For these types we quote the value. Even if it's another type (like INT), // for a LIKE we always quote the value. MySQL converts strings to numbers // and numbers to strings as necessary during the comparison if (preg_match('@char|binary|blob|text|set|date|time|year@i', $types[$i]) || strpos(' ' . $func_type, 'LIKE')) { $quot = '\''; } else { $quot = ''; } // LIKE %...% if ($func_type == 'LIKE %...%') { $func_type = 'LIKE'; $fields[$i] = '%' . $fields[$i] . '%'; } $w[] = PMA_backquote($names[$i]) . ' ' . $func_type . ' ' . $quot . PMA_sqlAddslashes($fields[$i]) . $quot; } // end if } // end for if ($w) { $sql_query .= ' WHERE ' . implode(' AND ', $w); } } // end if if ($orderField != '--nil--') { $sql_query .= ' ORDER BY ' . PMA_backquote($orderField) . ' ' . $order; } // end if require './sql.php'; } ?>