- skip to content

# Database Abstraction Layer

### User Tools

- Login

### Site Tools

- Recent changes
- Media Manager
- Sitemap

### Sidebar

##### Resources

- Reference Manual
- User Guide
- The Data Dictionary
- ADOdb-xmlschema
- ADOdb Active Record
- Performance Monitoring
- Date/Time Library
- Session Management Library
- Unsupported Addons
- Coding Standards

##### Supported Databases

- Access
- ADO
- CSV
- Firebird
- Frontbase
- IBM DB2
- Informix
- Interbase
- LDAP
- Microsoft SQL Server
- MySQL
- Netezza
- ODBC
- ODBTP
- Oracle
- PDO
- Postgresql
- SAP ADS
- SAP ASE
- SAP Maxdb
- SAP Sqlanywhere
- Sqlite
- Sybase
- Plain Text
- Visual Foxpro

##### Other

- Feature Comparison Matrix
- Connection Matrix
- Include File Guide

v5:database:odbc

# ODBC

In addition to the genric ODBC driver for use with Windows ODBC drivers, there are additional ODBC drivers that provide extended support for database specific functions

## odbc

##### Specification

Driver Name | odbc
Data Provider | odbc
Status | Active1)
Windows | Yes
Unix | No
ADOdb V5 | Yes
ADOdb V6 | Yes

##### Alternatives

PDO driver for ODBC

- This generic driver can be used with any database with ODBC connection support.
- Connections can only be made using DSN connection strings or pre-defined ODBC connections.
- Performance and functionality may be limited.
- Writing portable applications that use this driver is not recommended.
- When configuring connections on Windows, ensure that the ODBC driver configuration (32 Bit/64 Bit) matches the installed PHP version

### Setting The Cursor Mode

All ADOdb ODBC drivers can configure an appropriate cursor mode. The following modes are available through PHP.

- SQL_CUR_USE_IF_NEEDED
- SQL_CUR_USE_ODBC
- SQL_CUR_USE_DRIVER

The cursor is set by setting the `curmode` prior to the connect statement

    include 'adodb/adodb.inc.php';
    $db = newAdoConnection('odbc');

    $db->curmode = SQL_CUR_USE_IF_NEEDED;

    $db->connect('northwind');

## odbc_mssql

##### Specification

Driver Name | odbc_mssql
Data Provider | odbc
Status | Active2)
Windows | Yes
Unix | No
ADOdb V5 | Yes
ADOdb V6 | Yes

##### Alternatives

SQL Server

When used on Windows clients, this driver needs the Microsoft SQL server native client. There are feature limitations compared to the `mssqlnative` driver, use of that is always recommended.

## odbc_oracle

##### Specification

Driver Name | odbc_oracle
Data Provider | odbc
Status | Active3)
Windows | Yes
Unix | No
ADOdb V5 | Yes
ADOdb V6 | Yes

After connection, the date format is automatically set by the driver by executing the following statement:

    $sql = "ALTER SESSION SET NLS_DATE_FORMAT='YYYY-MM-DD HH24:MI:SS'";
    $db->execute($sql);

### odbc_db2

##### Specification

Driver Name | odbc_db2
Data Provider | odbc
Status | Inactive4)
Windows | Yes
Unix | No
ADOdb V5 | Yes
ADOdb V6 | Yes

##### Alternatives

IBM DB2 Native Mode Driver

Connects to DB2 database using either the IBM or 3rd party ODBC driver

If the driver supports it setting the Cursor Type to `SQL_CUR_USE_ODBC` can provide substantial performance improvements. See top of this page for more information.

##### USING CLI INTERFACE

There were reports that the $host and $database params have to be reversed in Connect() when using the CLI interface.

##### System Error 5

IF you get a System Error 5 when trying to Connect/Load, it could be a permission problem. Give the user connecting to DB2 full rights to the DB2 SQLLIB directory, and place the user in the DBUSERS group.

## Feature Limitations

ODBC connections have functionality limitations include transactional handling. See the Feature Matrix for more information

[odbc, windows, active, supported]
1) , 2) , 3) This driver is actively supported by ADOdb project members
4) This driver is not actively supported or enhanced by ADOdb project members, but you can provide fixes and enhancements if you have the expertise
v5/database/odbc.txt · Last modified: 2016/01/12 16:53 by mnewnham

### Page Tools

- Show pagesource
- Old revisions
- Backlinks
- Rename Page
- Back to top