There is a breaking change in the feature from V5. The connection string has changed
This driver supports connections using the standardized PHP Data Objects connection. The pdo driver itself cannot be used, it must be used with one of the supported drivers:
| PHP Driver | Description | ADOdb Connector |
|---|---|---|
| pdo_firebird | Firebird | pdo\firebird |
| pdo_ibm | IBM DB2 | pdo\ibm |
| pdo_mysql | MySQL | pdo\mysql |
| pdo_oci | Oracle | pdo\oci |
| pdo_pgsql | Postgresql | pdo\pgsql |
| pdo_sqlite | SQLite | pdo\sqlite |
| pdo_sqlsrv | SQL Server using Windows Native Client | pdo\sqlsrv |
To establish a connection, the DSN style of connection must be used, the first argument of the DSN string being the database type, e.g. to connect to a MySQL database:
include_once 'adodb/adodb.inc.php'; $db = ADOnewConnection('pdo\mysql'); $user = 'pdo-user'; $password = 'pdo-pass'; $dsnString= 'host=localhost;dbname=employees;charset=utf8mb4'; $db->connect($dsnString,$user,$password);
Note that in the above example, the database type is separated from the rest of the DSN string by a : (colon). The rest of the DSN arguments are separated by a ; (semi-colon).
The PDO::setAttribute() method can be emulated using setConnectionParameter().
Each supported driver offers the same functionality as the native mode one, unless specifically noted below
Microsoft native mode driver For Linux
FreeTDS Driver For Unix
| Driver Name | pdo |
|---|---|
| Data Provider | pdo |
| Status | Inactive1) |
| Windows | No |
| Unix | Yes |
| ADOdb V5 | Yes |
| ADOdb V6 | Yes |
The current status of this driver is unknown. Consider using the mssqlnative driver instead.
| Driver Name | pdo |
|---|---|
| Data Provider | pdo |
| Status | Active2) |
| Windows | Yes |
| Unix | No |
| ADOdb V5 | Yes |
| ADOdb V6 | Yes |
include 'adodb-dir/adodb.inc.php'; $db = ADOnewConnection('pdo'); $dsn = 'mysql:hostname=127.0.0.1;database=employees;' $user = 'user'; $password = 'password' $db->connect($dsn,$user,$password);
If you are using the instantclient, and there is no tsnames.ora defined, you can define a connection like this
//Connecting to Oracle Express on 192.168.86.86 $tns = " (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.86.86)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = XEPDB1) ) ) "; $dsnString="oci:dbname=$tns"; $db->connect($dsnString,$userName,$password);
Some features are not supported
$db = newAdoConnection('pdo'); $dsn = 'pgsql:host=192.168.0.212;dbname=dvdrental'; $user = 'someuser'; $pass = 'somepass'; $db->connect($dsn,$user,$pass);
| Driver Name | pdo |
|---|---|
| Data Provider | pdo |
| Status | Active5) |
| Windows | Yes |
| Unix | No |
| ADOdb V5 | Yes |
| ADOdb V6 | Yes |
include 'adodb-dir/adodb.inc.php'; $db = ADOnewConnection('pdo'); $dsn = 'sqlite:/home/sqlite/adodb-sqlite.db'; $user = 'root'; $db->connect($dsn,$user);
| Driver Name | pdo |
|---|---|
| Data Provider | pdo |
| Status | Active6) |
| Windows | Yes |
| Unix | Yes |
| ADOdb V5 | Yes |
| ADOdb V6 | Yes |
include 'adodb-dir/adodb.inc.php'; $db = ADOnewConnection('pdo'); $user = 'user'; $pass = 'password'; $dsn ='sqlsrv:server=SERVER\SQLEXPRESS;database=NORTHWND;'; $db->connect($dsn,$user,$password);
This driver is available from version 5.21
| Driver Name | pdo |
|---|---|
| Data Provider | pdo |
| Status | Active7) |
| Windows | Yes |
| Unix | Yes |
| ADOdb V5 | Yes |
| ADOdb V6 | Yes |
Unlike other pdo drivers, pdo_firebird is the preferred driver for this database. This is due to specific issues with this driver reported here.
include 'adodb-dir/adodb.inc.php'; $db = ADOnewConnection('pdo'); $dsn = 'firebird:dbname=employee.fdb;hostname=localhost'; $user = 'SYSDBA'; $pass = 'master-key'; $db->connect($dsn,$user,$pass);