|
Warning |
This extension is EXPERIMENTAL. The behaviour of this extension -- including the names of its functions and anything else documented about this extension -- may change without notice in a future release of PHP. Use this extension at your own risk. |
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 http://www.php.net/downloads.php 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:
extension=php_pdo.dll |
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:
extension=php_pdo.dll extension=php_pdo_firebird.dll extension=php_pdo_mssql.dll extension=php_pdo_mysql.dll extension=php_pdo_oci.dll extension=php_pdo_oci8.dll extension=php_pdo_odbc.dll extension=php_pdo_pgsql.dll extension=php_pdo_sqlite.dll |
These DLLs should exist in the system's extension_dir.
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:
bash$ wget http://pecl.php.net/get/PDO |
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:
export PATH="/usr/local/php5/bin:$PATH" |
Manually build and install the PDO extension:
bash$ tar xzf PDO-0.9.tgz bash$ cd PDO-0.9 bash$ phpize bash$ ./configure bash$ make bash$ sudo -s bash# make install bash# echo extension=pdo.so >> /usr/local/php5/lib/php.ini |
The behaviour of these functions is affected by settings in php.ini.
Table 1. PDO Configuration Options
Name | Default | Changeable | Changelog |
---|---|---|---|
pdo.dsn.* | php.ini only | ||
pdo_odbc.connection_pooling | "strict" | PHP_INI_ALL |
Here's a short explanation of the configuration directives.
Defines DSN alias. See PDO::__construct for thorough explanation.
Whether to pool ODBC connections. Can be one of "strict", "relaxed" or "off" (equals to "").
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 |
Represents a connection between PHP and a database server.
PDO - constructs a new PDO object
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
Represents a prepared statement and, after the statement is executed, an associated result set.
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
The constants below are defined by this extension, and will only be available when the extension has either been compiled into PHP or dynamically loaded at runtime.
Represents the SQL NULL data type.
Represents the SQL INTEGER data type.
Represents the SQL CHAR, VARCHAR, or other string data type.
Represents the SQL large object data type.
Specifies that the parameter is an INOUT parameter for a stored procedure. You must bitwise-OR this value with an explicit PDO_PARAM_* data type.
Specifies that the fetch method shall return each row as an object with variable names that correspond to the column names returned in the result set. PDO_FETCH_LAZY creates the object variable names as they are accessed.
Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO_FETCH_ASSOC returns only a single value per column name.
Specifies that the fetch method shall return each row as an array indexed by column name as returned in the corresponding result set. If the result set contains multiple columns with the same name, PDO_FETCH_NAMED returns an array of values per column name.
Specifies that the fetch method shall return each row as an array indexed by column number as returned in the corresponding result set, starting at column 0.
Specifies that the fetch method shall return each row as an array indexed by both column name and number as returned in the corresponding result set, starting at column 0.
Specifies that the fetch method shall return each row as an object with property names that correspond to the column names returned in the result set.
Specifies that the fetch method shall return TRUE and assign the values of the columns in the result set to the PHP variables to which they were bound with the PDOStatement::bindParam() or PDOStatement::bindColumn() methods.
Specifies that the fetch method shall return only a single requested column from the next row in the result set.
Specifies that the fetch method shall return a new instance of the requested class, mapping the columns to named properties in the class.
Specifies that the fetch method shall update an existing instance of the requested class, mapping the columns to named properties in the class.
If this value is FALSE, PDO attempts to disable autocommit so that the connection begins a transaction.
Setting the prefetch size allows you to balance speed against memory usage for your application. Not all database/driver combinations support setting of the prefetch size.
Sets the timeout value in seconds for communications with the database.
Force column names to a specific case specified by the PDO_CASE_* constants.
Returns the name of the driver.
Convert empty strings to SQL NULL values.
Request a persistent connection, rather than creating a new connection.
Prepend the containing catalog name to each column name returned in the result set. The catalog name and column name are separated by a decimal (.) character.
Prepend the containing table name to each column name returned in the result set. The table name and column name are separated by a decimal (.) character.
Do not raise an error or exception if an error occurs. The developer is expected to explicitly check for errors. This is the default mode.
Issue a PHP E_WARNING message if an error occurs.
Throw a PDOException if an error occurs.
Leave column names as returned by the database driver.
Force column names to lower case.
Force column names to upper case.
Fetch the next row in the result set. Valid only for scrollable cursors.
Fetch the previous row in the result set. Valid only for scrollable cursors.
Fetch the first row in the result set. Valid only for scrollable cursors.
Fetch the last row in the result set. Valid only for scrollable cursors.
Fetch the requested row by row number from the result set. Valid only for scrollable cursors.
Fetch the requested row by relative position from the current position of the cursor in the result set. Valid only for scrollable cursors.
Create a PDOStatement object with a forward-only cursor. This may improve the performance of your application but restricts your PDOStatement object to fetching one row at a time from the result set in a forward direction.
Create a PDOStatement object with a scrollable cursor. Pass the PDO_FETCH_ORI_* constants to control the rows fetched from the result set.
Corresponds to SQLSTATE '00000', meaning that the SQL statement was successfully issued with no errors or warnings.
Hosting by: Hurra Communications Ltd.
Generated: 2007-01-26 18:00:15