v5:database:pdo
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| v5:database:pdo [2019/01/03 03:25] – [pdo_pgsql] Added sample connection mnewnham | v5:database:pdo [2022/02/20 23:47] (current) – [Setting Construction Parameters] mnewnham | ||
|---|---|---|---|
| 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 32: | Line 39: | ||
| ===== Preferred Drivers ===== | ===== Preferred Drivers ===== | ||
| - | In all cases, using native drivers (listed below) provide better functionality, | + | |
| + | 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> | ||
| + | $db = newAdoConnection(' | ||
| + | |||
| + | $db-> | ||
| + | \PDO:: | ||
| + | ]; | ||
| + | |||
| + | $dsnString= ' | ||
| + | $db-> | ||
| + | |||
| + | </ | ||
| ===== The PDO setAttribute function ===== | ===== The PDO setAttribute function ===== | ||
| - | As of ADOdb 5.21, the PDO:: | + | For parameters that are set after the class is instantiated, The PDO:: |
| ===== Individual Driver Status ==== | ===== Individual Driver Status ==== | ||
| ----------------------- | ----------------------- | ||
| Line 66: | Line 95: | ||
| ^ADOdb V6|Yes| | ^ADOdb V6|Yes| | ||
| </ | </ | ||
| + | |||
| * Some **// | * Some **// | ||
| - | ==== Sample Connection String | + | |
| + | ------------------------------------------------------- | ||
| + | === Sample Connection String === | ||
| <code php> | <code php> | ||
| include ' | include ' | ||
| - | $db = ADOnewConnection(' | + | $db |
| + | |||
| + | $dsn = ' | ||
| $user = ' | $user = ' | ||
| $password = ' | $password = ' | ||
| - | $db-> | + | |
| + | $db-> | ||
| </ | </ | ||
| ---------------------------------------------- | ---------------------------------------------- | ||
| Line 84: | 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 101: | Line 161: | ||
| ^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| | ||
| </ | </ | ||
| - | ===== Status | + | === Status === |
| Some features are not supported | Some features are not supported | ||
| - | ===== Sample Connection String | + | --------------------------------------------------------------- |
| + | === Sample Connection String === | ||
| <code php> | <code php> | ||
| $db = newAdoConnection(' | $db = newAdoConnection(' | ||
| - | $dsnString= ' | + | |
| + | $dsn | ||
| $user = ' | $user = ' | ||
| - | $password | + | $pass = ' |
| - | $db-> | + | |
| + | $db-> | ||
| </ | </ | ||
| Line 130: | 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> | ||
| Line 156: | Line 225: | ||
| * Dates are always returned as strings | * Dates are always returned as strings | ||
| * Most // | * Most // | ||
| - | * [[v5: | + | * [[v5: |
| * 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, | * 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 the character set in the driver. This is a limitation of the PDO driver, not ADOdb | ||
| + | * No support for parameter binding | ||
| ---------------------------------------------------------------------------- | ---------------------------------------------------------------------------- | ||
| - | ==== Sample Connection String | + | === 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.1546482321.txt.gz · Last modified: by mnewnham
