警告 |
本扩展模块是实验性的。本模块的行为,包括其函数的名称以及其它任何关于此模块的文档可能会在没有通知的情况下随 PHP 以后的发布而改变。使用本扩展模块风险自担。 |
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 pdo_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 DLL's should exist in the systems 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.2.tgz bash$ cd PDO-0.2 bash$ phpize bash$ ./configure bash$ make bash$ sudo -s bash# make install bash# echo extension=pdo.so >> /usr/local/php5/lib/php.ini |
The following drivers currently implement the PDO interface:
Represents a connection between PHP and a database server.
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
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
fetchSingle - returns the data from the first 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
以下常量由本扩展模块定义,因此只有在本扩展模块被编译到 PHP 中,或者在运行时被动态加载后才有效。
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.
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.
Force column names to a specific case specified by the PDO_CASE_* constants.
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.