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

Class: MDB2

Source Location: /MDB2-2.0.0RC2/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 261]
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_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_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.

MDB2_Date This class provides several method to convert from and to MDB2 timestamps.



[ Top ]


Method Detail

apiVersion   [line 476]

string apiVersion( )

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

[ Top ]

connect   [line 374]

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 634]

string errorMessage( int $value)

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   $value     error code

[ Top ]

factory   [line 312]

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 843]

boolean 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 551]

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 527]

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 $data 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 ]

isManip   [line 610]

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 ]

isResult   [line 565]

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 579]

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 593]

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 ]

loadFile   [line 453]

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 722]

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:


1 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>

Parameters:

string   $dsn     Data Source Name to be parsed

[ Top ]

raiseError   [line 507]

object a &raiseError( [mixed $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null])

This method is used to communicate an error and invoke error callbacks etc. Basically a wrapper for PEAR::raiseError without the message string.
  • Return: PEAR error object
  • See: PEAR_Error

Parameters:

mixed   $code     integer error code
int   $mode     error mode, see PEAR_Error docs
mixed   $options     If error mode is PEAR_ERROR_TRIGGER, this is the error level (E_USER_NOTICE etc). If error mode is PEAR_ERROR_CALLBACK, this is the callback function, either as a function name, or as an array of an object and method name. For other error modes this parameter is ignored.
string   $userinfo     Extra debug information. Defaults to the last query and native error code.

[ Top ]

setOptions   [line 273]

void setOptions( object &$db, array $options)

set option array in an exiting database object
  • Access: public

Parameters:

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

[ Top ]

singleton   [line 422]

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

Returns a MDB2 connection with the requested DSN.

A newnew MDB2 connection object is only created if no object with the reuested 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 Wed, 28 Dec 2005 05:31:37 -0500 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.