diff options
author | mattab <matthieu.aubry@gmail.com> | 2013-09-25 09:49:39 +0400 |
---|---|---|
committer | mattab <matthieu.aubry@gmail.com> | 2013-09-25 12:04:40 +0400 |
commit | e1a7acafa59eec66b9458d2b3f665f48c41f051b (patch) | |
tree | 91d8dee9a8f0c2aa66abc755651efef6bcdb5ca8 /core | |
parent | 6c82534230eba6025b0c330b04493a2fdfe45f9e (diff) |
Thanks for the report. Could you apply this patch and confirm it is working for you?
Fixes #4156 Adding ORDER BY clause when DELETING so that it works with replication
https://dev.mysql.com/doc/refman/5.1/en/replication-features-limit.html
(cherry picked from commit ce6254e)
Diffstat (limited to 'core')
-rw-r--r-- | core/Db.php | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/core/Db.php b/core/Db.php index ef2f756f9d..a8369943ba 100644 --- a/core/Db.php +++ b/core/Db.php @@ -156,11 +156,15 @@ class Db * @param string $where The where clause of the query. Must include the WHERE keyword. * @param int $maxRowsPerQuery The maximum number of rows to delete per DELETE query. * @param array $parameters Parameters to bind in the query. + * @param string $primaryKey Name of primary key to sort by. * @return int The total number of rows deleted. */ - static public function deleteAllRows($table, $where, $maxRowsPerQuery = 100000, $parameters = array()) + static public function deleteAllRows($table, $where, $orderBy, $maxRowsPerQuery = 100000, $parameters = array()) { - $sql = "DELETE FROM $table $where LIMIT " . (int)$maxRowsPerQuery; + $sql = "DELETE FROM $table + $where + ORDER BY $orderBy ASC + LIMIT " . (int)$maxRowsPerQuery; // delete rows w/ a limit $totalRowsDeleted = 0; |