From e1bc3422e8a94c6bec99e4fab033be7a2a4c9379 Mon Sep 17 00:00:00 2001 From: Dan Scott Date: Sat, 13 Nov 2004 22:28:28 +0000 Subject: [PATCH] Add more PDO driver and constructor information git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@172620 c90b9560-bf6c-de11-be94-00142212c4b1 --- reference/pdo/functions/PDO-construct.xml | 126 +++++++++++++++++++++- reference/pdo/reference.xml | 48 ++++++++- 2 files changed, 168 insertions(+), 6 deletions(-) diff --git a/reference/pdo/functions/PDO-construct.xml b/reference/pdo/functions/PDO-construct.xml index 1ac1a20e1c..466acd4681 100644 --- a/reference/pdo/functions/PDO-construct.xml +++ b/reference/pdo/functions/PDO-construct.xml @@ -1,5 +1,5 @@ - + PDO::__construct @@ -13,12 +13,132 @@ PDOPDO::__construct stringdsn stringusername - stringpasswd + stringpassword arraydriver_opts + &warn.experimental.func; + + Creates a PDO instance to represent a connection to the requested + database. The dsn parameter supports three + different methods of specifying the arguments required to create + a database connection: + + Driver invocation + + + dsn consists of the PDO driver name, followed + by a colon, followed by the PDO driver-specific connection syntax. + For example, 'odbc:DSN=SAMPLE;UID=db2inst1;PWD=ibmdb2' + would create a PDO_ODBC connection to an ODBC database, while + 'mysql:host=127.0.0.1;dbname=testdb' would create + a PDO_MYSQL connection to a MySQL database. + + + + URI invocation + + + dsn consists of uri: + followed by a URI that defines the location of a file containing + the DSN string. The URI can specify a local file or a remote URL. + + + + Aliasing + + + dsn consists of a name + name that maps to + pdo.dsn.name in &php.ini; + defining the DSN string. name can not contain + a colon. + + + + + If username or password + are not required to complete the connection, you must pass empty strings + or the constructor will throw a PDOException exception. + + Create a PDO instance via driver invocation + +getMessage(); +} +?> +]]> + + + Create a PDO instance via URI invocation + + The following example assumes that the file + /usr/local/dbconnect exists with file permissions + that enable PHP to read the file. The file contains the PDO DSN to + connect to a DB2 database through the PDO_ODBC driver: + + + + + + The PHP script can then create a database connection by simply + passing the uri: parameter and pointing to + the file URI: + + +getMessage(); +} +?> +]]> + + + Create a PDO instance using an alias + + The following example assumes that &php.ini; contains the following + entry to enable a connection to a MySQL database using only the + alias mydb: + pdo.dsn.mydb=mysql:dbname=testdb;host=127.0.0.1 + + +getMessage(); +} +?> +]]> + + diff --git a/reference/pdo/reference.xml b/reference/pdo/reference.xml index 19c84d47d6..3d903eeef7 100644 --- a/reference/pdo/reference.xml +++ b/reference/pdo/reference.xml @@ -1,8 +1,8 @@ - + - pdo Functions + PDO Functions pdo @@ -13,7 +13,10 @@ The 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. + 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.
@@ -57,6 +60,45 @@ extension=pdo.dll
+
+ PDO Drivers + + The following drivers currently implement the PDO interface: + + + + PDO_FIREBIRD - Firebird/Interbase 6 + + + + + PDO_MYSQL - MySQL 3.x/4.0 + + + + + PDO_OCI - Oracle Call Interface + + + + + PDO_ODBC - ODBC v3 (IBM DB2 and unixODBC) + + + + + PDO_PGSQL - PostgreSQL + + + + + PDO_SQLITE - SQLite 3.x + + + + +
+
&reftitle.classes;