PostgreSQL: Limit rows in data manipulation without unique key
This commit is contained in:
parent
763e66a148
commit
52d98e16fa
|
@ -147,7 +147,7 @@ if (isset($_GET["firebird"])) {
|
|||
return $return;
|
||||
}
|
||||
|
||||
function limit1($query, $where) {
|
||||
function limit1($table, $query, $where) {
|
||||
return limit($query, $where, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -308,7 +308,7 @@ if (isset($_GET["mssql"])) {
|
|||
return ($limit !== null ? " TOP (" . ($limit + $offset) . ")" : "") . " $query$where"; // seek later
|
||||
}
|
||||
|
||||
function limit1($query, $where) {
|
||||
function limit1($table, $query, $where) {
|
||||
return limit($query, $where, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -362,11 +362,12 @@ if (!defined("DRIVER")) {
|
|||
}
|
||||
|
||||
/** Formulate SQL modification query with limit 1
|
||||
* @param string
|
||||
* @param string everything after UPDATE or DELETE
|
||||
* @param string
|
||||
* @return string
|
||||
*/
|
||||
function limit1($query, $where) {
|
||||
function limit1($table, $query, $where) {
|
||||
return limit($query, $where, 1);
|
||||
}
|
||||
|
||||
|
|
|
@ -175,8 +175,8 @@ if (isset($_GET["oracle"])) {
|
|||
));
|
||||
}
|
||||
|
||||
function limit1($query, $where) {
|
||||
return " $query$where";
|
||||
function limit1($table, $query, $where) {
|
||||
return " $query$where"; //! limit
|
||||
}
|
||||
|
||||
function db_collation($db, $collations) {
|
||||
|
|
|
@ -226,8 +226,8 @@ if (isset($_GET["pgsql"])) {
|
|||
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
|
||||
}
|
||||
|
||||
function limit1($query, $where) {
|
||||
return " $query$where";
|
||||
function limit1($table, $query, $where) {
|
||||
return (preg_match('~^INTO~', $query) ? limit($query, $where, 1) : "$query WHERE ctid = (SELECT ctid FROM " . table($table) . "$where LIMIT 1)");
|
||||
}
|
||||
|
||||
function db_collation($db, $collations) {
|
||||
|
|
|
@ -242,9 +242,9 @@ if (isset($_GET["sqlite"]) || isset($_GET["sqlite2"])) {
|
|||
return " $query$where" . ($limit !== null ? $separator . "LIMIT $limit" . ($offset ? " OFFSET $offset" : "") : "");
|
||||
}
|
||||
|
||||
function limit1($query, $where) {
|
||||
function limit1($table, $query, $where) {
|
||||
global $connection;
|
||||
return ($connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')") ? limit($query, $where, 1) : " $query$where");
|
||||
return ($connection->result("SELECT sqlite_compileoption_used('ENABLE_UPDATE_DELETE_LIMIT')") ? limit($query, $where, 1) : " $query$where"); //! limit
|
||||
}
|
||||
|
||||
function db_collation($db, $collations) {
|
||||
|
|
|
@ -50,7 +50,7 @@
|
|||
*/
|
||||
function delete($table, $queryWhere, $limit = 0) {
|
||||
$query = "FROM " . table($table);
|
||||
return queries("DELETE" . ($limit ? limit1($query, $queryWhere) : " $query$queryWhere"));
|
||||
return queries("DELETE" . ($limit ? limit1($table, $query, $queryWhere) : " $query$queryWhere"));
|
||||
}
|
||||
|
||||
/** Update data in table
|
||||
|
@ -67,7 +67,7 @@
|
|||
$values[] = "$key = $val";
|
||||
}
|
||||
$query = table($table) . " SET$separator" . implode(",$separator", $values);
|
||||
return queries("UPDATE" . ($limit ? limit1($query, $queryWhere) : " $query$queryWhere"));
|
||||
return queries("UPDATE" . ($limit ? limit1($table, $query, $queryWhere) : " $query$queryWhere"));
|
||||
}
|
||||
|
||||
/** Insert data into table
|
||||
|
|
|
@ -123,7 +123,7 @@ if ($_POST && !$error) {
|
|||
$result = ($_POST["delete"]
|
||||
? $driver->delete($TABLE, $where2, 1)
|
||||
: ($_POST["clone"]
|
||||
? queries("INSERT" . limit1($query, $where2))
|
||||
? queries("INSERT" . limit1($TABLE, $query, $where2))
|
||||
: $driver->update($TABLE, $set, $where2, 1)
|
||||
)
|
||||
);
|
||||
|
|
|
@ -9,7 +9,8 @@ MySQL, PostgreSQL: Display warnings
|
|||
MySQL: Add floor and ceil select functions
|
||||
MySQL: Add FIND_IN_SET search operator
|
||||
MariaDB: Support JSON since MariaDB 10.2
|
||||
PostgreSQL: Support functions
|
||||
PostgreSQL: Support routines
|
||||
PostgreSQL: Limit rows in data manipulation without unique key
|
||||
PostgreSQL: Allow editing views with uppercase letters (bug #467)
|
||||
PostgreSQL: Allow now() as default value (bug #525)
|
||||
SimpleDB: Document that allow_url_fopen is required
|
||||
|
|
Loading…
Reference in a new issue