The main "DB" class is simply a container class with some static methods for creating DB objects as well as some utility functions common to all parts of DB.
The object model of DB is as follows (indentation means inheritance):
DB The main DB class. This is simply a utility class with some "static" methods for creating DB objects as well as common utility functions for other DB classes.
DB_common The base for each DB implementation. Provides default | implementations (in OO lingo virtual methods) for | the actual DB implementations as well as a bunch of | query utility functions. | +-DB_mysql The DB implementation for MySQL. Inherits DB_common. When calling DB::factory or DB::connect for MySQL connections, the object returned is an instance of this class.
Located in /maintenance/libraries/pear/DB.php (line 270)
Return the DB API version
Load a PHP database extension if it is not loaded already.
Create a new DB object and connect to the specified database.
Example 1.
- <?php
- require_once 'DB.php';
- $dsn = 'mysql://user:password@host/database'
- $options = array(
- 'debug' => 2,
- 'portability' => DB_PORTABILITY_ALL,
- );
- $dbh =& DB::connect($dsn, $options);
- if (DB::isError($dbh)) {
- die($dbh->getMessage());
- }
- ?>
Return a textual error message for a DB error code
Create a new DB object for the specified database type.
Allows creation of a DB_<driver> object from which the object's methods can be utilized without actually connecting to a database.
Tell whether a value is a DB connection
Tell whether a result code from a DB method is an error
Tell whether a query is a data manipulation query (insert, update or delete) or a data definition query (create, drop, alter, grant, revoke).
Parse a data source name.
Additional keys can be added by appending a URI query string to the end of the DSN.
The format of the supplied DSN is in its fullest form:
- phptype(dbsyntax):
Most variations are allowed:
- phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644
- phptype://username:password@hostspec/database_name
- phptype://username:password@hostspec
- phptype://username@hostspec
- phptype://hostspec/database
- phptype://hostspec
- phptype(dbsyntax)
- phptype
Documentation generated on Fri, 10 Dec 2004 18:25:13 +0000 by phpDocumentor 1.3.0RC3