$location = ME . "select=" . urlencode($TABLE);
}
+ $indexes = indexes($TABLE);
+ $unique_array = unique_array($_GET["where"], $indexes);
+ $query_where = "\nWHERE $where";
+
if (isset($_POST["delete"])) {
- query_redirect("DELETE" . limit1("FROM " . table($TABLE), " WHERE $where"), $location, lang('Item has been deleted.'));
+ $query = "FROM " . table($TABLE);
+ query_redirect(
+ "DELETE" . ($unique_array ? " $query$query_where" : limit1($query, $query_where)),
+ $location,
+ lang('Item has been deleted.')
+ );
} else {
$set = array();
foreach ($fields as $name => $field) {
if (!$set) {
redirect($location);
}
- query_redirect("UPDATE" . limit1(table($TABLE) . " SET" . implode(",", $set), "\nWHERE $where"), $location, lang('Item has been updated.'));
+ $query = table($TABLE) . " SET" . implode(",", $set);
+ query_redirect(
+ "UPDATE" . ($unique_array ? " $query$query_where" : limit1($query, $query_where)),
+ $location,
+ lang('Item has been updated.')
+ );
} else {
$result = insert_into($TABLE, $set);
$last_id = ($result ? last_id() : 0);
/** Find unique identifier of a row
* @param array
* @param array result of indexes()
-* @return array
+* @return array or null if there is no unique identifier
*/
function unique_array($row, $indexes) {
foreach ($indexes as $index) {
return $return;
}
}
- $return = array();
- foreach ($row as $key => $val) {
- if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
- $return[$key] = $val;
- }
- }
- return $return;
}
/** Create SQL condition from parsed query string
foreach ($adminer->rowDescriptions($rows, $foreign_keys) as $n => $row) {
$unique_array = unique_array($rows[$n], $indexes);
+ if (!$unique_array) {
+ $unique_array = array();
+ foreach ($rows[$n] as $key => $val) {
+ if (!preg_match('~^(COUNT\\((\\*|(DISTINCT )?`(?:[^`]|``)+`)\\)|(AVG|GROUP_CONCAT|MAX|MIN|SUM)\\(`(?:[^`]|``)+`\\))$~', $key)) { //! columns looking like functions
+ $unique_array[$key] = $val;
+ }
+ }
+ }
$unique_idf = "";
foreach ($unique_array as $key => $val) {
if (strlen($val) > 64) {
Constraint memory used in TAR export
Allow exporting views dependent on each other (bug #3459151)
Fix resetting search (bug #3612507)
+Don't use LIMIT 1 if updating unique row (bug #3613109)
Restrict editing rows without unique identifier to search results
Display navigation bellow main content on mobile browsers
MySQL: Optimize create table page and Editor navigation