Skip to content

Commit fe9fb63

Browse files
committed
PHPC-465: Remove Manager's single write methods
Existing tests for single write methods were ported to executeBulkWrite() tests.
1 parent 011c0c2 commit fe9fb63

File tree

65 files changed

+667
-768
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

65 files changed

+667
-768
lines changed

php_phongo.c

Lines changed: 0 additions & 163 deletions
Original file line numberDiff line numberDiff line change
@@ -501,93 +501,6 @@ mongoc_bulk_operation_t *phongo_bulkwrite_init(zend_bool ordered) { /* {{{ */
501501
return mongoc_bulk_operation_new(ordered);
502502
} /* }}} */
503503

504-
void phongo_unwrap_exception(bool retval, zval *return_value TSRMLS_DC)
505-
{
506-
if (!retval) {
507-
if (instanceof_function(Z_OBJCE_P(EG(exception)), php_phongo_bulkwriteexception_ce TSRMLS_CC)) {
508-
php_phongo_writeresult_t *wr = php_phongo_writeresult_get_from_bulkwriteexception(EG(exception) TSRMLS_CC);
509-
510-
/* Clear the BulkWriteException */
511-
zend_clear_exception(TSRMLS_C);
512-
513-
/* Throw WriteError and/or WriteConcernErrors */
514-
php_phongo_throw_write_errors(wr TSRMLS_CC);
515-
php_phongo_throw_write_concern_error(wr TSRMLS_CC);
516-
517-
if (instanceof_function(Z_OBJCE_P(EG(exception)), php_phongo_writeexception_ce TSRMLS_CC)) {
518-
zend_update_property(Z_OBJCE_P(EG(exception)), EG(exception), ZEND_STRL("writeResult"), return_value TSRMLS_CC);
519-
}
520-
}
521-
}
522-
}
523-
524-
int phongo_execute_single_insert(mongoc_client_t *client, const char *namespace, const bson_t *doc, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
525-
{
526-
bool retval = false;
527-
mongoc_bulk_operation_t *bulk;
528-
529-
bulk = phongo_bulkwrite_init(true);
530-
mongoc_bulk_operation_insert(bulk, doc);
531-
532-
retval = phongo_execute_write(client, namespace, bulk, write_concern, server_id, return_value, return_value_used TSRMLS_CC);
533-
mongoc_bulk_operation_destroy(bulk);
534-
535-
phongo_unwrap_exception(retval, return_value TSRMLS_CC);
536-
return retval;
537-
} /* }}} */
538-
539-
int phongo_execute_single_update(mongoc_client_t *client, const char *namespace, const bson_t *query, const bson_t *update, const mongoc_write_concern_t *write_concern, int server_id, mongoc_update_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
540-
{
541-
bool retval = false;
542-
mongoc_bulk_operation_t *bulk;
543-
544-
bulk = phongo_bulkwrite_init(true);
545-
if (flags & MONGOC_UPDATE_MULTI_UPDATE) {
546-
mongoc_bulk_operation_update(bulk, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
547-
} else {
548-
bson_iter_t iter;
549-
zend_bool replaced = 0;
550-
551-
if (bson_iter_init(&iter, update)) {
552-
while (bson_iter_next (&iter)) {
553-
if (!strchr (bson_iter_key (&iter), '$')) {
554-
mongoc_bulk_operation_replace_one(bulk, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
555-
replaced = 1;
556-
break;
557-
}
558-
}
559-
}
560-
561-
if (!replaced) {
562-
mongoc_bulk_operation_update_one(bulk, query, update, !!(flags & MONGOC_UPDATE_UPSERT));
563-
}
564-
}
565-
retval = phongo_execute_write(client, namespace, bulk, write_concern, server_id, return_value, return_value_used TSRMLS_CC);
566-
mongoc_bulk_operation_destroy(bulk);
567-
568-
phongo_unwrap_exception(retval, return_value TSRMLS_CC);
569-
return retval;
570-
} /* }}} */
571-
572-
int phongo_execute_single_delete(mongoc_client_t *client, const char *namespace, const bson_t *query, const mongoc_write_concern_t *write_concern, int server_id, mongoc_delete_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
573-
{
574-
bool retval = false;
575-
mongoc_bulk_operation_t *bulk;
576-
577-
bulk = phongo_bulkwrite_init(true);
578-
if (flags & MONGOC_DELETE_SINGLE_REMOVE) {
579-
mongoc_bulk_operation_remove_one(bulk, query);
580-
} else {
581-
mongoc_bulk_operation_remove(bulk, query);
582-
}
583-
584-
retval = phongo_execute_write(client, namespace, bulk, write_concern, server_id, return_value, return_value_used TSRMLS_CC);
585-
mongoc_bulk_operation_destroy(bulk);
586-
587-
phongo_unwrap_exception(retval, return_value TSRMLS_CC);
588-
return retval;
589-
} /* }}} */
590-
591504
bool phongo_execute_write(mongoc_client_t *client, const char *namespace, mongoc_bulk_operation_t *bulk, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC) /* {{{ */
592505
{
593506
bson_error_t error;
@@ -1968,82 +1881,6 @@ void php_phongo_new_regex_from_regex_and_options(zval *object, const char *patte
19681881
intern->flags = estrndup(flags, intern->flags_len);
19691882
} /* }}} */
19701883

1971-
bool php_phongo_writeresult_get_write_errors(php_phongo_writeresult_t *writeresult, bson_error_t *error) /* {{{ */
1972-
{
1973-
const char *err = NULL;
1974-
uint32_t code = 0;
1975-
1976-
bson_iter_t iter;
1977-
bson_iter_t citer;
1978-
if (!bson_empty0 (&writeresult->write_result.writeErrors) &&
1979-
bson_iter_init (&iter, &writeresult->write_result.writeErrors) &&
1980-
bson_iter_next (&iter) &&
1981-
BSON_ITER_HOLDS_DOCUMENT (&iter) &&
1982-
bson_iter_recurse (&iter, &citer)) {
1983-
while (bson_iter_next (&citer)) {
1984-
if (BSON_ITER_IS_KEY (&citer, "errmsg")) {
1985-
err = bson_iter_utf8 (&citer, NULL);
1986-
} else if (BSON_ITER_IS_KEY (&citer, "code")) {
1987-
code = bson_iter_int32 (&citer);
1988-
}
1989-
}
1990-
1991-
bson_set_error(error, PHONGO_ERROR_WRITE_SINGLE_FAILED, code, "%s", err);
1992-
return true;
1993-
}
1994-
return false;
1995-
} /* }}} */
1996-
1997-
bool php_phongo_writeresult_get_writeconcern_error(php_phongo_writeresult_t *writeresult, bson_error_t *error) /* {{{ */
1998-
{
1999-
const char *err = NULL;
2000-
uint32_t code = 0;
2001-
bson_iter_t iter;
2002-
bson_iter_t citer;
2003-
2004-
if (!bson_empty0 (&writeresult->write_result.writeConcernErrors) &&
2005-
bson_iter_init (&iter, &writeresult->write_result.writeConcernErrors) &&
2006-
bson_iter_next (&iter) &&
2007-
BSON_ITER_HOLDS_DOCUMENT (&iter) &&
2008-
bson_iter_recurse (&iter, &citer)) {
2009-
while (bson_iter_next (&citer)) {
2010-
if (BSON_ITER_IS_KEY (&citer, "errmsg")) {
2011-
err = bson_iter_utf8 (&citer, NULL);
2012-
} else if (BSON_ITER_IS_KEY (&citer, "code")) {
2013-
code = bson_iter_int32 (&citer);
2014-
}
2015-
}
2016-
2017-
bson_set_error(error, PHONGO_ERROR_WRITECONCERN_FAILED, code, "%s", err);
2018-
return true;
2019-
}
2020-
return false;
2021-
} /* }}} */
2022-
zval* php_phongo_throw_write_errors(php_phongo_writeresult_t *wr TSRMLS_DC) /* {{{ */
2023-
{
2024-
bson_error_t error;
2025-
2026-
if (php_phongo_writeresult_get_write_errors(wr, &error)) {
2027-
return phongo_throw_exception(PHONGO_ERROR_WRITE_SINGLE_FAILED TSRMLS_CC, "%s", error.message);
2028-
}
2029-
return NULL;
2030-
} /* }}} */
2031-
zval* php_phongo_throw_write_concern_error(php_phongo_writeresult_t *wr TSRMLS_DC) /* {{{ */
2032-
{
2033-
bson_error_t error;
2034-
2035-
if (php_phongo_writeresult_get_writeconcern_error(wr, &error)) {
2036-
return phongo_throw_exception(PHONGO_ERROR_WRITECONCERN_FAILED TSRMLS_CC, "%s", error.message);
2037-
}
2038-
return NULL;
2039-
} /* }}} */
2040-
php_phongo_writeresult_t *php_phongo_writeresult_get_from_bulkwriteexception(zval *ex TSRMLS_DC) /* {{{ */
2041-
{
2042-
zval *wr = zend_read_property(php_phongo_bulkwriteexception_ce, ex, ZEND_STRL("writeResult"), 0 TSRMLS_CC);
2043-
2044-
return (php_phongo_writeresult_t *)zend_object_store_get_object(wr TSRMLS_CC);
2045-
} /* }}} */
2046-
20471884
static void php_phongo_cursor_free_current(php_phongo_cursor_t *cursor) /* {{{ */
20481885
{
20491886
if (cursor->visitor_data.zchild) {

php_phongo.h

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -119,9 +119,6 @@ mongoc_bulk_operation_t* phongo_bulkwrite_init (zend_bool ordered);
119119
bool phongo_execute_write (mongoc_client_t *client, const char *namespace, mongoc_bulk_operation_t *bulk, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
120120
int phongo_execute_command (mongoc_client_t *client, const char *db, const bson_t *command, const mongoc_read_prefs_t *read_preference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
121121
int phongo_execute_query (mongoc_client_t *client, const char *namespace, const php_phongo_query_t *query, const mongoc_read_prefs_t *read_preference, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
122-
int phongo_execute_single_insert(mongoc_client_t *client, const char *namespace, const bson_t *doc, const mongoc_write_concern_t *write_concern, int server_id, zval *return_value, int return_value_used TSRMLS_DC);
123-
int phongo_execute_single_update(mongoc_client_t *client, const char *namespace, const bson_t *query, const bson_t *update, const mongoc_write_concern_t *write_concern, int server_id, mongoc_update_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC);
124-
int phongo_execute_single_delete(mongoc_client_t *client, const char *namespace, const bson_t *query, const mongoc_write_concern_t *write_concern, int server_id, mongoc_delete_flags_t flags, zval *return_value, int return_value_used TSRMLS_DC);
125122

126123
mongoc_stream_t* phongo_stream_initiator (const mongoc_uri_t *uri, const mongoc_host_list_t *host, void *user_data, bson_error_t *error);
127124
const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference TSRMLS_DC);
@@ -147,9 +144,6 @@ void php_phongo_new_javascript_from_javascript_and_scope(int init, zval *object,
147144
void php_phongo_new_binary_from_binary_and_type(zval *object, const char *data, size_t data_len, bson_subtype_t type TSRMLS_DC);
148145
void php_phongo_new_regex_from_regex_and_options(zval *object, const char *pattern, const char *flags TSRMLS_DC);
149146

150-
php_phongo_writeresult_t *php_phongo_writeresult_get_from_bulkwriteexception(zval *ex TSRMLS_DC);
151-
zval* php_phongo_throw_write_errors(php_phongo_writeresult_t *wr TSRMLS_DC);
152-
zval* php_phongo_throw_write_concern_error(php_phongo_writeresult_t *wr TSRMLS_DC);
153147
zend_bool phongo_writeerror_init(zval *return_value, bson_t *bson TSRMLS_DC);
154148
zend_bool phongo_writeconcernerror_init(zval *return_value, bson_t *bson TSRMLS_DC);
155149

scripts/convert-mo-tests.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,9 @@ function clientOperation($phase, &$output) {
242242
$retval = <<< CODE
243243
try {
244244
\$wc = new MongoDB\\Driver\\WriteConcern($wc);
245-
\$result = \$manager->executeInsert("databaseName.collectionName", $doc, [], \$wc);
245+
\$bulk = new MongoDB\Driver\BulkWrite();
246+
\$bulk->insert($doc);
247+
\$result = \$manager->executeBulkWrite("databaseName.collectionName", \$bulk, \$wc);
246248
if (\$result->getInsertedCount() == 1) {
247249
var_dump(array("ok" => 1));
248250
} else {

src/MongoDB/Manager.c

Lines changed: 0 additions & 126 deletions
Original file line numberDiff line numberDiff line change
@@ -180,107 +180,6 @@ PHP_METHOD(Manager, executeBulkWrite)
180180
phongo_execute_write(intern->client, namespace, bulk->bulk, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
181181
}
182182
/* }}} */
183-
/* {{{ proto MongoDB\Driver\WriteResult Manager::executeInsert(string $namespace, array|object $document[, array $insertOptions = array()[, MongoDB\Driver\WriteConcern $writeConcern = null]])
184-
Convenience method for single insert operation. */
185-
PHP_METHOD(Manager, executeInsert)
186-
{
187-
php_phongo_manager_t *intern;
188-
char *namespace;
189-
int namespace_len;
190-
zval *document;
191-
zval *insertOptions = NULL;
192-
zval *zwrite_concern = NULL;
193-
bson_t *bson;
194-
(void)return_value_ptr;
195-
196-
197-
intern = (php_phongo_manager_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
198-
199-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sA|a!O!", &namespace, &namespace_len, &document, &insertOptions, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
200-
return;
201-
}
202-
203-
204-
bson = bson_new();
205-
zval_to_bson(document, PHONGO_BSON_ADD_ODS|PHONGO_BSON_ADD_CHILD_ODS, bson, NULL TSRMLS_CC);
206-
207-
/* When PHPC-443 is implemented, insertOptions will be parsed for the
208-
* bypassDocumentValidation option; however, there's nothing to do now. */
209-
210-
phongo_execute_single_insert(intern->client, namespace, bson, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, return_value, return_value_used TSRMLS_CC);
211-
bson_clear(&bson);
212-
}
213-
/* }}} */
214-
/* {{{ proto MongoDB\Driver\WriteResult Manager::executeUpdate(string $namespace, array|object $zquery, array|object $newObj[, array $updateOptions = array()[, MongoDB\Driver\WriteConcern $writeConcern = null]])
215-
Convenience method for single update operation. */
216-
PHP_METHOD(Manager, executeUpdate)
217-
{
218-
php_phongo_manager_t *intern;
219-
char *namespace;
220-
int namespace_len;
221-
zval *zquery;
222-
zval *newObj;
223-
zval *updateOptions = NULL;
224-
zval *zwrite_concern = NULL;
225-
bson_t *query;
226-
bson_t *update;
227-
mongoc_update_flags_t flags = MONGOC_UPDATE_NONE;
228-
(void)return_value_ptr;
229-
230-
231-
intern = (php_phongo_manager_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
232-
233-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sAA|a!O!", &namespace, &namespace_len, &zquery, &newObj, &updateOptions, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
234-
return;
235-
}
236-
237-
238-
query = bson_new();
239-
update = bson_new();
240-
zval_to_bson(zquery, PHONGO_BSON_NONE, query, NULL TSRMLS_CC);
241-
zval_to_bson(newObj, PHONGO_BSON_ADD_CHILD_ODS, update, NULL TSRMLS_CC);
242-
243-
if (updateOptions) {
244-
flags |= php_array_fetch_bool(updateOptions, "multi") ? MONGOC_UPDATE_MULTI_UPDATE : 0 ;
245-
flags |= php_array_fetch_bool(updateOptions, "upsert") ? MONGOC_UPDATE_UPSERT : 0;
246-
}
247-
248-
phongo_execute_single_update(intern->client, namespace, query, update, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, flags, return_value, return_value_used TSRMLS_CC);
249-
bson_clear(&query);
250-
bson_clear(&update);
251-
}
252-
/* }}} */
253-
/* {{{ proto MongoDB\Driver\WriteResult Manager::executeDelete(string $namespace, array|object $query[, array $deleteOptions = array()[, MongoDB\Driver\WriteConcern $writeConcern = null]])
254-
Convenience method for single delete operation. */
255-
PHP_METHOD(Manager, executeDelete)
256-
{
257-
php_phongo_manager_t *intern;
258-
char *namespace;
259-
int namespace_len;
260-
zval *query;
261-
zval *deleteOptions = NULL;
262-
zval *zwrite_concern = NULL;
263-
bson_t *bson;
264-
mongoc_delete_flags_t flags = MONGOC_DELETE_NONE;
265-
(void)return_value_ptr;
266-
267-
268-
intern = (php_phongo_manager_t *)zend_object_store_get_object(getThis() TSRMLS_CC);
269-
270-
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sA|a!O!", &namespace, &namespace_len, &query, &deleteOptions, &zwrite_concern, php_phongo_writeconcern_ce) == FAILURE) {
271-
return;
272-
}
273-
274-
275-
if (deleteOptions && php_array_fetch_bool(deleteOptions, "limit")) {
276-
flags |= MONGOC_DELETE_SINGLE_REMOVE;
277-
}
278-
bson = bson_new();
279-
zval_to_bson(query, PHONGO_BSON_NONE, bson, NULL TSRMLS_CC);
280-
phongo_execute_single_delete(intern->client, namespace, bson, phongo_write_concern_from_zval(zwrite_concern TSRMLS_CC), -1, flags, return_value, return_value_used TSRMLS_CC);
281-
bson_clear(&bson);
282-
}
283-
/* }}} */
284183
/* {{{ proto MongoDB\Driver\ReadPreference Manager::getReadPreference()
285184
Returns the ReadPreference associated with this Manager */
286185
PHP_METHOD(Manager, getReadPreference)
@@ -424,28 +323,6 @@ ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeBulkWrite, 0, 0, 2)
424323
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
425324
ZEND_END_ARG_INFO();
426325

427-
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeInsert, 0, 0, 2)
428-
ZEND_ARG_INFO(0, namespace)
429-
ZEND_ARG_INFO(0, document)
430-
ZEND_ARG_ARRAY_INFO(0, insertOptions, 1)
431-
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
432-
ZEND_END_ARG_INFO();
433-
434-
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeUpdate, 0, 0, 3)
435-
ZEND_ARG_INFO(0, namespace)
436-
ZEND_ARG_INFO(0, zquery)
437-
ZEND_ARG_INFO(0, newObj)
438-
ZEND_ARG_ARRAY_INFO(0, updateOptions, 1)
439-
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
440-
ZEND_END_ARG_INFO();
441-
442-
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_executeDelete, 0, 0, 2)
443-
ZEND_ARG_INFO(0, namespace)
444-
ZEND_ARG_INFO(0, query)
445-
ZEND_ARG_ARRAY_INFO(0, deleteOptions, 1)
446-
ZEND_ARG_OBJ_INFO(0, writeConcern, MongoDB\\Driver\\WriteConcern, 1)
447-
ZEND_END_ARG_INFO();
448-
449326
ZEND_BEGIN_ARG_INFO_EX(ai_Manager_getReadPreference, 0, 0, 0)
450327
ZEND_END_ARG_INFO();
451328

@@ -464,9 +341,6 @@ static zend_function_entry php_phongo_manager_me[] = {
464341
PHP_ME(Manager, executeCommand, ai_Manager_executeCommand, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
465342
PHP_ME(Manager, executeQuery, ai_Manager_executeQuery, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
466343
PHP_ME(Manager, executeBulkWrite, ai_Manager_executeBulkWrite, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
467-
PHP_ME(Manager, executeInsert, ai_Manager_executeInsert, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
468-
PHP_ME(Manager, executeUpdate, ai_Manager_executeUpdate, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
469-
PHP_ME(Manager, executeDelete, ai_Manager_executeDelete, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
470344
PHP_ME(Manager, getReadPreference, ai_Manager_getReadPreference, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
471345
PHP_ME(Manager, getServers, ai_Manager_getServers, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
472346
PHP_ME(Manager, getWriteConcern, ai_Manager_getWriteConcern, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

tests/bson/bson-generate-document-id.phpt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@ require_once __DIR__ . "/../utils/basic.inc";
88

99
$manager = new MongoDB\Driver\Manager(STANDALONE);
1010

11-
$manager->executeInsert(NS, array('_id' => 1, 'x' => 1));
12-
$manager->executeInsert(NS, array('_id' => 2, 'x' => 1));
13-
1411
$user = array(
1512
"username" => "bob",
1613
"address" => array(

tests/bson/bson-ods-001.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,9 @@ $hartmann = $array[0];
152152
var_dump($hartmann->getName());
153153
$hartmann->setName("Dr. " . $hartmann->getName());
154154

155-
$retval = $m->executeUpdate(NS, $hartmannFilter, $hartmann);
155+
$bulk = new MongoDB\Driver\BulkWrite();
156+
$bulk->update($hartmannFilter, $hartmann);
157+
$retval = $m->executeBulkWrite(NS, $bulk);
156158
var_dump($retval->getModifiedCount());
157159
?>
158160
===DONE===

tests/bson/bson-ods-002.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -207,7 +207,9 @@ $array = $m->executeQuery(NS, $queryHartmann)->toArray();
207207
$hartmann = $array[0];
208208
$hartmann->setName("Dr. " . $hartmann->getName());
209209

210-
$retval = $m->executeUpdate(NS, $hartmannFilter, $hartmann);
210+
$bulk = new MongoDB\Driver\BulkWrite();
211+
$bulk->update($hartmannFilter, $hartmann);
212+
$retval = $m->executeBulkWrite(NS, $bulk);
211213
printf("Updated %d person (%s)\n", $retval->getModifiedCount(), $hartmann->getName());
212214

213215
$queryAll = new MongoDB\Driver\Query(array());

tests/bson/bson-utcdatetime-001.phpt

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,9 @@ $manager = new MongoDB\Driver\Manager(STANDALONE);
1313
$classname = BSON_NAMESPACE . "\\UTCDateTime";
1414
$utcdatetime = new $classname("1416445411987");
1515

16-
$manager->executeInsert(NS, array('_id' => 1, 'x' => $utcdatetime));
16+
$bulk = new MongoDB\Driver\BulkWrite();
17+
$bulk->insert(array('_id' => 1, 'x' => $utcdatetime));
18+
$manager->executeBulkWrite(NS, $bulk);
1719

1820
$query = new MongoDB\Driver\Query(array('_id' => 1));
1921
$cursor = $manager->executeQuery(NS, $query);

0 commit comments

Comments
 (0)