@@ -108,9 +108,16 @@ public function close()
108
108
*/
109
109
public function destroy ($ sessionId )
110
110
{
111
- $ this ->getCollection ()->deleteOne (array (
112
- $ this ->options ['id_field ' ] => $ sessionId ,
113
- ));
111
+ if ($ this ->getCollection () instanceof \MongoDB \Collection)
112
+ {
113
+ $ this ->getCollection ()->deleteOne (array (
114
+ $ this ->options ['id_field ' ] => $ sessionId ,
115
+ ));
116
+ }else {
117
+ $ this ->getCollection ()->remove (array (
118
+ $ this ->options ['id_field ' ] => $ sessionId ,
119
+ ));
120
+ }
114
121
115
122
return true ;
116
123
}
@@ -120,9 +127,16 @@ public function destroy($sessionId)
120
127
*/
121
128
public function gc ($ maxlifetime )
122
129
{
123
- $ this ->getCollection ()->deleteMany (array (
124
- $ this ->options ['expiry_field ' ] => array ('$lt ' => new \MongoDate ()),
125
- ));
130
+ if ($ this ->getCollection () instanceof \MongoDB \Collection)
131
+ {
132
+ $ this ->getCollection ()->deleteMany (array (
133
+ $ this ->options ['id_field ' ] => $ sessionId ,
134
+ ));
135
+ }else {
136
+ $ this ->getCollection ()->remove (array (
137
+ $ this ->options ['expiry_field ' ] => array ('$lt ' => new \MongoDate ()),
138
+ ));
139
+ }
126
140
127
141
return true ;
128
142
}
@@ -140,11 +154,20 @@ public function write($sessionId, $data)
140
154
$ this ->options ['expiry_field ' ] => $ expiry ,
141
155
);
142
156
143
- $ this ->getCollection ()->updateOne (
144
- array ($ this ->options ['id_field ' ] => $ sessionId ),
145
- array ('$set ' => $ fields ),
146
- array ('upsert ' => true , 'multiple ' => false )
147
- );
157
+ if ($ this ->getCollection () instanceof \MongoDB \Collection)
158
+ {
159
+ $ this ->getCollection ()->updateOne (
160
+ array ($ this ->options ['id_field ' ] => $ sessionId ),
161
+ array ('$set ' => $ fields ),
162
+ array ('upsert ' => true , 'multiple ' => false )
163
+ );
164
+ }else {
165
+ $ this ->getCollection ()->update (
166
+ array ($ this ->options ['id_field ' ] => $ sessionId ),
167
+ array ('$set ' => $ fields ),
168
+ array ('upsert ' => true , 'multiple ' => false )
169
+ );
170
+ }
148
171
149
172
return true ;
150
173
}
0 commit comments