|
30 | 30 | #include "mongoc-cursor-cursorid-private.h" |
31 | 31 | #include "mongoc-read-prefs-private.h" |
32 | 32 | #include "mongoc-bulk-operation-private.h" |
| 33 | +#include "mongoc-read-concern-private.h" |
33 | 34 | #include "mongoc-write-concern-private.h" |
34 | 35 | #include "mongoc-uri-private.h" |
35 | 36 | #include "mongoc-trace.h" |
@@ -243,6 +244,17 @@ void phongo_server_init(zval *return_value, mongoc_client_t *client, int server_ |
243 | 244 | } |
244 | 245 | /* }}} */ |
245 | 246 |
|
| 247 | +void phongo_readconcern_init(zval *return_value, const mongoc_read_concern_t *read_concern TSRMLS_DC) /* {{{ */ |
| 248 | +{ |
| 249 | + php_phongo_readconcern_t *intern; |
| 250 | + |
| 251 | + object_init_ex(return_value, php_phongo_readconcern_ce); |
| 252 | + |
| 253 | + intern = (php_phongo_readconcern_t *)zend_object_store_get_object(return_value TSRMLS_CC); |
| 254 | + intern->read_concern = mongoc_read_concern_copy(read_concern); |
| 255 | +} |
| 256 | +/* }}} */ |
| 257 | + |
246 | 258 | void phongo_readpreference_init(zval *return_value, const mongoc_read_prefs_t *read_prefs TSRMLS_DC) /* {{{ */ |
247 | 259 | { |
248 | 260 | php_phongo_readpreference_t *intern; |
@@ -585,6 +597,10 @@ int phongo_execute_query(mongoc_client_t *client, const char *namespace, const p |
585 | 597 | efree(dbname); |
586 | 598 | efree(collname); |
587 | 599 |
|
| 600 | + if (query->read_concern) { |
| 601 | + mongoc_collection_set_read_concern(collection, query->read_concern); |
| 602 | + } |
| 603 | + |
588 | 604 | cursor = mongoc_collection_find(collection, query->flags, query->skip, query->limit, query->batch_size, query->query, query->selector, read_preference); |
589 | 605 | mongoc_collection_destroy(collection); |
590 | 606 |
|
@@ -1208,6 +1224,19 @@ const mongoc_write_concern_t* phongo_write_concern_from_zval(zval *zwrite_concer |
1208 | 1224 | return NULL; |
1209 | 1225 | } /* }}} */ |
1210 | 1226 |
|
| 1227 | +const mongoc_read_concern_t* phongo_read_concern_from_zval(zval *zread_concern TSRMLS_DC) /* {{{ */ |
| 1228 | +{ |
| 1229 | + if (zread_concern) { |
| 1230 | + php_phongo_readconcern_t *intern = (php_phongo_readconcern_t *)zend_object_store_get_object(zread_concern TSRMLS_CC); |
| 1231 | + |
| 1232 | + if (intern) { |
| 1233 | + return intern->read_concern; |
| 1234 | + } |
| 1235 | + } |
| 1236 | + |
| 1237 | + return NULL; |
| 1238 | +} /* }}} */ |
| 1239 | + |
1211 | 1240 | const mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference TSRMLS_DC) /* {{{ */ |
1212 | 1241 | { |
1213 | 1242 | if (zread_preference) { |
@@ -1296,6 +1325,19 @@ void php_phongo_server_to_zval(zval *retval, const mongoc_server_description_t * |
1296 | 1325 |
|
1297 | 1326 | } /* }}} */ |
1298 | 1327 |
|
| 1328 | +void php_phongo_read_concern_to_zval(zval *retval, const mongoc_read_concern_t *read_concern) /* {{{ */ |
| 1329 | +{ |
| 1330 | + const char *level = mongoc_read_concern_get_level(read_concern); |
| 1331 | + |
| 1332 | + array_init_size(retval, 1); |
| 1333 | + |
| 1334 | + if (level) { |
| 1335 | + add_assoc_string_ex(retval, ZEND_STRS("level"), (char *)level, 1); |
| 1336 | + } else { |
| 1337 | + add_assoc_null_ex(retval, ZEND_STRS("level")); |
| 1338 | + } |
| 1339 | +} /* }}} */ |
| 1340 | + |
1299 | 1341 | void php_phongo_read_preference_to_zval(zval *retval, const mongoc_read_prefs_t *read_prefs) /* {{{ */ |
1300 | 1342 | { |
1301 | 1343 |
|
@@ -2189,6 +2231,7 @@ PHP_MINIT_FUNCTION(mongodb) |
2189 | 2231 | PHP_MINIT(CursorId)(INIT_FUNC_ARGS_PASSTHRU); |
2190 | 2232 | PHP_MINIT(Manager)(INIT_FUNC_ARGS_PASSTHRU); |
2191 | 2233 | PHP_MINIT(Query)(INIT_FUNC_ARGS_PASSTHRU); |
| 2234 | + PHP_MINIT(ReadConcern)(INIT_FUNC_ARGS_PASSTHRU); |
2192 | 2235 | PHP_MINIT(ReadPreference)(INIT_FUNC_ARGS_PASSTHRU); |
2193 | 2236 | PHP_MINIT(Server)(INIT_FUNC_ARGS_PASSTHRU); |
2194 | 2237 | PHP_MINIT(BulkWrite)(INIT_FUNC_ARGS_PASSTHRU); |
|
0 commit comments