v5:database:pdo
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
v5:database:pdo [2016/05/18 01:14] – mnewnham | v5:database:pdo [2022/02/11 12:01] – [Description] move info about pdo driver usage to wrap dregad | ||
---|---|---|---|
Line 1: | Line 1: | ||
====== PDO ====== | ====== PDO ====== | ||
~~NOTOC~~ | ~~NOTOC~~ | ||
- | <WRAP right box> | + | |
- | == See Also == | + | |
- | [[http:// | + | |
- | </ | + | |
===== Description ===== | ===== Description ===== | ||
- | This driver supports connections using the standardized [[http:// | ||
- | * pdo_mssql | + | This driver supports connections using the standardized [[http:// |
- | | + | |
- | | + | Supported drivers: |
- | | + | |
- | | + | ^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 | ||
+ | |||
+ | <WRAP important> | ||
+ | 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 ===== | ===== Establishing A Connection ===== | ||
Line 23: | Line 30: | ||
$user = ' | $user = ' | ||
$password = ' | $password = ' | ||
- | $dsnString= ' | + | $dsnString= ' |
$db-> | $db-> | ||
Line 30: | Line 37: | ||
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). | 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). | ||
- | To connect | + | |
+ | ===== 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, | ||
+ | * In all cases, using native drivers (listed below) provide better functionality, | ||
+ | |||
+ | |||
+ | ===== Setting Construction Parameters ===== | ||
+ | Certain attributes need to be passed to the [[https:// | ||
<code php> | <code php> | ||
- | $db = ADOnewConnection(' | + | $db = newAdoConnection(' |
- | $user = 'root'; | + | $db-> |
+ | \PDO:: | ||
+ | ]; | ||
+ | |||
+ | $dsnString= ' | ||
+ | $db-> | ||
- | $db-> | ||
</ | </ | ||
- | ===== Preferred Drivers | + | ===== The PDO setAttribute function |
- | In all cases, using native drivers | + | For parameters that are set after the class is instantiated, The PDO:: |
===== Individual Driver Status ==== | ===== Individual Driver Status ==== | ||
----------------------- | ----------------------- | ||
Line 47: | Line 69: | ||
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Preferred Driver == | == Preferred Driver == | ||
+ | [[v5: | ||
[[v5: | [[v5: | ||
== Specification == | == Specification == | ||
Line 57: | Line 80: | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
</ | </ | ||
- | The current status of this driver is unknown | + | The current status of this driver is unknown. Consider using the [[v5: |
------------------------------------------ | ------------------------------------------ | ||
==== pdo_mysql ==== | ==== pdo_mysql ==== | ||
Line 66: | Line 89: | ||
^Driver Name|pdo| | ^Driver Name|pdo| | ||
^Data Provider|pdo| | ^Data Provider|pdo| | ||
- | ^Status|Inactive((This driver is not supported by ADOdb project members, but you can contribute to this driver if you have the expertise))| | + | ^Status|Active((This driver is supported by ADOdb project members))| |
^Windows|Yes| | ^Windows|Yes| | ||
^Unix|No| | ^Unix|No| | ||
Line 72: | Line 95: | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
</ | </ | ||
- | The current status of this driver is unknown | + | |
+ | * Some **// | ||
+ | |||
+ | |||
+ | ------------------------------------------------------- | ||
+ | === Sample Connection String === | ||
+ | <code php> | ||
+ | include ' | ||
+ | $db = ADOnewConnection(' | ||
+ | |||
+ | $dsn = ' | ||
+ | $user = ' | ||
+ | $password = ' | ||
+ | |||
+ | $db-> | ||
+ | </ | ||
---------------------------------------------- | ---------------------------------------------- | ||
==== pdo_oci ==== | ==== pdo_oci ==== | ||
Line 81: | Line 119: | ||
^Driver Name|pdo| | ^Driver Name|pdo| | ||
^Data Provider|pdo| | ^Data Provider|pdo| | ||
- | ^Status|Inactive((This driver is not supported by ADOdb project members, but you can contribute to this driver if you have the expertise))| | + | ^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| | ||
</ | </ | ||
- | The current status of this driver | + | == Limitations == |
+ | |||
+ | |||
+ | * There is no support for the complex binding features available in the Native Driver | ||
+ | * Some MetaFunctions are unavailable | ||
+ | |||
+ | ---------------------------------------- | ||
+ | === Sample Connection String === | ||
+ | If you are using the instantclient, | ||
+ | <code php> | ||
+ | |||
+ | // | ||
+ | $tns = " | ||
+ | (DESCRIPTION = | ||
+ | (ADDRESS_LIST = | ||
+ | (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.86.86)(PORT = 1521)) | ||
+ | ) | ||
+ | (CONNECT_DATA = | ||
+ | (SERVICE_NAME = XEPDB1) | ||
+ | ) | ||
+ | ) | ||
+ | "; | ||
+ | $dsnString=" | ||
+ | $db-> | ||
+ | |||
+ | </ | ||
------------------------------------------ | ------------------------------------------ | ||
==== pdo_pgsql ==== | ==== pdo_pgsql ==== | ||
Line 96: | Line 159: | ||
^Driver Name|pdo| | ^Driver Name|pdo| | ||
^Data Provider|pdo| | ^Data Provider|pdo| | ||
- | ^Status|Inactive((This driver is not supported by ADOdb project members, but you can contribute to this driver if you have the expertise))| | + | ^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| | ||
</ | </ | ||
- | The current status of this driver is unknown | + | === Status === |
+ | Some features are not supported | ||
+ | --------------------------------------------------------------- | ||
+ | === Sample Connection String === | ||
+ | <code php> | ||
+ | $db = newAdoConnection(' | ||
+ | |||
+ | $dsn = ' | ||
+ | $user = ' | ||
+ | $pass = ' | ||
+ | |||
+ | $db-> | ||
+ | </ | ||
----------------------------------------------- | ----------------------------------------------- | ||
==== pdo_sqlite ==== | ==== pdo_sqlite ==== | ||
Line 117: | Line 193: | ||
^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
</ | </ | ||
- | + | ---------------------------------------------------------------- | |
- | ==== Sample Connection String | + | === Sample Connection String === |
<code php> | <code php> | ||
include ' | include ' | ||
$db = ADOnewConnection(' | $db = ADOnewConnection(' | ||
- | $db-> | + | |
+ | $dsn = ' | ||
+ | $user = ' | ||
+ | |||
+ | $db-> | ||
</ | </ | ||
- | --------------------------------------- | + | |
+ | ------------------------------------------------- | ||
==== pdo_sqlsrv ==== | ==== pdo_sqlsrv ==== | ||
<WRAP right box round 300px> | <WRAP right box round 300px> | ||
== Preferred Driver == | == Preferred Driver == | ||
[[v5: | [[v5: | ||
- | [[v5: | ||
== Specification == | == Specification == | ||
^Driver Name|pdo| | ^Driver Name|pdo| | ||
Line 135: | Line 216: | ||
^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 144: | Line 225: | ||
* Dates are always returned as strings | * Dates are always returned as strings | ||
* Most // | * Most // | ||
- | * [[v5: | + | * [[v5: |
- | ==== Sample Connection String | + | * 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, |
+ | * You cannot change | ||
+ | * No support for parameter binding | ||
+ | |||
+ | ---------------------------------------------------------------------------- | ||
+ | |||
+ | === Sample Connection String === | ||
<code php> | <code php> | ||
include ' | include ' | ||
$db = ADOnewConnection(' | $db = ADOnewConnection(' | ||
+ | |||
$user = ' | $user = ' | ||
- | $password | + | $pass = ' |
- | $db-> | + | $dsn =' |
+ | |||
+ | $db-> | ||
</ | </ | ||
+ | ----------------------------------------------------------------------------- | ||
+ | |||
+ | ==== pdo_firebird ==== | ||
+ | <WRAP right box round 300px> | ||
+ | == Native Driver == | ||
+ | [[v5: | ||
+ | == 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| | ||
+ | </ | ||
+ | Unlike other pdo drivers, pdo_firebird is the preferred driver for this database. This is due to specific issues with this driver reported [[https:// | ||
+ | |||
+ | ------------------------------------------------------------ | ||
+ | === Sample Connection String === | ||
+ | |||
+ | <code php> | ||
+ | include ' | ||
+ | $db = ADOnewConnection(' | ||
+ | |||
+ | $dsn = ' | ||
+ | $user = ' | ||
+ | $pass = ' | ||
+ | |||
+ | $db-> | ||
+ | |||
+ | </ | ||
+ | {{tag> | ||
v5/database/pdo.txt · Last modified: 2022/02/20 23:47 by mnewnham