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
v5:database:pdo [2019/12/27 02:16] mnewnhamv5: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://wiki.hashphp.org/PDO_Tutorial_for_MySQL_Developers|Tutorial On PDO Connections]] +
-</WRAP>+
 ===== Description ===== ===== Description =====
-This driver supports connections using the standardized [[http://php.net/manual/en/book.pdo.php|PHP Data Objects]] connectionThe ''pdo'' driver itself cannot be used, it must be used with one of the supported drivers:+ 
 +This driver supports connections using the standardized [[http://php.net/manual/en/book.pdo.php|PHP Data Objects]].  
 + 
 +Supported drivers:
  
 ^PHP Driver^Description^ADOdb Connector^ ^PHP Driver^Description^ADOdb Connector^
Line 17: Line 17:
 |pdo_sqlsrv|SQL Server using Windows Native Client|sqlsrv| |pdo_sqlsrv|SQL Server using Windows Native Client|sqlsrv|
    
 +<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. 
 +</WRAP>
 +
 +
 ===== 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 34: Line 39:
  
 ===== Preferred Drivers ===== ===== Preferred Drivers =====
-In all cases, using native drivers (listed below) provide better functionality, as well as performance, than the equivalent PDO driver.+ 
 +Using ADOdb effectively eliminates the need to use the PHP PDO driver as it hides the PHP level command: 
 + 
 +  * It provides true database abstraction, for example, the ADOdb method ''selectLimit()'' provides a true abstraction of the row limiting and offset of all databases. With PDO, you still need to provide the database specific syntax. 
 +  * In all cases, using native drivers (listed below) provide better functionality, as well as performance, than the equivalent PDO driver. This is true at both the ADOdb and PHP level 
 + 
 + 
 +===== Setting Construction Parameters ===== 
 +Certain attributes need to be passed to the [[https://www.php.net/manual/en/pdo.construct.php|PDO Constructor]], for example, changing the error mode. To facilitate this, a PDO specific settable array **'' ADOConnection::pdoParameters ''** is provided: 
 + 
 +<code php> 
 +$db = newAdoConnection('pdo'); 
 + 
 +$db->pdoParameters = [ 
 +\PDO::ATTR_ERRMODE => \PDO::ERRMODE_EXCEPTION 
 +]; 
 + 
 +$dsnString= 'host=localhost;dbname=employee.fdb'; 
 +$db->connect('firebird:' . $dsnString,"SYSDBA", "password"); 
 + 
 +</code> 
 ===== The PDO setAttribute function ===== ===== The PDO setAttribute function =====
-As of ADOdb 5.21the PDO::setAttribute() method can be emulated using [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]].+For parameters that are set after the class is instantiatedThe PDO::setAttribute() method can be populated using [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]]. 
 ===== Individual Driver Status ==== ===== Individual Driver Status ====
 ----------------------- -----------------------
Line 101: Line 128:
  
  
-  * There id no support for the complex binding features available in the Native Driver+  * There is no support for the complex binding features available in the Native Driver
   * Some MetaFunctions are unavailable   * Some MetaFunctions are unavailable
  
Line 198: Line 225:
   * Dates are always returned as strings   * Dates are always returned as strings
   * Most //**Meta**// functions are unsupported   * Most //**Meta**// functions are unsupported
-  * [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]] is not supported, so changing the character set at run-time is not available.+  * [[v5:reference:connection:setconnectionparameter|setConnectionParameter()]] is not supported
   * 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, see the [[v5:database:microsoft_sql_server|mssqlnative driver]]   * 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, see the [[v5:database:microsoft_sql_server|mssqlnative driver]]
 +  * You cannot change the character set in the driver. This is a limitation of the PDO driver, not ADOdb
 +  * No support for parameter binding
  
 ---------------------------------------------------------------------------- ----------------------------------------------------------------------------
Line 218: Line 247:
  
 ==== pdo_firebird ==== ==== pdo_firebird ====
-<WRAP info> 
-This driver is available from version 5.21 
-</WRAP> 
 <WRAP right box round 300px> <WRAP right box round 300px>
 == Native Driver == == Native Driver ==
Line 249: Line 275:
  
 </code> </code>
 +
 +{{tag>tier2}}
 +
v5/database/pdo.1577409376.txt.gz · Last modified: 2019/12/27 02:16 by mnewnham