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

Class: MDB2

Source Location: /MDB2-2.5.0b5/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 268]
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 537]

string apiVersion( )

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

[ Top ]

areEquals   [line 488]

boolean areEquals( array $arr1, array $arr2)

It looks like there's a memory leak in array_diff() in PHP 5.1.x, so use this method instead.

Parameters:

array   $arr1   — 
array   $arr2   — 

[ Top ]

classExists   [line 307]

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

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

Create a new MDB2_Driver_* connection object and connect to the specified database
  • 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 694]

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

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

Create a new MDB2 object for the specified database type
  • 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 927]

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

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

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

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

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

mixed loadClass( string $class_name, bool $debug)

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

Parameters:

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

[ Top ]

loadFile   [line 513]

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

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)://username:password@protocol+hostspec/database?option=8&another=true

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 <cox@idecnet.com>
  • Access: public

Parameters:

string   $dsn   —  Data Source Name to be parsed

[ Top ]

raiseError   [line 569]

PEAR_Error &raiseError( [mixed $code = null], [int $mode = null], [mixed $options = null], [string $userinfo = null], [ $dummy1 = null], [ $dummy2 = null], [ $dummy3 = false])

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

Parameters:

mixed   $code   —  int 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.
   $dummy1   — 
   $dummy2   — 
   $dummy3   — 

[ Top ]

setOptions   [line 282]

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

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.

  • 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 Mon, 11 Mar 2019 15:51:34 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.