mirror of
https://github.com/macintoshplus/mongo-php-driver.git
synced 2026-03-29 20:32:12 +02:00
188 lines
3.7 KiB
PHP
188 lines
3.7 KiB
PHP
<?php
|
|
|
|
namespace MongoDB;
|
|
|
|
/**
|
|
* Result returned by Server and Manager executeWriteBatch() methods.
|
|
*
|
|
* This class may be constructed internally if it will encapsulate a libmongoc
|
|
* data structure.
|
|
*/
|
|
final class WriteResult
|
|
{
|
|
/**
|
|
* Returns the number of documents that were inserted
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getInsertedCount() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
RETURN_LONG(intern->nInserted);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the number of documents that matched the update criteria
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getMatchedCount() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
RETURN_LONG(intern->nMatched);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the number of documents that were actually modified by an update
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getModifiedCount() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
RETURN_LONG(intern->nModified);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the number of documents that were deleted
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getDeletedCount() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
RETURN_LONG(intern->nRemoved);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the number of documents that were upserted
|
|
*
|
|
* @return integer
|
|
*/
|
|
public function getUpsertedCount() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
RETURN_LONG(intern->nUpserted);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns metadata about the operation.
|
|
*
|
|
* @see https://github.com/mongodb/specifications/blob/master/source/server_write_commands.rst#situational-fields
|
|
* @return array Additional metadata for the operation(s) (e.g. lastOp)
|
|
*/
|
|
public function getInfo()
|
|
{
|
|
/*** CIMPL ***/
|
|
/*
|
|
if (intern->info && Z_TYPE_P(intern->info) == IS_ARRAY) {
|
|
RETURN_ZVAL(intern->info, 1, 0);
|
|
}
|
|
|
|
array_init(return_value);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the Server from which the result originated
|
|
*
|
|
* @return Server
|
|
*/
|
|
public function getServer() {
|
|
/*** CIMPL ***/
|
|
/*
|
|
phongo_server_init(return_value, intern->result.hint, NULL TSRMLS_CC);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns the identifiers generated by the server for upsert operations.
|
|
*
|
|
* Each identifier value in the associative array will be indexed by the
|
|
* batch index of the corresponding upsert operation.
|
|
*
|
|
* @return array
|
|
*/
|
|
public function getUpsertedIds()
|
|
{
|
|
/*** CIMPL ***/
|
|
/*
|
|
if (intern->upsertedIds && Z_TYPE_P(intern->upsertedIds) == IS_ARRAY) {
|
|
RETURN_ZVAL(intern->upsertedIds, 1, 0);
|
|
}
|
|
|
|
array_init(return_value);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Return any write concern errors that occurred
|
|
*
|
|
* @return WriteConcernError[]
|
|
*/
|
|
public function getWriteConcernErrors()
|
|
{
|
|
/*** CIMPL ***/
|
|
/*
|
|
if (intern->writeConcernErrors && Z_TYPE_P(intern->writeConcernErrors) == IS_ARRAY) {
|
|
RETURN_ZVAL(intern->writeConcernErrors, 1, 0);
|
|
}
|
|
|
|
array_init(return_value);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
|
|
/**
|
|
* Returns any write errors that occurred
|
|
*
|
|
* @return WriteError[]
|
|
*/
|
|
public function getWriteErrors()
|
|
{
|
|
/*** CIMPL ***/
|
|
/*
|
|
if (intern->writeErrors && Z_TYPE_P(intern->writeErrors) == IS_ARRAY) {
|
|
RETURN_ZVAL(intern->writeErrors, 1, 0);
|
|
}
|
|
|
|
array_init(return_value);
|
|
*/
|
|
/*** CIMPL ***/
|
|
}
|
|
}
|
|
|
|
$WriteResult["internwrapper"] = "result.";
|
|
|
|
$WriteResult["free"] = <<< EOF
|
|
if (intern->info) {
|
|
zval_ptr_dtor(&intern->info);
|
|
}
|
|
|
|
if (intern->upsertedIds) {
|
|
zval_ptr_dtor(&intern->upsertedIds);
|
|
}
|
|
|
|
if (intern->writeConcernErrors) {
|
|
zval_ptr_dtor(&intern->writeConcernErrors);
|
|
}
|
|
|
|
if (intern->writeErrors) {
|
|
zval_ptr_dtor(&intern->writeErrors);
|
|
}
|
|
|
|
EOF;
|