Skip to content

Commit b388634

Browse files
committed
Merge pull request #443
2 parents 512658e + 1470d5c commit b388634

File tree

3 files changed

+22
-8
lines changed

3 files changed

+22
-8
lines changed

src/MongoDB/BulkWrite.c

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -275,9 +275,16 @@ PHP_METHOD(BulkWrite, update)
275275
}
276276

277277
if (php_phongo_bulkwrite_update_has_operators(bupdate)) {
278-
if (!mongoc_bulk_operation_update_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
279-
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
280-
goto cleanup;
278+
if (zoptions && php_array_existsc(zoptions, "multi") && php_array_fetchc_bool(zoptions, "multi")) {
279+
if (!mongoc_bulk_operation_update_many_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
280+
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
281+
goto cleanup;
282+
}
283+
} else {
284+
if (!mongoc_bulk_operation_update_one_with_opts(intern->bulk, bquery, bupdate, boptions, &error)) {
285+
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
286+
goto cleanup;
287+
}
281288
}
282289
} else {
283290
if (!bson_validate(bupdate, BSON_VALIDATE_DOT_KEYS|BSON_VALIDATE_DOLLAR_KEYS, NULL)) {
@@ -335,9 +342,16 @@ PHP_METHOD(BulkWrite, delete)
335342
goto cleanup;
336343
}
337344

338-
if (!mongoc_bulk_operation_remove_with_opts(intern->bulk, bquery, boptions, &error)) {
339-
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
340-
goto cleanup;
345+
if (zoptions && php_array_existsc(zoptions, "limit") && php_array_fetchc_bool(zoptions, "limit")) {
346+
if (!mongoc_bulk_operation_remove_one_with_opts(intern->bulk, bquery, boptions, &error)) {
347+
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
348+
goto cleanup;
349+
}
350+
} else {
351+
if (!mongoc_bulk_operation_remove_many_with_opts(intern->bulk, bquery, boptions, &error)) {
352+
phongo_throw_exception_from_bson_error_t(&error TSRMLS_CC);
353+
goto cleanup;
354+
}
341355
}
342356

343357
intern->num_ops++;

src/libmongoc

Submodule libmongoc updated 97 files

0 commit comments

Comments
 (0)