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

Class: MDB2

Source Location: /MDB2-2.0.0beta2/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 236]
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 456]

string apiVersion( )

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

[ Top ]

connect   [line 323]

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

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

mixed &factory( string $type, [ $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'
   $debug   — 

[ Top ]

isConnection   [line 485]

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

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

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

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

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 ]

loadFile   [line 442]

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

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>

Parameters:

string   $dsn   —  Data Source Name to be parsed

[ Top ]

setOptions   [line 248]

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

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.
   &$db   — 

[ Top ]

singleton   [line 395]

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