[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Fmsystem-commits] [11882] booking: FIX for repeating rows from LIMIT OF
From: |
Sigurd Nes |
Subject: |
[Fmsystem-commits] [11882] booking: FIX for repeating rows from LIMIT OFFSET |
Date: |
Wed, 02 Apr 2014 21:41:24 +0000 |
Revision: 11882
http://svn.sv.gnu.org/viewvc/?view=rev&root=fmsystem&revision=11882
Author: sigurdne
Date: 2014-04-02 21:41:23 +0000 (Wed, 02 Apr 2014)
Log Message:
-----------
booking: FIX for repeating rows from LIMIT OFFSET
Modified Paths:
--------------
trunk/booking/inc/class.socommon.inc.php
trunk/booking/inc/class.uicompleted_reservation.inc.php
Modified: trunk/booking/inc/class.socommon.inc.php
===================================================================
--- trunk/booking/inc/class.socommon.inc.php 2014-04-01 14:03:25 UTC (rev
11881)
+++ trunk/booking/inc/class.socommon.inc.php 2014-04-02 21:41:23 UTC (rev
11882)
@@ -417,7 +417,22 @@
strtolower($results) === 'all' AND $results =
$total_records; //TODO: Kept because of BC. Should be easy to remove this
dependency?
- $order = $sort ? "ORDER BY $sort $dir ": '';
+ /*
+ * Due to problem on order with offset - we need to set
an additional parameter in some cases
+ *
http://stackoverflow.com/questions/13580826/postgresql-repeating-rows-from-limit-offset
+ */
+
+ if($sort)
+ {
+ if(is_array($sort))
+ {
+ $order = "ORDER BY {$sort[0]} {$dir},
{$sort[1]}";
+ }
+ else
+ {
+ $order = "ORDER BY {$sort} {$dir}";
+ }
+ }
$base_sql = "SELECT $cols FROM $this->table_name $joins
WHERE $condition $order ";
if ($results)
@@ -499,7 +514,7 @@
'total_records' => $total_records,
'results' => $results,
'start' => $start,
- 'sort' => $sort,
+ 'sort' => is_array($sort) ?
$sort[0] : $sort,
'dir' => $dir
);
}
Modified: trunk/booking/inc/class.uicompleted_reservation.inc.php
===================================================================
--- trunk/booking/inc/class.uicompleted_reservation.inc.php 2014-04-01
14:03:25 UTC (rev 11881)
+++ trunk/booking/inc/class.uicompleted_reservation.inc.php 2014-04-02
21:41:23 UTC (rev 11882)
@@ -243,6 +243,22 @@
$sort = phpgw::get_var('sort');
$dir = phpgw::get_var('dir');
+ /*
+ * Due to problem on order with offset - we need to set
an additional parameter in some cases
+ *
http://stackoverflow.com/questions/13580826/postgresql-repeating-rows-from-limit-offset
+ */
+
+ switch($sort)
+ {
+ case 'cost':
+ $_sort = array('cost','id');
+ break;
+
+ default:
+ $_sort = $sort;
+ break;
+ }
+
$filters = array();
foreach($this->bo->so->get_field_defs() as $field =>
$params) {
if(phpgw::get_var("filter_$field")) {
@@ -283,7 +299,7 @@
'start' => $start,
'results' => $results,
'query' => $query,
- 'sort' => $sort,
+ 'sort' => $_sort,
'dir' => $dir,
'filters' => $filters
);
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Fmsystem-commits] [11882] booking: FIX for repeating rows from LIMIT OFFSET,
Sigurd Nes <=