ADOdb

Database Abstraction Layer for PHP

User Tools

Site Tools


v5:database:pdo

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Next revisionBoth sides next revision
v5:database:pdo [2019/01/03 03:25] – [pdo_pgsql] Added sample connection mnewnhamv5:database:pdo [2019/01/06 04:12] mnewnham
Line 6: Line 6:
 </WRAP> </WRAP>
 ===== Description ===== ===== Description =====
-This driver supports connections using the standardized [[http://php.net/manual/en/book.pdo.php|PHP Data Objects]] connection. The ''pdo'' driver itself cannot be used, it must be used with one of the supported databases: +This driver supports connections using the standardized [[http://php.net/manual/en/book.pdo.php|PHP Data Objects]] connection. The ''pdo'' driver itself cannot be used, it must be used with one of the supported drivers:
- +
-  * pdo_mssql (SQL Server with FREETDS) +
-  * pdo_mysql (MySQL) +
-  * pdo_oci (Oracle) +
-  * pdo_pgsql (Postgresql) +
-  * pdo_sqlite (SQLite) +
-  * pdo_sqlsrv (SQL Server with Windows)+
  
 +^PHP Driver^Description^ADOdb Connector^
 +|pdo_firebird|Firebird|firebird|
 +|pdo_mssql|SQL Server with FREETDS|mssql|
 +|pdo_mysql|MySQL|mysql|
 +|pdo_oci|Oracle|oci|
 +|pdo_pgsql|Postgresql|pgsql|
 +|pdo_sqlite|SQLite|sqlite|
 +|pdo_sqlsrv|SQL Server using Windows Native Client|sqlsrv|
 + 
 ===== Establishing A Connection ===== ===== Establishing A Connection =====
 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: 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:
Line 67: Line 69:
 </WRAP> </WRAP>
   * Some **//Meta//** functions are unavailable   * Some **//Meta//** functions are unavailable
 +-------------------------------------------------------
 ==== Sample Connection String ==== ==== Sample Connection String ====
 <code php> <code php>
 include 'adodb-dir/adodb.inc.php'; include 'adodb-dir/adodb.inc.php';
-$db = ADOnewConnection('pdo');+$db   = ADOnewConnection('pdo'); 
 + 
 +$dsn  = 'mysql:hostname=127.0.0.1;database=employees;'
 $user = 'user'; $user = 'user';
 $password = 'password' $password = 'password'
-$db->connect('mysql:hostname=127.0.0.1;database=employees;',$user,$password);+ 
 +$db->connect($dsn,$user,$password);
 </code> </code>
 ---------------------------------------------- ----------------------------------------------
Line 101: Line 106:
 ^Status|Active((This driver is supported by ADOdb project members))| ^Status|Active((This driver is supported by ADOdb project members))|
 ^Windows|Yes| ^Windows|Yes|
-^Unix|No|+^Unix|Yes|
 ^ADOdb V5|Yes| ^ADOdb V5|Yes|
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
Line 107: Line 112:
 ===== Status ===== ===== Status =====
 Some features are not supported Some features are not supported
 +---------------------------------------------------------------
 ===== Sample Connection String ===== ===== Sample Connection String =====
 <code php> <code php>
 $db = newAdoConnection('pdo'); $db = newAdoConnection('pdo');
-$dsnString= 'host=192.168.0.212;dbname=dvdrental';+ 
 +$dsn  = 'pgsql:host=192.168.0.212;dbname=dvdrental';
 $user = 'someuser'; $user = 'someuser';
-$password = 'somepass'; +$pass = 'somepass'; 
-$db->connect('pgsql:'$dsnString,$someuser,$somepass);+ 
 +$db->connect($dsn,$user,$pass);
 </code> </code>
  
Line 130: Line 138:
 ^ADOdb V6|Yes| ^ADOdb V6|Yes|
 </WRAP> </WRAP>
 +----------------------------------------------------------------
 ==== Sample Connection String ==== ==== Sample Connection String ====
 <code php> <code php>
 include 'adodb-dir/adodb.inc.php'; include 'adodb-dir/adodb.inc.php';
 $db = ADOnewConnection('pdo'); $db = ADOnewConnection('pdo');
-$db->connect('sqlite:/home/sqlite/adodb-sqlite.db','root');+ 
 +$dsn  = 'sqlite:/home/sqlite/adodb-sqlite.db'
 +$user = 'root'
 + 
 +$db->connect($dsn,$user);
 </code> </code>
 --------------------------------------- ---------------------------------------
Line 165: Line 177:
 include 'adodb-dir/adodb.inc.php'; include 'adodb-dir/adodb.inc.php';
 $db = ADOnewConnection('pdo'); $db = ADOnewConnection('pdo');
 +
 $user = 'user'; $user = 'user';
-$password = 'password' +$pass = 'password'; 
-$db->connect('sqlsrv:server=SERVER\SQLEXPRESS;database=NORTHWND;',$user,$password);+$dsn  ='sqlsrv:server=SERVER\SQLEXPRESS;database=NORTHWND;'
 + 
 +$db->connect($dsn,$user,$password);
 </code> </code>
  
 +-----------------------------------------------------------------------------
  
 +==== pdo_firebird ====
 +<WRAP info>
 +This driver is available from version 5.21
 +</WRAP>
 +<WRAP right box round 300px>
 +== Native Driver ==
 +[[v5:database:firebird|Firebird/Interbase Driver]]\\
 +== Specification ==
 +^Driver Name|pdo|
 +^Data Provider|pdo|
 +^Status|Active((This driver is supported by ADOdb project members))|
 +^Windows|Yes|
 +^Unix|Yes|
 +^ADOdb V5|Yes|
 +^ADOdb V6|Yes|
 +</WRAP>
 +Unlike other pdo drivers, pdo_firebird is the preferred driver for this database. This is due to specific issues with this driver reported [[https://bugs.php.net/bug.php?id=72175|here]]. 
  
 +------------------------------------------------------------
 +==== Sample Connection String ====
 +<code php>
 +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);
 +
 +</code>
v5/database/pdo.txt · Last modified: 2022/02/20 23:47 by mnewnham