File tree 3 files changed +18
-7
lines changed
3 files changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -18,12 +18,12 @@ class Builder extends \Illuminate\Database\Query\Builder {
18
18
* @var array
19
19
*/
20
20
protected $ conversion = array (
21
- '= ' => '= ' ,
21
+ '= ' => '= ' ,
22
22
'!= ' => '$ne ' ,
23
23
'<> ' => '$ne ' ,
24
- '< ' => '$lt ' ,
24
+ '< ' => '$lt ' ,
25
25
'<= ' => '$lte ' ,
26
- '> ' => '$gt ' ,
26
+ '> ' => '$gt ' ,
27
27
'>= ' => '$gte ' ,
28
28
);
29
29
@@ -121,7 +121,8 @@ public function getFresh($columns = array('*'))
121
121
122
122
// Apply order and limit
123
123
if ($ this ->orders ) $ pipeline [] = array ('$sort ' => $ this ->orders );
124
- if ($ this ->limit ) $ pipeline [] = array ('$limit ' => $ this ->limit );
124
+ if ($ this ->offset ) $ pipeline [] = array ('$skip ' => $ this ->offset );
125
+ if ($ this ->limit ) $ pipeline [] = array ('$limit ' => $ this ->limit );
125
126
126
127
$ results = $ this ->collection ->aggregate ($ pipeline );
127
128
@@ -150,7 +151,7 @@ public function getFresh($columns = array('*'))
150
151
// Apply order, offset and limit
151
152
if ($ this ->orders ) $ cursor ->sort ($ this ->orders );
152
153
if ($ this ->offset ) $ cursor ->skip ($ this ->offset );
153
- if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
154
+ if ($ this ->limit ) $ cursor ->limit ($ this ->limit );
154
155
155
156
// Return results
156
157
return iterator_to_array ($ cursor , false );
Original file line number Diff line number Diff line change @@ -105,14 +105,14 @@ protected function getDsn(array $config)
105
105
$ dsn .= "{$ username }: {$ password }@ " ;
106
106
}
107
107
108
- $ dsn .= "{$ host }" ;
108
+ $ dsn .= "{$ host }" ;
109
109
110
110
if (isset ($ config ['port ' ]))
111
111
{
112
112
$ dsn .= ": {$ port }" ;
113
113
}
114
114
115
- $ dsn .= "/ {$ database }" ;
115
+ $ dsn .= "/ {$ database }" ;
116
116
117
117
return $ dsn ;
118
118
}
Original file line number Diff line number Diff line change @@ -244,10 +244,20 @@ public function testGroupBy()
244
244
$ users = User::groupBy ('age ' )->get ();
245
245
$ this ->assertEquals (6 , count ($ users ));
246
246
247
+ $ users = User::groupBy ('age ' )->skip (1 )->get ();
248
+ $ this ->assertEquals (5 , count ($ users ));
249
+
250
+ $ users = User::groupBy ('age ' )->take (2 )->get ();
251
+ $ this ->assertEquals (2 , count ($ users ));
252
+
247
253
$ users = User::groupBy ('age ' )->orderBy ('age ' , 'desc ' )->get ();
248
254
$ this ->assertEquals (37 , $ users [0 ]->age );
249
255
$ this ->assertEquals (35 , $ users [1 ]->age );
250
256
$ this ->assertEquals (33 , $ users [2 ]->age );
257
+
258
+ $ users = User::groupBy ('age ' )->skip (1 )->take (2 )->orderBy ('age ' , 'desc ' )->get ();
259
+ $ this ->assertEquals (35 , $ users [0 ]->age );
260
+ $ this ->assertEquals (33 , $ users [1 ]->age );
251
261
}
252
262
253
263
public function testSubquery ()
You can’t perform that action at this time.
0 commit comments