mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-04-24 17:08:03 +02:00
PHPC-136: var_dump() CommandResult and QueryResult
This commit is contained in:
+109
-4
@@ -30,6 +30,7 @@
|
||||
#include <bson.h>
|
||||
#include <mongoc.h>
|
||||
#include <mongoc-cursor-cursorid-private.h>
|
||||
#include <mongoc-read-prefs-private.h>
|
||||
|
||||
|
||||
/* PHP Core stuff */
|
||||
@@ -1070,6 +1071,106 @@ void php_phongo_objectid_new_from_oid(zval *object, const bson_oid_t *oid TSRMLS
|
||||
bson_oid_to_string(oid, intern->oid);
|
||||
} /* }}} */
|
||||
|
||||
|
||||
void php_phongo_read_preference_to_zval(zval *retval, mongoc_read_prefs_t *read_prefs) /* {{{ */
|
||||
{
|
||||
|
||||
array_init_size(retval, 2);
|
||||
|
||||
add_assoc_long_ex(retval, ZEND_STRS("mode"), read_prefs->mode);
|
||||
if (read_prefs->tags.len) {
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&read_prefs->tags), read_prefs->tags.len, &state);
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("tags"), state.zchild);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("tags"));
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
void php_phongo_result_to_zval(zval *retval, php_phongo_result_t *result) /* {{{ */
|
||||
{
|
||||
|
||||
array_init_size(retval, 4);
|
||||
|
||||
if (result->cursor) {
|
||||
zval *cursor = NULL;
|
||||
|
||||
MAKE_STD_ZVAL(cursor);
|
||||
array_init_size(cursor, 19);
|
||||
|
||||
add_assoc_long_ex(cursor, ZEND_STRS("stamp"), result->cursor->stamp);
|
||||
|
||||
#define _ADD_BOOL(z, field) add_assoc_bool_ex(z, ZEND_STRS(#field), result->cursor->field)
|
||||
_ADD_BOOL(cursor, is_command);
|
||||
_ADD_BOOL(cursor, sent);
|
||||
_ADD_BOOL(cursor, done);
|
||||
_ADD_BOOL(cursor, failed);
|
||||
_ADD_BOOL(cursor, end_of_event);
|
||||
_ADD_BOOL(cursor, in_exhaust);
|
||||
_ADD_BOOL(cursor, redir_primary);
|
||||
_ADD_BOOL(cursor, has_fields);
|
||||
#undef _ADD_BOOL
|
||||
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&result->cursor->query), result->cursor->query.len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("query"), state.zchild);
|
||||
}
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&result->cursor->fields), result->cursor->fields.len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("fields"), state.zchild);
|
||||
}
|
||||
{
|
||||
zval *read_preference = NULL;
|
||||
|
||||
MAKE_STD_ZVAL(read_preference);
|
||||
php_phongo_read_preference_to_zval(read_preference, result->cursor->read_prefs);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("read_preference"), read_preference);
|
||||
}
|
||||
|
||||
#define _ADD_INT(z, field) add_assoc_long_ex(z, ZEND_STRS(#field), result->cursor->field)
|
||||
_ADD_INT(cursor, flags);
|
||||
_ADD_INT(cursor, skip);
|
||||
_ADD_INT(cursor, limit);
|
||||
_ADD_INT(cursor, count);
|
||||
_ADD_INT(cursor, batch_size);
|
||||
#undef _ADD_INT
|
||||
|
||||
add_assoc_string_ex(cursor, ZEND_STRS("ns"), result->cursor->ns, 1);
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(result->cursor->current), result->cursor->current->len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("current_doc"), state.zchild);
|
||||
}
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("cursor"), cursor);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("cursor"));
|
||||
}
|
||||
|
||||
if (result->firstBatch) {
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(result->firstBatch), result->firstBatch->len, &state);
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("firstBatch"), state.zchild);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("firstBatch"));
|
||||
}
|
||||
add_assoc_long_ex(retval, ZEND_STRS("hint"), result->hint);
|
||||
add_assoc_bool_ex(retval, ZEND_STRS("is_command_cursor"), result->is_command_cursor);
|
||||
|
||||
} /* }}} */
|
||||
|
||||
|
||||
void php_phongo_new_utcdatetime_from_epoch(zval *object, int64_t msec_since_epoch TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_phongo_utcdatetime_t *intern;
|
||||
@@ -1426,10 +1527,14 @@ PHP_MINIT_FUNCTION(phongo)
|
||||
|
||||
/* Prep default object handlers to be used when we register the classes */
|
||||
memcpy(&phongo_std_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
phongo_std_object_handlers.clone_obj = NULL;
|
||||
phongo_std_object_handlers.read_property = NULL;
|
||||
phongo_std_object_handlers.write_property = NULL;
|
||||
phongo_std_object_handlers.get_debug_info = NULL;
|
||||
phongo_std_object_handlers.clone_obj = NULL;
|
||||
/*
|
||||
phongo_std_object_handlers.get_debug_info = NULL;
|
||||
phongo_std_object_handlers.compare_objects = NULL;
|
||||
phongo_std_object_handlers.cast_object = NULL;
|
||||
phongo_std_object_handlers.count_elements = NULL;
|
||||
phongo_std_object_handlers.get_closure = NULL;
|
||||
*/
|
||||
|
||||
PHP_MINIT(bson)(INIT_FUNC_ARGS_PASSTHRU);
|
||||
|
||||
|
||||
@@ -117,6 +117,8 @@ mongoc_read_prefs_t* phongo_read_preference_from_zval(zval *zread_preference
|
||||
mongoc_write_concern_t* phongo_write_concern_from_zval (zval *zwrite_concern TSRMLS_DC);
|
||||
php_phongo_query_t* phongo_query_from_zval (zval *zquery TSRMLS_DC);
|
||||
|
||||
void php_phongo_read_preference_to_zval(zval *retval, mongoc_read_prefs_t *read_prefs);
|
||||
void php_phongo_result_to_zval(zval *retval, php_phongo_result_t *result);
|
||||
|
||||
void php_phongo_objectid_new_from_oid(zval *object, const bson_oid_t *oid TSRMLS_DC);
|
||||
void php_phongo_cursor_new_from_result(zval *object, php_phongo_result_t *result TSRMLS_DC);
|
||||
|
||||
+25
-16
@@ -44,6 +44,8 @@
|
||||
|
||||
PHONGO_API zend_class_entry *php_phongo_commandresult_ce;
|
||||
|
||||
zend_object_handlers php_phongo_handler_commandresult;
|
||||
|
||||
/* {{{ proto MongoDB\Driver\CommandResult CommandResult::__construct(MongoDB\Driver\Server $server, array|object $responseDocument)
|
||||
Constructs a new CommandResult */
|
||||
PHP_METHOD(CommandResult, __construct)
|
||||
@@ -182,16 +184,6 @@ PHP_METHOD(CommandResult, getServer)
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/**
|
||||
* Result returned by Server and Manager executeCommand() methods.
|
||||
*
|
||||
* This object wraps an OP_REPLY. It is constructed after a command is executed
|
||||
* on the server but before a Cursor is created in the driver (if applicable).
|
||||
* This allows the Cursor implementation to be customized.
|
||||
*
|
||||
* For commands that do not support cursors (i.e. most commands), getIterator()
|
||||
* should return a cursor consisting of a single document, the command result.
|
||||
*/
|
||||
/* {{{ MongoDB\Driver\CommandResult */
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(ai_CommandResult___construct, 0, 0, 2)
|
||||
@@ -244,34 +236,51 @@ static void php_phongo_commandresult_free_object(void *object TSRMLS_DC) /* {{{
|
||||
|
||||
zend_object_value php_phongo_commandresult_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_object_value retval;
|
||||
zend_object_value retval;
|
||||
php_phongo_commandresult_t *intern = NULL;
|
||||
|
||||
intern = (php_phongo_commandresult_t *)emalloc(sizeof(php_phongo_commandresult_t));
|
||||
memset(intern, 0, sizeof(php_phongo_commandresult_t));
|
||||
intern = (php_phongo_commandresult_t *)ecalloc(1, sizeof *intern);
|
||||
|
||||
zend_object_std_init(&intern->result.std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->result.std, class_type);
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_commandresult_free_object, NULL TSRMLS_CC);
|
||||
retval.handlers = phongo_get_std_object_handlers();
|
||||
retval.handlers = &php_phongo_handler_commandresult;
|
||||
|
||||
return retval;
|
||||
} /* }}} */
|
||||
|
||||
HashTable *php_phongo_commandresult_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_phongo_commandresult_t *intern;
|
||||
zval retval = zval_used_for_init;
|
||||
|
||||
|
||||
*is_temp = 1;
|
||||
intern = (php_phongo_commandresult_t *)zend_object_store_get_object(object TSRMLS_CC);
|
||||
|
||||
php_phongo_result_to_zval(&retval, &intern->result);
|
||||
|
||||
return Z_ARRVAL(retval);
|
||||
|
||||
} /* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION */
|
||||
PHP_MINIT_FUNCTION(CommandResult)
|
||||
{
|
||||
(void)type; /* We don't care if we are loaded via dl() or extension= */
|
||||
(void)type; (void)module_number;
|
||||
zend_class_entry ce;
|
||||
|
||||
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "CommandResult", php_phongo_commandresult_me);
|
||||
ce.create_object = php_phongo_commandresult_create_object;
|
||||
php_phongo_commandresult_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
php_phongo_commandresult_ce->create_object = php_phongo_commandresult_create_object;
|
||||
php_phongo_commandresult_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
|
||||
php_phongo_commandresult_ce->get_iterator = phongo_result_get_iterator;
|
||||
|
||||
memcpy(&php_phongo_handler_commandresult, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
php_phongo_handler_commandresult.get_debug_info = php_phongo_commandresult_get_debug_info;
|
||||
|
||||
zend_class_implements(php_phongo_commandresult_ce TSRMLS_CC, 1, zend_ce_aggregate);
|
||||
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <bson.h>
|
||||
#include <mongoc.h>
|
||||
#include <mongoc-cursor-private.h>
|
||||
#include <mongoc-read-prefs-private.h>
|
||||
|
||||
/* PHP Core stuff */
|
||||
#include <php.h>
|
||||
@@ -446,104 +445,6 @@ zend_object_value php_phongo_cursor_create_object(zend_class_entry *class_type T
|
||||
return retval;
|
||||
} /* }}} */
|
||||
|
||||
void php_phongo_read_preference_to_zval(zval *retval, mongoc_read_prefs_t *read_prefs) /* {{{ */
|
||||
{
|
||||
|
||||
array_init_size(retval, 2);
|
||||
|
||||
add_assoc_long_ex(retval, ZEND_STRS("mode"), read_prefs->mode);
|
||||
if (read_prefs->tags.len) {
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&read_prefs->tags), read_prefs->tags.len, &state);
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("tags"), state.zchild);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("tags"));
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
void php_phongo_result_to_zval(zval *retval, php_phongo_result_t *result) /* {{{ */
|
||||
{
|
||||
|
||||
array_init_size(retval, 4);
|
||||
|
||||
if (result->cursor) {
|
||||
zval *cursor = NULL;
|
||||
|
||||
MAKE_STD_ZVAL(cursor);
|
||||
array_init_size(cursor, 16);
|
||||
|
||||
add_assoc_long_ex(cursor, ZEND_STRS("stamp"), result->cursor->stamp);
|
||||
|
||||
#define _ADD_BOOL(z, field) add_assoc_bool_ex(z, ZEND_STRS(#field), result->cursor->field)
|
||||
_ADD_BOOL(cursor, is_command);
|
||||
_ADD_BOOL(cursor, sent);
|
||||
_ADD_BOOL(cursor, done);
|
||||
_ADD_BOOL(cursor, failed);
|
||||
_ADD_BOOL(cursor, end_of_event);
|
||||
_ADD_BOOL(cursor, in_exhaust);
|
||||
_ADD_BOOL(cursor, redir_primary);
|
||||
_ADD_BOOL(cursor, has_fields);
|
||||
#undef _ADD_BOOL
|
||||
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&result->cursor->query), result->cursor->query.len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("query"), state.zchild);
|
||||
}
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(&result->cursor->fields), result->cursor->fields.len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("fields"), state.zchild);
|
||||
}
|
||||
{
|
||||
zval *read_preference = NULL;
|
||||
|
||||
MAKE_STD_ZVAL(read_preference);
|
||||
php_phongo_read_preference_to_zval(read_preference, result->cursor->read_prefs);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("read_preference"), read_preference);
|
||||
}
|
||||
|
||||
#define _ADD_INT(z, field) add_assoc_long_ex(z, ZEND_STRS(#field), result->cursor->field)
|
||||
_ADD_INT(cursor, flags);
|
||||
_ADD_INT(cursor, skip);
|
||||
_ADD_INT(cursor, limit);
|
||||
_ADD_INT(cursor, count);
|
||||
_ADD_INT(cursor, batch_size);
|
||||
#undef _ADD_INT
|
||||
|
||||
add_assoc_string_ex(cursor, ZEND_STRS("ns"), result->cursor->ns, 1);
|
||||
{
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(result->cursor->current), result->cursor->current->len, &state);
|
||||
add_assoc_zval_ex(cursor, ZEND_STRS("current_doc"), state.zchild);
|
||||
}
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("cursor"), cursor);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("cursor"));
|
||||
}
|
||||
|
||||
if (result->firstBatch) {
|
||||
php_phongo_bson_state state = PHONGO_BSON_STATE_INITIALIZER;
|
||||
|
||||
MAKE_STD_ZVAL(state.zchild);
|
||||
bson_to_zval(bson_get_data(result->firstBatch), result->firstBatch->len, &state);
|
||||
add_assoc_zval_ex(retval, ZEND_STRS("firstBatch"), state.zchild);
|
||||
} else {
|
||||
add_assoc_null_ex(retval, ZEND_STRS("firstBatch"));
|
||||
}
|
||||
add_assoc_long_ex(retval, ZEND_STRS("hint"), result->hint);
|
||||
add_assoc_bool_ex(retval, ZEND_STRS("is_command_cursor"), result->is_command_cursor);
|
||||
|
||||
} /* }}} */
|
||||
|
||||
HashTable *php_phongo_cursor_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_phongo_cursor_t *intern;
|
||||
|
||||
@@ -44,6 +44,8 @@
|
||||
|
||||
PHONGO_API zend_class_entry *php_phongo_queryresult_ce;
|
||||
|
||||
zend_object_handlers php_phongo_handler_queryresult;
|
||||
|
||||
/* {{{ proto MongoDB\Driver\QueryResult QueryResult::__construct(MongoDB\Driver\Server $server, MongoDB\Driver\CursorId $cursorId, array $firstBatch)
|
||||
Construct a new QueryResult */
|
||||
PHP_METHOD(QueryResult, __construct)
|
||||
@@ -247,35 +249,51 @@ static void php_phongo_queryresult_free_object(void *object TSRMLS_DC) /* {{{ */
|
||||
|
||||
zend_object_value php_phongo_queryresult_create_object(zend_class_entry *class_type TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
zend_object_value retval;
|
||||
zend_object_value retval;
|
||||
php_phongo_queryresult_t *intern = NULL;
|
||||
|
||||
intern = (php_phongo_queryresult_t *)emalloc(sizeof(php_phongo_queryresult_t));
|
||||
memset(intern, 0, sizeof(php_phongo_queryresult_t));
|
||||
intern = (php_phongo_queryresult_t *)ecalloc(1, sizeof *intern);
|
||||
|
||||
zend_object_std_init(&intern->result.std, class_type TSRMLS_CC);
|
||||
object_properties_init(&intern->result.std, class_type);
|
||||
|
||||
retval.handle = zend_objects_store_put(intern, (zend_objects_store_dtor_t) zend_objects_destroy_object, php_phongo_queryresult_free_object, NULL TSRMLS_CC);
|
||||
retval.handlers = phongo_get_std_object_handlers();
|
||||
retval.handlers = &php_phongo_handler_queryresult;
|
||||
|
||||
return retval;
|
||||
} /* }}} */
|
||||
|
||||
HashTable *php_phongo_queryresult_get_debug_info(zval *object, int *is_temp TSRMLS_DC) /* {{{ */
|
||||
{
|
||||
php_phongo_queryresult_t *intern;
|
||||
zval retval = zval_used_for_init;
|
||||
|
||||
|
||||
*is_temp = 1;
|
||||
intern = (php_phongo_queryresult_t *)zend_object_store_get_object(object TSRMLS_CC);
|
||||
|
||||
php_phongo_result_to_zval(&retval, &intern->result);
|
||||
|
||||
return Z_ARRVAL(retval);
|
||||
|
||||
} /* }}} */
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_MINIT_FUNCTION */
|
||||
PHP_MINIT_FUNCTION(QueryResult)
|
||||
{
|
||||
(void)type; /* We don't care if we are loaded via dl() or extension= */
|
||||
(void)module_number; /* We don't care if we are loaded via dl() or extension= */
|
||||
(void)type; (void)module_number;
|
||||
zend_class_entry ce;
|
||||
|
||||
INIT_NS_CLASS_ENTRY(ce, "MongoDB\\Driver", "QueryResult", php_phongo_queryresult_me);
|
||||
ce.create_object = php_phongo_queryresult_create_object;
|
||||
php_phongo_queryresult_ce = zend_register_internal_class(&ce TSRMLS_CC);
|
||||
php_phongo_queryresult_ce->create_object = php_phongo_queryresult_create_object;
|
||||
php_phongo_queryresult_ce->ce_flags |= ZEND_ACC_FINAL_CLASS;
|
||||
php_phongo_queryresult_ce->get_iterator = phongo_result_get_iterator;
|
||||
|
||||
memcpy(&php_phongo_handler_queryresult, phongo_get_std_object_handlers(), sizeof(zend_object_handlers));
|
||||
php_phongo_handler_queryresult.get_debug_info = php_phongo_queryresult_get_debug_info;
|
||||
|
||||
zend_class_implements(php_phongo_queryresult_ce TSRMLS_CC, 1, zend_ce_aggregate);
|
||||
|
||||
|
||||
|
||||
@@ -13,6 +13,7 @@ $result = $manager->executeCommand(DATABASE_NAME, $command);
|
||||
var_dump($command);
|
||||
|
||||
var_dump($result instanceof MongoDB\Driver\CommandResult);
|
||||
var_dump($result);
|
||||
|
||||
echo "Dumping response document:\n";
|
||||
var_dump($result->getResponseDocument());
|
||||
@@ -38,6 +39,71 @@ object(MongoDB\Driver\Command)#%d (1) {
|
||||
}
|
||||
}
|
||||
bool(true)
|
||||
object(MongoDB\Driver\CommandResult)#%d (%d) {
|
||||
["cursor"]=>
|
||||
array(19) {
|
||||
["stamp"]=>
|
||||
int(0)
|
||||
["is_command"]=>
|
||||
bool(true)
|
||||
["sent"]=>
|
||||
bool(true)
|
||||
["done"]=>
|
||||
bool(false)
|
||||
["failed"]=>
|
||||
bool(false)
|
||||
["end_of_event"]=>
|
||||
bool(false)
|
||||
["in_exhaust"]=>
|
||||
bool(false)
|
||||
["redir_primary"]=>
|
||||
bool(false)
|
||||
["has_fields"]=>
|
||||
bool(false)
|
||||
["query"]=>
|
||||
array(1) {
|
||||
["ping"]=>
|
||||
int(1)
|
||||
}
|
||||
["fields"]=>
|
||||
array(0) {
|
||||
}
|
||||
["read_preference"]=>
|
||||
array(2) {
|
||||
["mode"]=>
|
||||
int(1)
|
||||
["tags"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
["flags"]=>
|
||||
int(0)
|
||||
["skip"]=>
|
||||
int(0)
|
||||
["limit"]=>
|
||||
int(1)
|
||||
["count"]=>
|
||||
int(1)
|
||||
["batch_size"]=>
|
||||
int(0)
|
||||
["ns"]=>
|
||||
string(11) "phongo.$cmd"
|
||||
["current_doc"]=>
|
||||
array(1) {
|
||||
["ok"]=>
|
||||
float(1)
|
||||
}
|
||||
}
|
||||
["firstBatch"]=>
|
||||
array(1) {
|
||||
["ok"]=>
|
||||
float(1)
|
||||
}
|
||||
["hint"]=>
|
||||
int(1)
|
||||
["is_command_cursor"]=>
|
||||
bool(false)
|
||||
}
|
||||
Dumping response document:
|
||||
array(1) {
|
||||
["ok"]=>
|
||||
|
||||
@@ -16,23 +16,98 @@ $batch->insert(array('_id' => 3, 'x' => 4, 'y' => 5));
|
||||
$manager->executeWriteBatch(NS, $batch);
|
||||
|
||||
$query = new MongoDB\Driver\Query(array('x' => 3), array('projection' => array('y' => 1)));
|
||||
$cursor = $manager->executeQuery(NS, $query);
|
||||
$qr = $manager->executeQuery(NS, $query);
|
||||
|
||||
var_dump($cursor instanceof MongoDB\Driver\QueryResult);
|
||||
var_dump($qr instanceof MongoDB\Driver\QueryResult);
|
||||
var_dump($qr);
|
||||
|
||||
$server = $cursor->getServer();
|
||||
$server = $qr->getServer();
|
||||
|
||||
var_dump($server instanceof MongoDB\Driver\Server);
|
||||
var_dump($server->getHost());
|
||||
var_dump($server->getPort());
|
||||
|
||||
var_dump(iterator_to_array($cursor));
|
||||
var_dump(iterator_to_array($qr));
|
||||
|
||||
?>
|
||||
===DONE===
|
||||
<?php exit(0); ?>
|
||||
--EXPECTF--
|
||||
bool(true)
|
||||
object(MongoDB\Driver\QueryResult)#%d (%d) {
|
||||
["cursor"]=>
|
||||
array(19) {
|
||||
["stamp"]=>
|
||||
int(0)
|
||||
["is_command"]=>
|
||||
bool(false)
|
||||
["sent"]=>
|
||||
bool(true)
|
||||
["done"]=>
|
||||
bool(false)
|
||||
["failed"]=>
|
||||
bool(false)
|
||||
["end_of_event"]=>
|
||||
bool(false)
|
||||
["in_exhaust"]=>
|
||||
bool(false)
|
||||
["redir_primary"]=>
|
||||
bool(false)
|
||||
["has_fields"]=>
|
||||
bool(true)
|
||||
["query"]=>
|
||||
array(1) {
|
||||
["$query"]=>
|
||||
object(stdClass)#%d (%d) {
|
||||
["x"]=>
|
||||
int(3)
|
||||
}
|
||||
}
|
||||
["fields"]=>
|
||||
array(1) {
|
||||
["y"]=>
|
||||
int(1)
|
||||
}
|
||||
["read_preference"]=>
|
||||
array(2) {
|
||||
["mode"]=>
|
||||
int(1)
|
||||
["tags"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
["flags"]=>
|
||||
int(0)
|
||||
["skip"]=>
|
||||
int(0)
|
||||
["limit"]=>
|
||||
int(0)
|
||||
["count"]=>
|
||||
int(1)
|
||||
["batch_size"]=>
|
||||
int(0)
|
||||
["ns"]=>
|
||||
string(42) "phongo.standalone_manager_executeQuery_001"
|
||||
["current_doc"]=>
|
||||
array(2) {
|
||||
["_id"]=>
|
||||
int(2)
|
||||
["y"]=>
|
||||
int(4)
|
||||
}
|
||||
}
|
||||
["firstBatch"]=>
|
||||
array(2) {
|
||||
["_id"]=>
|
||||
int(2)
|
||||
["y"]=>
|
||||
int(4)
|
||||
}
|
||||
["hint"]=>
|
||||
int(1)
|
||||
["is_command_cursor"]=>
|
||||
bool(false)
|
||||
}
|
||||
bool(true)
|
||||
string(%d) "%s"
|
||||
int(27017)
|
||||
|
||||
@@ -42,7 +42,42 @@ modifiedCount: 1
|
||||
upsertedCount: 1
|
||||
deletedCount: 1
|
||||
upsertedId[3]: int(3)
|
||||
object(MongoDB\Driver\WriteResult)#%d (9) {
|
||||
object(MongoDB\Driver\WriteResult)#%d (%d) {
|
||||
["result"]=>
|
||||
array(4) {
|
||||
["cursor"]=>
|
||||
NULL
|
||||
["firstBatch"]=>
|
||||
array(7) {
|
||||
["nInserted"]=>
|
||||
int(2)
|
||||
["nMatched"]=>
|
||||
int(1)
|
||||
["nModified"]=>
|
||||
int(1)
|
||||
["nRemoved"]=>
|
||||
int(1)
|
||||
["nUpserted"]=>
|
||||
int(1)
|
||||
["upserted"]=>
|
||||
array(1) {
|
||||
[0]=>
|
||||
object(stdClass)#%d (%d) {
|
||||
["index"]=>
|
||||
int(3)
|
||||
["_id"]=>
|
||||
int(3)
|
||||
}
|
||||
}
|
||||
["writeErrors"]=>
|
||||
array(0) {
|
||||
}
|
||||
}
|
||||
["hint"]=>
|
||||
int(1)
|
||||
["is_command_cursor"]=>
|
||||
bool(false)
|
||||
}
|
||||
["nInserted"]=>
|
||||
int(2)
|
||||
["nMatched"]=>
|
||||
|
||||
Reference in New Issue
Block a user