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

Class: MDB2

Source Location: /MDB2-2.1.0/MDB2.php

Class Overview


The main 'MDB2' 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 272]
The main 'MDB2' 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 MDB2 is as follows (indentation means inheritance):

MDB2 The main MDB2 class. This is simply a utility class with some 'static' methods for creating MDB2 objects as well as common utility functions for other MDB2 classes.

MDB2_Driver_Common The base for each MDB2 implementation. Provides default | implementations (in OO lingo virtual methods) for | the actual DB implementations as well as a bunch of | query utility functions. | +-MDB2_Driver_mysql The MDB2 implementation for MySQL. Inherits MDB2_Driver_Common. When calling MDB2::factory or MDB2::connect for MySQL connections, the object returned is an instance of this class. +-MDB2_Driver_pgsql The MDB2 implementation for PostGreSQL. Inherits MDB2_Driver_Common. When calling MDB2::factory or MDB2::connect for PostGreSQL connections, the object returned is an instance of this class.



[ Top ]


Method Detail

apiVersion   [line 543]

string apiVersion( )

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

[ Top ]

classExists   [line 310]

bool classExists( string $classname)

Checks if a class exists without triggering __autoload
  • Return: true success and false on error
  • Access: public

Parameters:

string   $classname     classname

[ Top ]

connect   [line 436]

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

Create a new MDB2 connection object and connect to the specified database

IMPORTANT: In order for MDB2 to work properly it is necessary that you make sure that you work with a reference of the original object instead of a copy (this is a PHP4 quirk).

For example: $db =& MDB2::connect($dsn); ^^ And not: $db = MDB2::connect($dsn); ^^

  • Return: a newly created MDB2 connection object, or a MDB2 error object on error
  • See: MDB2::parseDSN
  • Access: public

Parameters:

mixed   $dsn     'data source name', see the MDB2::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by MDB2::parseDSN.
array   $options     An associative array of option names and their values.

[ Top ]

errorMessage   [line 693]

string errorMessage( [int|array $value = null])

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

Parameters:

int|array   $value     integer error code,

[ Top ]

factory   [line 379]

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

Create a new MDB2 object for the specified database type

IMPORTANT: In order for MDB2 to work properly it is necessary that you make sure that you work with a reference of the original object instead of a copy (this is a PHP4 quirk).

For example: $db =& MDB2::factory($dsn); ^^ And not: $db = MDB2::factory($dsn);

  • Return: a newly created MDB2 object, or false on error
  • Access: public

Parameters:

mixed   $dsn     'data source name', see the MDB2::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by MDB2::parseDSN.
array   $options     An associative array of option names and their values.

[ Top ]

fileExists   [line 913]

bool fileExists( string $file)

Checks if a file exists in the include path
  • Return: true success and false on error
  • Access: public

Parameters:

string   $file     filename

[ Top ]

isConnection   [line 625]

bool isConnection( mixed $value)

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

Parameters:

mixed   $value     value to test

[ Top ]

isError   [line 599]

bool isError( mixed $data, [int $code = null])

Tell whether a value is a MDB2 error.
  • Return: true if parameter is an error
  • Access: public

Parameters:

mixed   $data     the value to test
int   $code     if is an error object, return true only if $code is a string and $db->getMessage() == $code or $code is an integer and $db->getCode() == $code

[ Top ]

isResult   [line 641]

bool isResult( mixed $value)

Tell whether a value is a MDB2 result
  • Return: whether $value is a MDB2 result
  • Access: public

Parameters:

mixed   $value     value to test

[ Top ]

isResultCommon   [line 657]

bool isResultCommon( mixed $value)

Tell whether a value is a MDB2 result implementing the common interface
  • Return: whether $value is a MDB2 result implementing the common interface
  • Access: public

Parameters:

mixed   $value     value to test

[ Top ]

isStatement   [line 673]

bool isStatement( mixed $value)

Tell whether a value is a MDB2 statement interface
  • Return: whether $value is a MDB2 statement interface
  • Access: public

Parameters:

mixed   $value     value to test

[ Top ]

loadClass   [line 330]

bool loadClass( string $class_name, bool $debug)

Loads a PEAR class.
  • Return: true success or false on failure
  • Access: public

Parameters:

string   $class_name     classname to load
bool   $debug     if errors should be suppressed

[ Top ]

loadFile   [line 519]

string loadFile( string $file)

load a file (like 'Date')
  • Return: name of the file that was included
  • Access: public

Parameters:

string   $file     name of the file in the MDB2 directory (without '.php')

[ Top ]

parseDSN   [line 792]

array parseDSN( string $dsn)

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:


0 phptype(dbsyntax):

Most variations are allowed:


1 phptype://username:password@protocol+hostspec:110//usr/db_file.db?mode=0644
2 phptype://username:password@hostspec/database_name
3 phptype://username:password@hostspec
4 phptype://username@hostspec
5 phptype://hostspec/database
6 phptype://hostspec
7 phptype(dbsyntax)
8 phptype

  • Return: an associative array with the following keys:
    • 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
  • Author: Tomas V.V.Cox <mailto:cox@idecnet.com>
  • Access: public

Parameters:

string   $dsn     Data Source Name to be parsed

[ Top ]

setOptions   [line 286]

mixed setOptions( MDB2_Driver_Common &$db, array $options)

set option array in an exiting database object
  • Return: MDB2_OK or a PEAR Error object
  • Access: public

Parameters:

MDB2_Driver_Common   &$db     MDB2 object
array   $options     An associative array of option names and their values.

[ Top ]

singleton   [line 486]

mixed &singleton( [mixed $dsn = null], [array $options = false])

Returns a MDB2 connection with the requested DSN.

A new MDB2 connection object is only created if no object with the requested DSN exists yet.

IMPORTANT: In order for MDB2 to work properly it is necessary that you make sure that you work with a reference of the original object instead of a copy (this is a PHP4 quirk).

For example: $db =& MDB2::singleton($dsn); ^^ And not: $db = MDB2::singleton($dsn); ^^

  • Return: a newly created MDB2 connection object, or a MDB2 error object on error
  • See: MDB2::parseDSN
  • Access: public

Parameters:

mixed   $dsn     'data source name', see the MDB2::parseDSN method for a description of the dsn format. Can also be specified as an array of the format returned by MDB2::parseDSN.
array   $options     An associative array of option names and their values.

[ Top ]


Documentation generated on Thu, 15 Jun 2006 09:06:49 -0400 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.