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 databases:
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'); $user = 'pdo-user'; $password = 'pdo-pass'; $dsnString= 'host=localhost;dbname=employees;charset=utf8mb4' $db->connect('mysql:' . $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).
In all cases, using native drivers (listed below) provide better functionality, as well as performance, than the equivalent PDO driver.
As of ADOdb 5.21, the PDO::setAttribute() method can be emulated using setConnectionParameter().
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
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'); $user = 'user'; $password = 'password' $db->connect('mysql:hostname=127.0.0.1;database=employees;',$user,$password);
Driver Name | pdo |
---|---|
Data Provider | pdo |
Status | Inactive3) |
Windows | Yes |
Unix | No |
ADOdb V5 | Yes |
ADOdb V6 | Yes |
The current status of this driver is unknown
Driver Name | pdo |
---|---|
Data Provider | pdo |
Status | Inactive4) |
Windows | Yes |
Unix | No |
ADOdb V5 | Yes |
ADOdb V6 | Yes |
The current status of this driver is unknown
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'); $db->connect('sqlite:/home/sqlite/adodb-sqlite.db','root');
Native Mode Driver
ODBC Driver for SQL Server
Driver Name | pdo |
---|---|
Data Provider | pdo |
Status | Active6) |
Windows | Yes |
Unix | No |
ADOdb V5 | Yes |
ADOdb V6 | Yes |
include 'adodb-dir/adodb.inc.php'; $db = ADOnewConnection('pdo'); $user = 'user'; $password = 'password' $db->connect('sqlsrv:server=SERVER\SQLEXPRESS;database=NORTHWND;',$user,$password);