Skip to content

Commit b5c3810

Browse files
committed
PHP-1322 Rename count methods in WriteResults
1 parent 2a6e5d1 commit b5c3810

File tree

5 files changed

+37
-37
lines changed

5 files changed

+37
-37
lines changed

docs/batch.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -108,11 +108,11 @@ $manager = new MongoDB\Manager("mongodb://localhost:27017");
108108
$wc = new MongoDB\WriteConcern(MongoDB\WriteConcern::MAJORITY);
109109
$result = $manager->executeWriteBatch("db.collection", $batch, $wc);
110110

111-
printf("numInserted: %d\n", $result->getNumInserted());
112-
printf("numMatched: %d\n", $result->getNumMatched());
113-
printf("numModified: %d\n", $result->getNumModified());
114-
printf("numUpserted: %d\n", $result->getNumUpserted());
115-
printf("numRemoved: %d\n", $result->getNumRemoved());
111+
printf("numInserted: %d\n", $result->getInsertedCount());
112+
printf("numMatched: %d\n", $result->getMatchedCount());
113+
printf("numModified: %d\n", $result->getModifiedCount());
114+
printf("numUpserted: %d\n", $result->getUpsertedCount());
115+
printf("numRemoved: %d\n", $result->getDeletedCount());
116116

117117
foreach ($result->getUpsertedIds() as $index => $id) {
118118
printf("upsertedId: '%s', index: %d\n", $id, $index);

src/MongoDB/WriteResult.c

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,9 @@
4444

4545
PHONGO_API zend_class_entry *php_phongo_writeresult_ce;
4646

47-
/* {{{ proto integer WriteResult::getNumInserted()
47+
/* {{{ proto integer WriteResult::getInsertedCount()
4848
Returns the number of documents that were inserted */
49-
PHP_METHOD(WriteResult, getNumInserted)
49+
PHP_METHOD(WriteResult, getInsertedCount)
5050
{
5151
php_phongo_writeresult_t *intern;
5252
zend_error_handling error_handling;
@@ -66,9 +66,9 @@ PHP_METHOD(WriteResult, getNumInserted)
6666
RETURN_LONG(intern->nInserted);
6767
}
6868
/* }}} */
69-
/* {{{ proto integer WriteResult::getNumMatched()
69+
/* {{{ proto integer WriteResult::getMatchedCount()
7070
Returns the number of documents that matched the update criteria */
71-
PHP_METHOD(WriteResult, getNumMatched)
71+
PHP_METHOD(WriteResult, getMatchedCount)
7272
{
7373
php_phongo_writeresult_t *intern;
7474
zend_error_handling error_handling;
@@ -88,9 +88,9 @@ PHP_METHOD(WriteResult, getNumMatched)
8888
RETURN_LONG(intern->nMatched);
8989
}
9090
/* }}} */
91-
/* {{{ proto integer WriteResult::getNumModified()
91+
/* {{{ proto integer WriteResult::getModifiedCount()
9292
Returns the number of documents that were actually modified by an update */
93-
PHP_METHOD(WriteResult, getNumModified)
93+
PHP_METHOD(WriteResult, getModifiedCount)
9494
{
9595
php_phongo_writeresult_t *intern;
9696
zend_error_handling error_handling;
@@ -110,9 +110,9 @@ PHP_METHOD(WriteResult, getNumModified)
110110
RETURN_LONG(intern->nModified);
111111
}
112112
/* }}} */
113-
/* {{{ proto integer WriteResult::getNumRemoved()
113+
/* {{{ proto integer WriteResult::getDeletedCount()
114114
Returns the number of documents that were deleted */
115-
PHP_METHOD(WriteResult, getNumRemoved)
115+
PHP_METHOD(WriteResult, getDeletedCount)
116116
{
117117
php_phongo_writeresult_t *intern;
118118
zend_error_handling error_handling;
@@ -132,9 +132,9 @@ PHP_METHOD(WriteResult, getNumRemoved)
132132
RETURN_LONG(intern->nRemoved);
133133
}
134134
/* }}} */
135-
/* {{{ proto integer WriteResult::getNumUpserted()
135+
/* {{{ proto integer WriteResult::getUpsertedCount()
136136
Returns the number of documents that were upserted */
137-
PHP_METHOD(WriteResult, getNumUpserted)
137+
PHP_METHOD(WriteResult, getUpsertedCount)
138138
{
139139
php_phongo_writeresult_t *intern;
140140
zend_error_handling error_handling;
@@ -289,19 +289,19 @@ PHP_METHOD(WriteResult, getWriteErrors)
289289
*/
290290
/* {{{ MongoDB\WriteResult */
291291

292-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getNumInserted, 0, 0, 0)
292+
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getInsertedCount, 0, 0, 0)
293293
ZEND_END_ARG_INFO();
294294

295-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getNumMatched, 0, 0, 0)
295+
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getMatchedCount, 0, 0, 0)
296296
ZEND_END_ARG_INFO();
297297

298-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getNumModified, 0, 0, 0)
298+
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getModifiedCount, 0, 0, 0)
299299
ZEND_END_ARG_INFO();
300300

301-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getNumRemoved, 0, 0, 0)
301+
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getDeletedCount, 0, 0, 0)
302302
ZEND_END_ARG_INFO();
303303

304-
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getNumUpserted, 0, 0, 0)
304+
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getUpsertedCount, 0, 0, 0)
305305
ZEND_END_ARG_INFO();
306306

307307
ZEND_BEGIN_ARG_INFO_EX(ai_WriteResult_getInfo, 0, 0, 0)
@@ -321,11 +321,11 @@ ZEND_END_ARG_INFO();
321321

322322

323323
static zend_function_entry php_phongo_writeresult_me[] = {
324-
PHP_ME(WriteResult, getNumInserted, ai_WriteResult_getNumInserted, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
325-
PHP_ME(WriteResult, getNumMatched, ai_WriteResult_getNumMatched, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
326-
PHP_ME(WriteResult, getNumModified, ai_WriteResult_getNumModified, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
327-
PHP_ME(WriteResult, getNumRemoved, ai_WriteResult_getNumRemoved, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
328-
PHP_ME(WriteResult, getNumUpserted, ai_WriteResult_getNumUpserted, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
324+
PHP_ME(WriteResult, getInsertedCount, ai_WriteResult_getInsertedCount, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
325+
PHP_ME(WriteResult, getMatchedCount, ai_WriteResult_getMatchedCount, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
326+
PHP_ME(WriteResult, getModifiedCount, ai_WriteResult_getModifiedCount, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
327+
PHP_ME(WriteResult, getDeletedCount, ai_WriteResult_getDeletedCount, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
328+
PHP_ME(WriteResult, getUpsertedCount, ai_WriteResult_getUpsertedCount, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
329329
PHP_ME(WriteResult, getInfo, ai_WriteResult_getInfo, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
330330
PHP_ME(WriteResult, getServer, ai_WriteResult_getServer, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)
331331
PHP_ME(WriteResult, getUpsertedIds, ai_WriteResult_getUpsertedIds, ZEND_ACC_PUBLIC|ZEND_ACC_FINAL)

tests/batch/write-0002.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ assert($result instanceof \MongoDB\WriteResult);
2525

2626
printf(
2727
"Inserted %d documents to %s\n",
28-
$result->getNumInserted(),
28+
$result->getInsertedCount(),
2929
$result->getServer()->getHost()
3030
);
3131
printf("hannes: %s\nhayley: %s\n", $hannes_id, $hayley_id);

tests/utils/basic.inc

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -99,11 +99,11 @@ function printWriteResult(MongoDB\WriteResult $result)
9999
{
100100
printServer($result->getServer());
101101

102-
printf("numInserted: %d\n", $result->getNumInserted());
103-
printf("numMatched: %d\n", $result->getNumMatched());
104-
printf("numModified: %d\n", $result->getNumModified());
105-
printf("numUpserted: %d\n", $result->getNumUpserted());
106-
printf("numRemoved: %d\n", $result->getNumRemoved());
102+
printf("numInserted: %d\n", $result->getInsertedCount());
103+
printf("numMatched: %d\n", $result->getMatchedCount());
104+
printf("numModified: %d\n", $result->getModifiedCount());
105+
printf("numUpserted: %d\n", $result->getUpsertedCount());
106+
printf("numRemoved: %d\n", $result->getDeletedCount());
107107

108108
foreach ($result->getUpsertedIds() as $index => $id) {
109109
printf("upsertedId[%d]: ", $index);
@@ -134,16 +134,16 @@ function printWriteError(MongoDB\WriteError $error)
134134
}
135135

136136
function getInsertCount($retval) {
137-
return $retval->getNumInserted();
137+
return $retval->getInsertedCount();
138138
}
139139
function getModifiedCount($retval) {
140-
return $retval->getNumModified();
140+
return $retval->getModifiedCount();
141141
}
142142
function getRemovedCount($retval) {
143-
return $retval->getNumRemoved();
143+
return $retval->getDeletedCount();
144144
}
145145
function getUpsertedCount($retval) {
146-
return $retval->getNumUpserted();
146+
return $retval->getUpsertedCount();
147147
}
148148
function getWriteErrors($retval) {
149149
return (array)$retval->getWriteErrors();

tests/utils/fixtures-users.inc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,6 @@ for ($i = 0; $i < 100; $i++) {
5959

6060
$retval = $manager->executeWriteBatch(NS, $batch);
6161

62-
if ($retval->getNumInserted() !== 100) {
63-
exit(sprintf('skip Fixtures were not loaded (expected: %d, actual: %d)', 100, $retval->getNumInserted()));
62+
if ($retval->getInsertedCount() !== 100) {
63+
exit(sprintf('skip Fixtures were not loaded (expected: %d, actual: %d)', 100, $retval->getInsertedCount()));
6464
}

0 commit comments

Comments
 (0)