@@ -24,46 +24,17 @@ class CursorType {
24
24
class Collection {
25
25
protected $ manager ;
26
26
protected $ rp ;
27
+ protected $ wc ;
27
28
protected $ ns ;
28
29
29
- function __construct (Manager $ manager , $ ns , ReadPreference $ rp = null ) {
30
+ function __construct (Manager $ manager , $ ns , WriteConcern $ wc = null , ReadPreference $ rp = null ) {
30
31
$ this ->manager = $ manager ;
31
32
$ this ->ns = $ ns ;
33
+ $ this ->wc = $ wc ;
32
34
$ this ->rp = $ rp ;
33
35
}
34
36
35
- protected function _opQueryFlags ($ options ) {
36
- $ flags = 0 ;
37
-
38
- $ flags |= $ options ["allowPartialResults " ] ? QueryFlags::PARTIAL : 0 ;
39
- $ flags |= $ options ["cursorType " ] ? $ options ["cursorType " ] : 0 ;
40
- $ flags |= $ options ["oplogReplay " ] ? QueryFlags::OPLOG_REPLY : 0 ;
41
- $ flags |= $ options ["noCursorTimeout " ] ? QueryFlags::NO_CURSOR_TIMEOUT : 0 ;
42
-
43
- return $ flags ;
44
- }
45
-
46
- protected function _buildQuery ($ document , $ options ) {
47
- if ($ options ["comment " ]) {
48
- $ options ["modifiers " ]['$comment ' ] = $ options ["comment " ];
49
- }
50
- if ($ options ["maxTimeMS " ]) {
51
- $ options ["modifiers " ]['$maxTimeMS ' ] = $ options ["maxTimeMS " ];
52
- }
53
- if ($ options ["sort " ]) {
54
- $ options ['$orderby ' ] = $ options ["sort " ];
55
- }
56
-
57
- $ flags = $ this ->_opQueryFlags ($ options );
58
- $ options ["cursorFlags " ] = $ flags ;
59
-
60
-
61
- $ query = new Query ($ document , $ options );
62
-
63
- return $ query ;
64
- }
65
-
66
- function find (array $ document = array (), array $ options = array ()) {
37
+ function find (array $ document = array (), array $ options = array ()) { /* {{{ {{{ */
67
38
68
39
$ options = array_merge ($ this ->getFindOptions (), $ options );
69
40
@@ -72,9 +43,8 @@ function find(array $document = array(), array $options = array()) {
72
43
$ cursor = $ this ->manager ->executeQuery ($ this ->ns , $ query , $ this ->rp );
73
44
74
45
return $ cursor ;
75
- }
76
-
77
- function getFindOptions () {
46
+ } /* }}} */
47
+ function getFindOptions () { /* {{{ */
78
48
return array (
79
49
/**
80
50
* Get partial results from a mongos if some shards are down (instead of throwing an error).
@@ -166,6 +136,37 @@ function getFindOptions() {
166
136
*/
167
137
"sort " => array (),
168
138
);
139
+ } /* }}} */
140
+ protected function _opQueryFlags ($ options ) { /* {{{ */
141
+ $ flags = 0 ;
142
+
143
+ $ flags |= $ options ["allowPartialResults " ] ? QueryFlags::PARTIAL : 0 ;
144
+ $ flags |= $ options ["cursorType " ] ? $ options ["cursorType " ] : 0 ;
145
+ $ flags |= $ options ["oplogReplay " ] ? QueryFlags::OPLOG_REPLY : 0 ;
146
+ $ flags |= $ options ["noCursorTimeout " ] ? QueryFlags::NO_CURSOR_TIMEOUT : 0 ;
147
+
148
+ return $ flags ;
149
+ } /* }}} */
150
+ protected function _buildQuery ($ document , $ options ) { /* {{{ */
151
+ if ($ options ["comment " ]) {
152
+ $ options ["modifiers " ]['$comment ' ] = $ options ["comment " ];
153
+ }
154
+ if ($ options ["maxTimeMS " ]) {
155
+ $ options ["modifiers " ]['$maxTimeMS ' ] = $ options ["maxTimeMS " ];
156
+ }
157
+ if ($ options ["sort " ]) {
158
+ $ options ['$orderby ' ] = $ options ["sort " ];
159
+ }
160
+
161
+ $ flags = $ this ->_opQueryFlags ($ options );
162
+ $ options ["cursorFlags " ] = $ flags ;
163
+
164
+
165
+ $ query = new Query ($ document , $ options );
166
+
167
+ return $ query ;
168
+ } /* }}} */
169
+ /* }}} */
169
170
}
170
171
}
171
172
0 commit comments