DB
[ class tree: DB ] [ index: DB ] [ all elements ]

Class: DB

Source Location: /DB-1.4.0/DB.php

Class Overview


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.


Author(s):

Methods


Inherited Variables

Inherited Methods


Class Details

[line 210]
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.



[ Top ]


Method Detail

apiVersion   [line 318]

int apiVersion( )

Return the DB API version
  • Return: the DB API version number
  • Access: public

[ Top ]

assertExtension   [line 600]

boolean assertExtension( string $name)

Load a PHP database extension if it is not loaded already.
  • Return: true if the extension was already or successfully loaded, false if it could not be loaded
  • Access: public

Parameters:

string   $name     the base name of the extension (without the .so or .dll suffix)

[ Top ]

connect   [line 264]

mixed &connect( mixed $dsn, [mixed $options = false])

Create a new DB connection object and connect to the specified database
  • Return: a newly created DB connection object, or a DB error object on error
  • See: DB_common::setOption
  • See: DB::isError
  • See: DB::parseDSN

Parameters:

mixed   $dsn     "data source name", see the DB::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by DB::parseDSN.
mixed   $options     An associative array of option names and their values. For backwards compatibility, this parameter may also be a boolean that tells whether the connection should be persistent. See DB_common::setOption for more information on connection options.

[ Top ]

errorMessage   [line 392]

string errorMessage( integer $value)

Return a textual error message for a DB error code
  • Return: error message, or false if the error code was not recognized

Parameters:

integer   $value     error code

[ Top ]

factory   [line 225]

mixed &factory( string $type)

Create a new DB connection object for the specified database type
  • Return:

    a newly created DB object, or a DB error code on error

    access public


Parameters:

string   $type     database type, for example "mysql"

[ Top ]

isConnection   [line 352]

bool isConnection( mixed $value)

Tell whether a value is a DB connection
  • Return: whether $value is a DB connection
  • Access: public

Parameters:

mixed   $value     value to test

[ Top ]

isError   [line 334]

bool isError( int $value)

Tell whether a result code from a DB method is an error
  • Return: whether $value is an error
  • Access: public

Parameters:

int   $value     result code

[ Top ]

isManip   [line 372]

boolean isManip( string $query)

Tell whether a query is a data manipulation query (insert, update or delete) or a data definition query (create, drop, alter, grant, revoke).
  • Return: whether $query is a data manipulation query
  • Access: public

Parameters:

string   $query     the query

[ Top ]

parseDSN   [line 472]

array parseDSN( string $dsn)

Parse a data source name

A array with the following keys will be returned: phptype: Database backend used in PHP (mysql, odbc etc.) dbsyntax: Database used with regards to SQL syntax etc. protocol: Communication protocol to use (tcp, unix etc.) hostspec: Host specification (hostname[:port]) database: Database to use on the DBMS server username: User name for login password: Password for login

The format of the supplied DSN is in its fullest form:

phptype(dbsyntax)://username:password@protocol+hostspec/database

Most variations are allowed:

phptype://username:password@protocol+hostspec:110//usr/db_file.db phptype://username:password@hostspec/database_name phptype://username:password@hostspec phptype://username@hostspec phptype://hostspec/database phptype://hostspec phptype(dbsyntax) phptype


Parameters:

string   $dsn     Data Source Name to be parsed

[ Top ]


Documentation generated on Fri, 30 Apr 2004 23:19:44 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.