PHP data objects
PHP Data Objects, or PDO for short, represents an abstraction level for database access and enables PHP to access different SQL -based databases, such as MySQL , PostgreSQL or SQLite . Among other things, the porting effort when switching to another database is minimized. Only the database access is abstracted, not the database itself. A database-specific driver is required for the database to be used.
properties
PDO has an object-oriented structure and, in contrast to its counterpart MySQLi, cannot be used procedurally . The object-oriented environment makes it easier for developers to expand the interface functionality.
With PDO, developers have the option of using so-called prepared statements for database instructions . In addition, PDO standardizes the code syntax for sending SQL statements (database queries based on SQL syntax) and processing the result relations obtained. Appropriate methods are provided for this, for example
PDO::beginTransaction() // erstellt eine neue Transaktion
PDO::prepare() // erstellt ein neues prepared statement
PDOStatement::fetch() // liest die nächste Zeile der Ergebnisrelation ein
For a complete reference, see the official PHP documentation.
integration
PHP Data Objects have been an integral part of the language since PHP 5.1. Since PDO is based on the new, more object-oriented approaches of PHP 5, it has only been possible to use it since this version. Before that, the software could be implemented as a PECL module .
See also
Web links
- Official documentation on php.net
- PDO tutorial on net.tutsplus.com, engl.
- Test PDO functions online