PDO Functions PDO
&reftitle.intro; &warn.experimental; The PHP Data Objects (PDO) extension defines a lightweight, consistent interface for accessing databases in PHP. Each database driver that implements the PDO interface can expose database-specific features as regular extension functions. Note that you cannot perform any database functions using the PDO extension by itself; you must use a database-specific PDO driver to access a database server.
&reftitle.install; Windows Follow the same steps to install and enable the PDO drivers of your choice. Windows users can download the extension DLL php_pdo.dll as part of the PECL collection binaries from &url.php.downloads; or a more recent version from a PHP 5 PECL Snapshot. To enable the PDO extension on Windows operating systems, you must add the following line to &php.ini;: Next, choose the other DB specific DLL files and either use dl to load them at runtime, or enable them in &php.ini; below php_pdo.dll. For example: These DLLs should exist in the system's extension_dir. Linux and UNIX Due to a bug in the pear installer you should install the PDO package manually using the following steps: Follow the same steps to install and enable the PDO drivers of your choice. Download the PDO package to your local machine: Determine your PHP bin directory. If your PHP 5 CLI binary lives at /usr/local/php5/bin/php then the bin dir is /usr/local/php5/bin. Set your path so that your PHP bin directory is at the front: Manually build and install the PDO extension: > /usr/local/php5/lib/php.ini ]]>
&reference.pdo.ini;
PDO Drivers The following drivers currently implement the PDO interface: Driver name Supported databases PDO_DBLIB FreeTDS / Microsoft SQL Server / Sybase PDO_FIREBIRD Firebird/Interbase 6 PDO_MYSQL MySQL 3.x/4.x PDO_OCI Oracle Call Interface PDO_ODBC ODBC v3 (IBM DB2, unixODBC and win32 ODBC) PDO_PGSQL PostgreSQL PDO_SQLITE SQLite 3 and SQLite 2
&reftitle.classes;
<classname>PDO</classname> Represents a connection between PHP and a database server.
&reftitle.constructor; PDO - constructs a new PDO object
&reftitle.methods; beginTransaction - begins a transaction commit - commits a transaction exec - issues an SQL statement and returns the number of affected rows errorCode - retrieves an error code, if any, from the database errorInfo - retrieves an array of error information, if any, from the database getAttribute - retrieves a database connection attribute lastInsertId - retrieves the value of the last row that was inserted into a table prepare - prepares an SQL statement for execution query - issues an SQL statement and returns a result set quote - returns a quoted version of a string for use in SQL statements rollBack - roll back a transaction setAttribute - sets a database connection attribute
<classname>PDOStatement</classname> Represents a prepared statement and, after the statement is executed, an associated result set.
&reftitle.methods; bindColumn - binds a PHP variable to an output column in a result set bindParam - binds a PHP variable to a parameter in the prepared statement closeCursor - closes the cursor, allowing the statement to be executed again columnCount - returns the number of columns in the result set errorCode - retrieves an error code, if any, from the statement errorInfo - retrieves an array of error information, if any, from the statement execute - executes a prepared statement fetch - fetches a row from a result set fetchAll - fetches an array containing all of the rows from a result set fetchColumn - returns the data from a single column in a result set getAttribute - retrieves a PDOStatement attribute getColumnMeta - retrieves metadata for a column in the result set nextRowset - retrieves the next rowset (result set) rowCount - returns the number of rows that were affected by the execution of an SQL statement setAttribute - sets a PDOStatement attribute setFetchMode - sets the fetch mode for a PDOStatement
&reference.pdo.constants;
&reference.pdo.functions;