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

Class: MDB2

Source Location: /MDB2-2.0.0alpha1/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 170]
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_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_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_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 386]

string apiVersion( )

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

[ Top ]

connect   [line 257]

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: $mdb =& MDB2::connect($dsn); ^^ And not: $mdb = 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 467]

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

mixed &factory( string $type, [mixed $debug = false])

Create a new MDB2 object for the specified database type type
  • Return: a newly created MDB2 object, or false on error
  • Access: public

Parameters:

string   $type     database type, for example 'mysql'

[ Top ]

isConnection   [line 415]

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

boolean isError( integer $value)

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

Parameters:

integer   $value     result code

[ Top ]

isManip   [line 446]

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

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 ]

loadFile   [line 372]

$module loadFile( string $file)

load a file (like 'Date')
  • Return: name of the file to be included from the MDB2 modules dir
  • Access: public

Parameters:

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

[ Top ]

parseDSN   [line 551]

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 ]

setOptions   [line 182]

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

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: $mdb =& MDB2::singleton($dsn); ^^ And not: $mdb = 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 Sat, 1 May 2004 01:37:06 +0200 by phpDocumentor 1.2.3. PEAR Logo Copyright © PHP Group 2004.