]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
baculum: Fix OFFSET parameter in PHP framework
authorMarcin Haba <marcin.haba@bacula.pl>
Fri, 9 Dec 2022 12:30:34 +0000 (13:30 +0100)
committerMarcin Haba <marcin.haba@bacula.pl>
Mon, 9 Jan 2023 12:34:42 +0000 (13:34 +0100)
Ticket in the PRADO framework GitHub project:

Support for OFFSET parameter without LIMIT clause in SQL query for TActiveRecord

https://github.com/pradosoft/prado/issues/819

gui/baculum/protected/vendor/pradosoft/prado/framework/Data/DataGateway/TSqlCriteria.php

index 4d0acc220dadf02272d1933b34e60895a6afd598..07a20508a606d03ac248c6023838f4952fcb5b40 100644 (file)
@@ -144,7 +144,7 @@ class TSqlCriteria extends \Prado\TComponent
                //    [LIMIT {[offset,] row_count | row_count OFFSET offset}]
                // See: http://dev.mysql.com/doc/refman/5.0/en/select.html
 
-               if (preg_match('/ORDER\s+BY\s+(.*?)(?=LIMIT)|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) {
+               if (preg_match('/ORDER\s+BY\s+(.*?)(?=\s+(?:LIMIT|OFFSET))|ORDER\s+BY\s+(.*?)$/i', $value, $matches) > 0) {
                        // condition contains ORDER BY
                        $value = str_replace($matches[0], '', $value);
                        if (strlen($matches[1]) > 0) {