@@ -36,24 +36,36 @@ private function getValueFiled()
36
36
{
37
37
$ field = $ this ->select ->getPart (Select::COLUMNS )[0 ];
38
38
39
- return $ field [1 ];
39
+ return (string ) $ field [1 ];
40
+ }
41
+
42
+ /**
43
+ * Get value alias
44
+ *
45
+ * @return string
46
+ */
47
+ private function getValueAlias ()
48
+ {
49
+ $ field = $ this ->select ->getPart (Select::COLUMNS )[0 ];
50
+
51
+ return $ field [2 ];
40
52
}
41
53
42
54
/**
43
55
* {@inheritdoc}
44
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
45
56
*/
46
57
public function load ($ limit , $ offset = null , $ lower = null , $ upper = null )
47
58
{
48
59
$ select = clone $ this ->select ;
49
- $ value = $ this ->getValueFiled ();
60
+ $ valueFiled = $ this ->getValueFiled ();
61
+ $ valueAlias = $ this ->getValueAlias ();
50
62
if ($ lower !== null ) {
51
- $ select ->where ("$ {value } >= ? " , $ lower - self ::DELTA );
63
+ $ select ->where ("$ {valueFiled } >= ? " , $ lower - self ::DELTA );
52
64
}
53
65
if ($ upper !== null ) {
54
- $ select ->where ("$ {value } < ? " , $ upper - self ::DELTA );
66
+ $ select ->where ("$ {valueFiled } < ? " , $ upper - self ::DELTA );
55
67
}
56
- $ select ->order ("value ASC " )
68
+ $ select ->order ("$ {valueAlias} ASC " )
57
69
->limit ($ limit , $ offset );
58
70
59
71
return $ this ->arrayValuesToFloat (
@@ -64,16 +76,15 @@ public function load($limit, $offset = null, $lower = null, $upper = null)
64
76
65
77
/**
66
78
* {@inheritdoc}
67
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
68
79
*/
69
80
public function loadPrevious ($ data , $ index , $ lower = null )
70
81
{
71
82
$ select = clone $ this ->select ;
72
- $ value = $ this ->getValueFiled ();
83
+ $ valueFiled = $ this ->getValueFiled ();
73
84
$ select ->columns (['count ' => 'COUNT(*) ' ])
74
- ->where ("$ {value } < ? " , $ data - self ::DELTA );
85
+ ->where ("$ {valueFiled } < ? " , $ data - self ::DELTA );
75
86
if ($ lower !== null ) {
76
- $ select ->where ("$ {value } >= ? " , $ lower - self ::DELTA );
87
+ $ select ->where ("$ {valueFiled } >= ? " , $ lower - self ::DELTA );
77
88
}
78
89
$ offset = $ this ->select ->getConnection ()
79
90
->fetchRow ($ select )['count ' ];
@@ -86,17 +97,17 @@ public function loadPrevious($data, $index, $lower = null)
86
97
87
98
/**
88
99
* {@inheritdoc}
89
- * @SuppressWarnings(PHPMD.UnusedLocalVariable)
90
100
*/
91
101
public function loadNext ($ data , $ rightIndex , $ upper = null )
92
102
{
93
103
$ select = clone $ this ->select ;
94
- $ value = $ this ->getValueFiled ();
104
+ $ valueFiled = $ this ->getValueFiled ();
105
+ $ valueAlias = $ this ->getValueAlias ();
95
106
$ select ->columns (['count ' => 'COUNT(*) ' ])
96
- ->where ("$ {value } > ? " , $ data + self ::DELTA );
107
+ ->where ("$ {valueFiled } > ? " , $ data + self ::DELTA );
97
108
98
109
if ($ upper !== null ) {
99
- $ select ->where ("$ {value } < ? " , $ data - self ::DELTA );
110
+ $ select ->where ("$ {valueFiled } < ? " , $ data - self ::DELTA );
100
111
}
101
112
102
113
$ offset = $ this ->select ->getConnection ()
@@ -107,11 +118,11 @@ public function loadNext($data, $rightIndex, $upper = null)
107
118
}
108
119
109
120
$ select = clone $ this ->select ;
110
- $ select ->where ("$ {value } >= ? " , $ data - self ::DELTA );
121
+ $ select ->where ("$ {valueFiled } >= ? " , $ data - self ::DELTA );
111
122
if ($ upper !== null ) {
112
- $ select ->where ("$ {value } < ? " , $ data - self ::DELTA );
123
+ $ select ->where ("$ {valueFiled } < ? " , $ data - self ::DELTA );
113
124
}
114
- $ select ->order ("$ {value } DESC " )
125
+ $ select ->order ("$ {valueAlias } DESC " )
115
126
->limit ($ rightIndex - $ offset + 1 , $ offset - 1 );
116
127
117
128
return $ this ->arrayValuesToFloat (
0 commit comments