Skip to content

Commit 481600d

Browse files
committed
PHPC-157: Consolidate CommandResult and QueryResult classes
1 parent 9e4277e commit 481600d

File tree

7 files changed

+13
-25
lines changed

7 files changed

+13
-25
lines changed

config.m4

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,13 +173,12 @@ if test "$PHONGO" != "no"; then
173173
";
174174
PHONGO_MONGODB_CLASSES="\
175175
src/MongoDB/Command.c \
176-
src/MongoDB/CommandResult.c \
177176
src/MongoDB/Cursor.c \
178177
src/MongoDB/CursorId.c \
179178
src/MongoDB/Manager.c \
180179
src/MongoDB/Query.c \
181-
src/MongoDB/QueryResult.c \
182180
src/MongoDB/ReadPreference.c \
181+
src/MongoDB/Result.c \
183182
src/MongoDB/Server.c \
184183
src/MongoDB/WriteBatch.c \
185184
src/MongoDB/WriteConcern.c \

docs/crud.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ $query = new MongoDB\Driver\Query(array());
7575
try {
7676
/* Full namespace as the first argument (dbname.collname), and the query object
7777
* to execute as the second.
78-
* Returns MongoDB\Driver\QueryResult on success, throws exception on failure
78+
* Returns MongoDB\Driver\Result on success, throws exception on failure
7979
*/
8080
$cursor = $manager->executeQuery("db.collection", $query, $rp);
8181

php_phongo.c

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ int phongo_execute_query(mongoc_client_t *client, char *namespace, php_phongo_qu
636636
return true;
637637
}
638638

639-
phongo_result_init(return_value, php_phongo_queryresult_ce, cursor, doc, 0, 0 TSRMLS_CC);
639+
phongo_result_init(return_value, php_phongo_result_ce, cursor, doc, 0, 0 TSRMLS_CC);
640640
return true;
641641
} /* }}} */
642642

@@ -686,15 +686,15 @@ int phongo_execute_command(mongoc_client_t *client, char *db, bson_t *command, m
686686
_mongoc_cursor_cursorid_init(cursor);
687687
cursor->limit = 0;
688688
cursor->is_command = false;
689-
phongo_result_init(return_value, php_phongo_commandresult_ce, cursor, &first_batch, mongoc_cursor_get_hint(cursor), 1 TSRMLS_CC);
689+
phongo_result_init(return_value, php_phongo_result_ce, cursor, &first_batch, mongoc_cursor_get_hint(cursor), 1 TSRMLS_CC);
690690
return true;
691691
}
692692
}
693693
}
694694
}
695695
}
696696

697-
phongo_result_init(return_value, php_phongo_commandresult_ce, cursor, doc, mongoc_cursor_get_hint(cursor), 0 TSRMLS_CC);
697+
phongo_result_init(return_value, php_phongo_result_ce, cursor, doc, mongoc_cursor_get_hint(cursor), 0 TSRMLS_CC);
698698
return true;
699699
} /* }}} */
700700

@@ -1587,13 +1587,12 @@ PHP_MINIT_FUNCTION(phongo)
15871587
PHP_MINIT(bson)(INIT_FUNC_ARGS_PASSTHRU);
15881588

15891589
PHP_MINIT(Command)(INIT_FUNC_ARGS_PASSTHRU);
1590-
PHP_MINIT(CommandResult)(INIT_FUNC_ARGS_PASSTHRU);
15911590
PHP_MINIT(Cursor)(INIT_FUNC_ARGS_PASSTHRU);
15921591
PHP_MINIT(CursorId)(INIT_FUNC_ARGS_PASSTHRU);
15931592
PHP_MINIT(Manager)(INIT_FUNC_ARGS_PASSTHRU);
15941593
PHP_MINIT(Query)(INIT_FUNC_ARGS_PASSTHRU);
1595-
PHP_MINIT(QueryResult)(INIT_FUNC_ARGS_PASSTHRU);
15961594
PHP_MINIT(ReadPreference)(INIT_FUNC_ARGS_PASSTHRU);
1595+
PHP_MINIT(Result)(INIT_FUNC_ARGS_PASSTHRU);
15971596
PHP_MINIT(Server)(INIT_FUNC_ARGS_PASSTHRU);
15981597
PHP_MINIT(WriteBatch)(INIT_FUNC_ARGS_PASSTHRU);
15991598
PHP_MINIT(WriteConcern)(INIT_FUNC_ARGS_PASSTHRU);

php_phongo_classes.h

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,6 @@ typedef struct {
5555
php_phongo_bson_state visitor_data;
5656
} php_phongo_result_t;
5757

58-
typedef struct {
59-
php_phongo_result_t result;
60-
} php_phongo_commandresult_t;
61-
6258
typedef struct {
6359
zend_object_iterator iterator;
6460
bson_iter_t first_batch_iter;
@@ -91,10 +87,6 @@ typedef struct {
9187
uint32_t batch_size;
9288
} php_phongo_query_t;
9389

94-
typedef struct {
95-
php_phongo_result_t result;
96-
} php_phongo_queryresult_t;
97-
9890
typedef struct {
9991
zend_object std;
10092
mongoc_read_prefs_t *read_preference;
@@ -194,13 +186,12 @@ typedef struct {
194186
} php_phongo_utcdatetime_t;
195187

196188
extern PHONGO_API zend_class_entry *php_phongo_command_ce;
197-
extern PHONGO_API zend_class_entry *php_phongo_commandresult_ce;
198189
extern PHONGO_API zend_class_entry *php_phongo_cursor_ce;
199190
extern PHONGO_API zend_class_entry *php_phongo_cursorid_ce;
200191
extern PHONGO_API zend_class_entry *php_phongo_manager_ce;
201192
extern PHONGO_API zend_class_entry *php_phongo_query_ce;
202-
extern PHONGO_API zend_class_entry *php_phongo_queryresult_ce;
203193
extern PHONGO_API zend_class_entry *php_phongo_readpreference_ce;
194+
extern PHONGO_API zend_class_entry *php_phongo_result_ce;
204195
extern PHONGO_API zend_class_entry *php_phongo_server_ce;
205196
extern PHONGO_API zend_class_entry *php_phongo_writebatch_ce;
206197
extern PHONGO_API zend_class_entry *php_phongo_writeconcern_ce;
@@ -234,13 +225,12 @@ extern PHONGO_API zend_class_entry *php_phongo_timestamp_ce;
234225
extern PHONGO_API zend_class_entry *php_phongo_utcdatetime_ce;
235226

236227
PHP_MINIT_FUNCTION(Command);
237-
PHP_MINIT_FUNCTION(CommandResult);
238228
PHP_MINIT_FUNCTION(Cursor);
239229
PHP_MINIT_FUNCTION(CursorId);
240230
PHP_MINIT_FUNCTION(Manager);
241231
PHP_MINIT_FUNCTION(Query);
242-
PHP_MINIT_FUNCTION(QueryResult);
243232
PHP_MINIT_FUNCTION(ReadPreference);
233+
PHP_MINIT_FUNCTION(Result);
244234
PHP_MINIT_FUNCTION(Server);
245235
PHP_MINIT_FUNCTION(WriteBatch);
246236
PHP_MINIT_FUNCTION(WriteConcern);

src/MongoDB/Manager.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ PHP_METHOD(Manager, __construct)
117117
mongoc_client_set_stream_initiator(intern->client, phongo_stream_initiator, ctx);
118118
}
119119
/* }}} */
120-
/* {{{ proto MongoDB\Driver\CommandResult Manager::executeCommand(string $db, MongoDB\Driver\Command $command[, MongoDB\Driver\ReadPreference $readPreference = null])
120+
/* {{{ proto MongoDB\Driver\Result Manager::executeCommand(string $db, MongoDB\Driver\Command $command[, MongoDB\Driver\ReadPreference $readPreference = null])
121121
Execute a command */
122122
PHP_METHOD(Manager, executeCommand)
123123
{
@@ -144,7 +144,7 @@ PHP_METHOD(Manager, executeCommand)
144144
phongo_execute_command(intern->client, db, cmd->bson, phongo_read_preference_from_zval(readPreference TSRMLS_CC), return_value, return_value_used TSRMLS_CC);
145145
}
146146
/* }}} */
147-
/* {{{ proto MongoDB\Driver\QueryResult Manager::executeQuery(string $namespace, MongoDB\Driver\Query $zquery[, MongoDB\Driver\ReadPreference $readPreference = null])
147+
/* {{{ proto MongoDB\Driver\Result Manager::executeQuery(string $namespace, MongoDB\Driver\Query $zquery[, MongoDB\Driver\ReadPreference $readPreference = null])
148148
Execute a Query */
149149
PHP_METHOD(Manager, executeQuery)
150150
{

src/MongoDB/Server.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ PHP_METHOD(Server, __construct)
9999
mongoc_uri_destroy(uri);
100100
}
101101
/* }}} */
102-
/* {{{ proto MongoDB\Driver\CommandResult Server::executeCommand(string $db, MongoDB\Driver\Command $command)
102+
/* {{{ proto MongoDB\Driver\Result Server::executeCommand(string $db, MongoDB\Driver\Command $command)
103103
Executes a command on this server */
104104
PHP_METHOD(Server, executeCommand)
105105
{
@@ -125,7 +125,7 @@ PHP_METHOD(Server, executeCommand)
125125
phongo_execute_command(intern->client, db, cmd->bson, NULL, return_value, return_value_used TSRMLS_CC);
126126
}
127127
/* }}} */
128-
/* {{{ proto MongoDB\Driver\QueryResult Server::executeQuery(string $namespace, MongoDB\Driver\Query $zquery)
128+
/* {{{ proto MongoDB\Driver\Result Server::executeQuery(string $namespace, MongoDB\Driver\Query $zquery)
129129
Executes a Query */
130130
PHP_METHOD(Server, executeQuery)
131131
{

tests/functional/query-sort-003.phpt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ object(MongoDB\Driver\Query)#%d (6) {
5656
["batch_size"]=>
5757
int(0)
5858
}
59-
string(26) "MongoDB\Driver\Result"
59+
string(21) "MongoDB\Driver\Result"
6060
string(21) "MongoDB\Driver\Cursor"
6161
abernathy.audrey
6262
alda.murray

0 commit comments

Comments
 (0)