Datastore/src/V1/Gapic/DatastoreGapicClient.php
public function commit($projectId, $mode, $mutations, array $optionalArgs = [])
    {
        $request = new CommitRequest();
        $request->setProjectId($projectId);
        $request->setMode($mode);
        $request->setMutations($mutations);
        if (isset($optionalArgs['transaction'])) {
            $request->setTransaction($optionalArgs['transaction']);
        }

        $requestParams = new RequestParamsHeaderDescriptor([
          'project_id' => $request->getProjectId(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'Commit',
            CommitResponse::class,
            $optionalArgs,
            $request
        )->wait();
    }
public function commit($projectId, $mode, $mutations, array $optionalArgs = [])
    {
        $request = new CommitRequest();
        $request->setProjectId($projectId);
        $request->setMode($mode);
        $request->setMutations($mutations);
        if (isset($optionalArgs['transaction'])) {
            $request->setTransaction($optionalArgs['transaction']);
        }

        $requestParams = new RequestParamsHeaderDescriptor([
          'project_id' => $request->getProjectId(),
        ]);
        $optionalArgs['headers'] = isset($optionalArgs['headers'])
            ? array_merge($requestParams->getHeader(), $optionalArgs['headers'])
            : $requestParams->getHeader();

        return $this->startCall(
            'Commit',
            CommitResponse::class,
            $optionalArgs,
            $request
        )->wait();
    }
public function commit ( $ projectId , $ mode , $ mutations , array $ optionalArgs = [ ] ) { $ request = new CommitRequest ( ) ; $ request -> setProjectId ( $ projectId ) ; $ request -> setMode ( $ mode ) ; $ request -> setMutations ( $ mutations ) ; if ( isset ( $ optionalArgs [ 'transaction' ] ) ) { $ request -> setTransaction ( $ optionalArgs [ 'transaction' ] ) ; } $ requestParams = new RequestParamsHeaderDescriptor ( [ 'project_id' => $ request -> getProjectId ( ) , ] ) ; $ optionalArgs [ 'headers' ] = isset ( $ optionalArgs [ 'headers' ] ) ? array_merge ( $ requestParams -> getHeader ( ) , $ optionalArgs [ 'headers' ] ) : $ requestParams -> getHeader ( ) ; return $ this -> startCall ( 'Commit' , CommitResponse :: class , $ optionalArgs , $ request ) -> wait ( ) ; }
Commits a transaction, optionally creating, deleting or modifying some
entities.

Sample code:
```
$datastoreClient = new DatastoreClient();
try {
$projectId = '';
$mode = CommitRequest\Mode::MODE_UNSPECIFIED;
$mutations = [];
$response = $datastoreClient->commit($projectId, $mode, $mutations);
} finally {
$datastoreClient->close();
}
```

@param string     $projectId The ID of the project against which to make the request.
@param int        $mode      The type of commit to perform. Defaults to `TRANSACTIONAL`.
For allowed values, use constants defined on {@see \Google\Cloud\Datastore\V1\CommitRequest\Mode}
@param Mutation[] $mutations The mutations to perform.

When mode is `TRANSACTIONAL`, mutations affecting a single entity are
applied in order. The following sequences of mutations affecting a single
entity are not permitted in a single `Commit` request:

- `insert` followed by `insert`
- `update` followed by `insert`
- `upsert` followed by `insert`
- `delete` followed by `update`

When mode is `NON_TRANSACTIONAL`, no two mutations may affect a single
entity.
@param array $optionalArgs {
Optional.

@type string $transaction
The identifier of the transaction associated with the commit. A
transaction identifier is returned by a call to
[Datastore.BeginTransaction][google.datastore.v1.Datastore.BeginTransaction].
@type RetrySettings|array $retrySettings
Retry settings to use for this call. Can be a
{@see Google\ApiCore\RetrySettings} object, or an associative array
of retry settings parameters. See the documentation on
{@see Google\ApiCore\RetrySettings} for example usage.
}

@return \Google\Cloud\Datastore\V1\CommitResponse

@throws ApiException if the remote call fails
@experimental
Commits a transaction optionally creating deleting or modifying some entities .