Database Abstraction Layer for PHP

User Tools

Site Tools


PDO (new)

This is still under development. Feedback is welcome, just add your comments in the pull request.

Driver Namepdo
Data Providerpdo
ADOdb V5Yes
ADOdb V6Yes


This driver supports connections using the standardized PHP Data Objects.This page refers to ADOdb release 5.23.0 and higher. For previous versions of ADOdb, see the Previous Version Of This Page.

Except for the pdo_odbc driver, all PDO drivers include support for full data dictionary functions (e.g. createTableSql(),addIndexSql(), etc.)

Quick Upgrade Notes

  • Instead of newAdoConnection('pdo'), use newAdoConnection('pdo\driver')
  • Passing a DSN statement to newAdoConnection() is no longer supported
  • Do not start the DSN statement with the driver name

Supported drivers

PHP DriverDescriptionADOdb Connector
pdo_ibmIBM DB2ibm
pdo_informixIBM Informixinformix
pdo_odbcGeneric ODBCodbc
pdo_sqlsrvMicrosoft SQL Serversqlsrv

Unsupported Drivers

  • pdo_mssql
  • pdo_dblib
  • pdo_cubrid

Note that the pdo driver cannot be used on its own. It is a technical component that is used internally by the above drivers.

Establishing A Connection

To establish a connection:

  1. The PDO database type must be specified in the ADONewConnection() function call
  2. The DSN style of connection must be used in the connect() statement, e.g. to connect to a MySQL database:
include_once 'adodb/';
$db = ADOnewConnection('pdo\mysql');
$user     = 'pdo-user';
$password = 'pdo-pass';
$dsnString= 'host=localhost;dbname=employees;charset=utf8mb4';

Preferred Drivers

Using ADOdb effectively eliminates the need to use the PHP PDO driver as it hides the PHP level command:

  • It provides true database abstraction, for example, the ADOdb method selectLimit() provides a true abstraction of the row limiting and offset of all databases. With PDO, you still need to provide the database specific syntax.
  • Unless otherwise described below, using native drivers (listed below) provide better functionality, as well as performance, than the equivalent PDO driver. This is true at both the ADOdb and PHP level

Setting Construction Parameters

Certain attributes need to be passed to the PDO Constructor, for example, changing the error mode. To facilitate this, a PDO specific settable array ADOConnection::pdoParameters is provided:

$db = newAdoConnection('pdo\firebird');
$db->pdoParameters = [
$dsnString= 'host=localhost;dbname=employee.fdb';
$db->connect($dsnString,"SYSDBA", "password");

The PDO setAttribute function

For parameters that are set after the class is instantiated, The PDO::setAttribute() method can be populated using setConnectionParameter().

Individual Driver Status


PDO Name


Preferred Driver

Firebird/Interbase Driver

Sample Connection String

include 'adodb-dir/';
$db = ADOnewConnection('pdo\firebird');
$dsn  = 'dbname=employee.fdb;hostname=localhost';
$user = 'SYSDBA';
$pass = 'master-key';


PDO Name


Preferred Driver


  • This driver requires the installation of the IBM DB2 client
  • See the Preferred Driver page for more information about building DSNs for use with DB2 connections.

Sample Connection String

include 'adodb-dir/';
$db   = ADOnewConnection('pdo\ibm');
$dsn = 'hostname=;protocol=tcpip;port=25010;';
$dsn.= 'database=SAMPLE;uid=db2inst1;pwd=somepassword';
$user = '';
$password = ''

IBM Informix

PDO Name


  • There is no native mode driver for IBM Informix Connections
  • This driver requires the installation of the IBM Informix Client
  • Supports Informix Databases version 12+

Sample Connection String

include 'adodb-dir/';
$db   = ADOnewConnection('pdo\informix');
$dsn = 'hostname=;service=ol_informix1410;database=stores_demo;';
$dsn.= 'server=ol_informix1410;protocol=onsoctcp;EnableScrollableCursors=1;';
$user = 'ix-user';
$password = 'ix-password'


PDO Name


Preferred Driver


Sample Connection String

include 'adodb-dir/';
$db   = ADOnewConnection('pdo\mysql');
$dsn  = 'hostname=;database=employees;'
$user = 'user';
$password = 'password'


PDO Name


  • This is a simple driver for connection to any ODBC compliant database.
  • It is useful for reading and simple writes to data sources such as Microsoft Access, Excel and Google Sheets
  • There is no support for Data Dictionary functions or database specific items such as sequences.

Sample Connection String

include 'adodb-dir/';
$db   = ADOnewConnection('pdo\odbc');
* Points directly at the DSN configuration in Windows Control Panel
$dsn  = 'MYDSN'


PDO Name


Preferred Driver


  • There is no support for the complex binding features available in the Native Driver
  • This driver requires installation of an Oracle client, such as InstantClient

Sample Connection String

If you are using the instantclient, and there is no tsnames.ora defined, you can define a connection like this

$db = newAdoConnection('pdo\oci');
//Connecting to Oracle Express on
$tns = " 
      (ADDRESS = (PROTOCOL = TCP)(HOST = = 1521))


PDO Name


Preferred Driver


Sample Connection String

$db = newAdoConnection('pdo\pgsql');
$dsn  = 'pgsql:host=;dbname=dvdrental';
$user = 'someuser';
$pass = 'somepass';


PDO Name


Preferred Driver

SQLite Database

Sample Connection String

include 'adodb-dir/';
$db = ADOnewConnection('pdo\sqlite');
$dsn  = '/home/sqlite/adodb-sqlite.db';
$user = 'root';

SQL Server

PDO Name


Preferred Driver

Native Mode Driver

  • This driver requires the installation of the Microsoft native client library, as well as the Microsoft SQL Server PDO drivers for PHP
  • Dates are always returned as strings
  • This driver can also be used on Linux platforms, beginning with PHP Version 7. The program relies on the Microsoft drivers for Linux. For more information, see the mssqlnative driver
  • You cannot change the character set in the driver. This is a limitation of the PDO driver, not ADOdb

Sample Connection String

include 'adodb-dir/';
$db = ADOnewConnection('pdo\sqlsrv');
$user = 'user';
$pass = 'password';
$dsn  ='server=SERVER\SQLEXPRESS;database=NORTHWND;';

This driver is supported by ADOdb project members
v5/database/pdo_new.txt · Last modified: 2023/01/24 04:00 by mnewnham