" . lang('Tables') . " | " . html_select('table_style', $table_style, $row["table_style"])
. (support("trigger") ? checkbox("triggers", 1, $row["table_style"], lang('Triggers')) : "")
;
diff --git a/adminer/include/adminer.inc.php b/adminer/include/adminer.inc.php
index d52d4b82..db6028fa 100644
--- a/adminer/include/adminer.inc.php
+++ b/adminer/include/adminer.inc.php
@@ -304,7 +304,7 @@ document.getElementById('username').focus();
* @return array expressions to join by AND
*/
function selectSearchProcess($fields, $indexes) {
- global $connection;
+ global $connection, $jush;
$return = array();
foreach ($indexes as $i => $index) {
if ($index["type"] == "FULLTEXT" && $_GET["fulltext"][$i] != "") {
@@ -330,7 +330,7 @@ document.getElementById('username').focus();
foreach ($fields as $name => $field) {
if (is_numeric($val["val"]) || !ereg('int|float|double|decimal', $field["type"])) {
$name = idf_escape($name);
- $cols[] = (ereg('char|text|enum|set', $field["type"]) && !ereg('^utf8', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
+ $cols[] = ($jush == "sql" && ereg('char|text|enum|set', $field["type"]) && !ereg('^utf8', $field["collation"]) ? "CONVERT($name USING utf8)" : $name);
}
}
$return[] = ($cols ? "(" . implode("$cond OR ", $cols) . "$cond)" : "0");
diff --git a/adminer/include/editing.inc.php b/adminer/include/editing.inc.php
index 1ebdb422..70ac314d 100644
--- a/adminer/include/editing.inc.php
+++ b/adminer/include/editing.inc.php
@@ -5,77 +5,73 @@
* @return null
*/
function select($result, $connection2 = null) {
- if (!$result->num_rows) {
- echo " " . lang('No rows.') . "\n";
- } else {
- echo " \n";
- $links = array(); // colno => orgtable - create links from these columns
- $indexes = array(); // orgtable => array(column => colno) - primary keys
- $columns = array(); // orgtable => array(column => ) - not selected columns in primary key
- $blobs = array(); // colno => bool - display bytes for blobs
- $types = array(); // colno => type - display char in
- odd(''); // reset odd for each result
- for ($i=0; $row = $result->fetch_row(); $i++) {
- if (!$i) {
- echo "";
- for ($j=0; $j < count($row); $j++) {
- $field = $result->fetch_field();
- $orgtable = $field->orgtable;
- $orgname = $field->orgname;
- if ($orgtable != "") {
- if (!isset($indexes[$orgtable])) {
- // find primary key in each table
- $indexes[$orgtable] = array();
- foreach (indexes($orgtable, $connection2) as $index) {
- if ($index["type"] == "PRIMARY") {
- $indexes[$orgtable] = array_flip($index["columns"]);
- break;
- }
+ $links = array(); // colno => orgtable - create links from these columns
+ $indexes = array(); // orgtable => array(column => colno) - primary keys
+ $columns = array(); // orgtable => array(column => ) - not selected columns in primary key
+ $blobs = array(); // colno => bool - display bytes for blobs
+ $types = array(); // colno => type - display char in
+ odd(''); // reset odd for each result
+ for ($i=0; $row = $result->fetch_row(); $i++) {
+ if (!$i) {
+ echo "\n";
+ echo "";
+ for ($j=0; $j < count($row); $j++) {
+ $field = $result->fetch_field();
+ $orgtable = $field->orgtable;
+ $orgname = $field->orgname;
+ if ($orgtable != "") {
+ if (!isset($indexes[$orgtable])) {
+ // find primary key in each table
+ $indexes[$orgtable] = array();
+ foreach (indexes($orgtable, $connection2) as $index) {
+ if ($index["type"] == "PRIMARY") {
+ $indexes[$orgtable] = array_flip($index["columns"]);
+ break;
}
- $columns[$orgtable] = $indexes[$orgtable];
- }
- if (isset($columns[$orgtable][$orgname])) {
- unset($columns[$orgtable][$orgname]);
- $indexes[$orgtable][$orgname] = $j;
- $links[$j] = $orgtable;
}
+ $columns[$orgtable] = $indexes[$orgtable];
}
- if ($field->charsetnr == 63) { // 63 - binary
- $blobs[$j] = true;
- }
- $types[$j] = $field->type;
- echo "name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($field->name);
- }
- echo " | \n";
- }
- echo "";
- foreach ($row as $key => $val) {
- if (!isset($val)) {
- $val = "NULL";
- } else {
- if ($blobs[$key] && !is_utf8($val)) {
- $val = "" . lang('%d byte(s)', strlen($val)) . ""; //! link to download
- } elseif (!strlen($val)) { // strlen - SQLite can return int
- $val = " "; // some content to print a border
- } else {
- $val = h($val);
- if ($types[$key] == 254) { // 254 - char
- $val = "$val ";
- }
- }
- if (isset($links[$key]) && !$columns[$links[$key]]) {
- $link = "edit=" . urlencode($links[$key]);
- foreach ($indexes[$links[$key]] as $col => $j) {
- $link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
- }
- $val = "$val";
+ if (isset($columns[$orgtable][$orgname])) {
+ unset($columns[$orgtable][$orgname]);
+ $indexes[$orgtable][$orgname] = $j;
+ $links[$j] = $orgtable;
}
}
- echo "$val";
+ if ($field->charsetnr == 63) { // 63 - binary
+ $blobs[$j] = true;
+ }
+ $types[$j] = $field->type;
+ echo " | name != $orgname ? " title='" . h(($orgtable != "" ? "$orgtable." : "") . $orgname) . "'" : "") . ">" . h($field->name);
}
+ echo "\n";
+ }
+ echo " | ";
+ foreach ($row as $key => $val) {
+ if (!isset($val)) {
+ $val = "NULL";
+ } else {
+ if ($blobs[$key] && !is_utf8($val)) {
+ $val = "" . lang('%d byte(s)', strlen($val)) . ""; //! link to download
+ } elseif (!strlen($val)) { // strlen - SQLite can return int
+ $val = " "; // some content to print a border
+ } else {
+ $val = h($val);
+ if ($types[$key] == 254) { // 254 - char
+ $val = "$val ";
+ }
+ }
+ if (isset($links[$key]) && !$columns[$links[$key]]) {
+ $link = "edit=" . urlencode($links[$key]);
+ foreach ($indexes[$links[$key]] as $col => $j) {
+ $link .= "&where" . urlencode("[" . bracket_escape($col) . "]") . "=" . urlencode($row[$j]);
+ }
+ $val = "$val";
+ }
+ }
+ echo "$val";
}
- echo " | \n";
}
+ echo ($i ? " " : "" . lang('No rows.')) . "\n";
}
/** Get referencable tables with single column primary key except self
diff --git a/adminer/include/export.inc.php b/adminer/include/export.inc.php
index 892dce53..7c449529 100644
--- a/adminer/include/export.inc.php
+++ b/adminer/include/export.inc.php
@@ -20,7 +20,7 @@ function dump_table($table, $style, $is_view = false) {
$create = create_sql($table);
if ($create) {
if ($style == "DROP+CREATE") {
- echo "DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . idf_escape($table) . ";\n";
+ echo "DROP " . ($is_view ? "VIEW" : "TABLE") . " IF EXISTS " . table($table) . ";\n";
}
echo ($style != "CREATE+ALTER" ? $create : ($is_view ? substr_replace($create, " OR REPLACE", 6, 0) : substr_replace($create, " IF NOT EXISTS", 12, 0))) . ";\n\n";
}
@@ -86,7 +86,7 @@ CREATE PROCEDURE adminer_alter (INOUT alter_command text) BEGIN
UNTIL done END REPEAT;
CLOSE columns;
IF @alter_table != '' OR add_columns != '' THEN
- SET alter_command = CONCAT(alter_command, 'ALTER TABLE " . idf_escape($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n');
+ SET alter_command = CONCAT(alter_command, 'ALTER TABLE " . table($table) . "', SUBSTR(CONCAT(add_columns, @alter_table), 2), ';\\n');
END IF;
END;;
DELIMITER ;
@@ -104,10 +104,10 @@ function dump_data($table, $style, $select = "") {
$max_packet = ($jush == "sqlite" ? 0 : 1048576); // default, minimum is 1024
if ($style) {
if ($_POST["format"] == "sql" && $style == "TRUNCATE+INSERT") {
- echo "TRUNCATE " . idf_escape($table) . ";\n";
+ echo truncate_sql($table) . ";\n";
}
$fields = fields($table);
- $result = $connection->query(($select ? $select : "SELECT * FROM " . idf_escape($table)), 1); // 1 - MYSQLI_USE_RESULT //! enum and set as numbers, microtime
+ $result = $connection->query(($select ? $select : "SELECT * FROM " . table($table)), 1); // 1 - MYSQLI_USE_RESULT //! enum and set as numbers, microtime
if ($result) {
$insert = "";
$buffer = "";
@@ -116,7 +116,7 @@ function dump_data($table, $style, $select = "") {
dump_csv($row);
} else {
if (!$insert) {
- $insert = "INSERT INTO " . idf_escape($table) . " (" . implode(", ", array_map('idf_escape', array_keys($row))) . ") VALUES";
+ $insert = "INSERT INTO " . table($table) . " (" . implode(", ", array_map('idf_escape', array_keys($row))) . ") VALUES";
}
foreach ($row as $key => $val) {
$row[$key] = (isset($val) ? (ereg('int|float|double|decimal', $fields[$key]["type"]) ? $val : $connection->quote($val)) : "NULL"); //! columns looking like functions
diff --git a/adminer/include/functions.inc.php b/adminer/include/functions.inc.php
index 743ecfd0..21733338 100644
--- a/adminer/include/functions.inc.php
+++ b/adminer/include/functions.inc.php
@@ -626,7 +626,7 @@ function search_tables() {
$name = $adminer->tableName($table_status);
if (isset($table_status["Engine"]) && $name != "" && (!$_POST["tables"] || in_array($table, $_POST["tables"]))) {
$result = $connection->query("SELECT" . limit("1 FROM " . table($table), " WHERE " . implode(" AND ", $adminer->selectSearchProcess(fields($table), array())), 1));
- if ($result->num_rows) {
+ if ($result->fetch_row()) {
if (!$found) {
echo " \n";
$found = true;
diff --git a/adminer/select.inc.php b/adminer/select.inc.php
index df2eed78..e6568473 100644
--- a/adminer/select.inc.php
+++ b/adminer/select.inc.php
@@ -144,12 +144,11 @@ if ($_POST && !$error) {
$cols = $matches2[1];
$affected--;
} else {
- $set = "";
+ $set = array();
foreach ($matches2[1] as $i => $col) {
- $set .= ", " . idf_escape($cols[$i]) . " = " . ($col == "" && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
+ $set[idf_escape($cols[$i])] = ($col == "" && $fields[$cols[$i]]["null"] ? "NULL" : $connection->quote(str_replace('""', '"', preg_replace('~^"|"$~', '', $col))));
}
- $set = substr($set, 1);
- $result = queries("INSERT INTO " . table($TABLE) . " SET$set ON DUPLICATE KEY UPDATE$set");
+ $result = insert_update($TABLE, $set);
if (!$result) {
break;
}
@@ -159,7 +158,7 @@ if ($_POST && !$error) {
queries("COMMIT");
}
queries_redirect(remove_from_uri("page"), lang('%d row(s) have been imported.', $affected), $result);
- queries("ROLLBACK");
+ queries("ROLLBACK"); // after queries_redirect() to not overwrite error
} else {
$error = upload_error($file);
}
diff --git a/todo.txt b/todo.txt
index e2b159b5..5d68a1de 100644
--- a/todo.txt
+++ b/todo.txt
@@ -26,8 +26,6 @@ Saving of MySQL 5 BIT data type - don't use quote()
? Geometry support
SQLite:
-CSV import - ON DUPLICATE KEY UPDATE
-Export - CREATE DATABASE
Delimiter in export and SQL command
Backward keys in Editor
|
---|