Toggle autocommit behaviour

- « ODBC Functions

- odbc_binmode »

- PHP Manual
- ODBC Functions
- Toggle autocommit behaviour

# odbc_autocommit

(PHP 4, PHP 5, PHP 7, PHP 8)

odbc_autocommit — Toggle autocommit behaviour

### Description

odbc_autocommit(resource `$odbc`, bool `$enable` = `null`): int|bool

Toggles autocommit behaviour.

By default, auto-commit is on for a connection. Disabling auto-commit is equivalent with starting a transaction.

### Parameters

`odbc`

  The ODBC connection identifier, see odbc_connect() for details.

`enable`

  If `enable` is `true`, auto-commit is enabled, if it is `false` auto-commit is disabled. If `null` is passed, this function returns the auto-commit status for `odbc`.

### Return Values

Without the `enable` parameter, this function returns auto-commit status for `odbc`. Non-zero is returned if auto-commit is on, 0 if it is off, or `false` if an error occurs.

If `enable` is set, this function returns `true` on success and `false` on failure.

### Changelog

Version | Description
--- | ---
8.3.0 | `enable` is now nullable.

### See Also

- odbc_commit() - Commit an ODBC transaction
- odbc_rollback() - Rollback a transaction