[ Index ]
 

Code source de PHP PEAR 1.4.5

Accédez au Source d'autres logiciels libresSoutenez Angelica Josefina !

title

Body

[fermer]

/ -> MDB.php (sommaire)

The method mapErrorCode in each MDB_dbtype implementation maps native error codes to one of these. If you add an error code here, make sure you also add a textual version of it in MDB::errorMessage().

Poids: 733 lignes (27 kb)
Inclus ou requis: 9 fois
Référencé: 0 fois
Nécessite: 1 fichier
 PEAR.php

Définit 2 classes

MDB:: (11 méthodes):
  setOptions()
  factory()
  connect()
  singleton()
  loadFile()
  apiVersion()
  isError()
  isConnection()
  isManip()
  errorMessage()
  parseDSN()

MDB_Error:: (1 méthode):
  MDB_Error()


Classe: MDB  - X-Ref

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

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

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

MDB_Date     This class provides several method to convert from and to
MDB timestamps.

MDB_Manager  This class handles the xml schema management.

setOptions(&$db, $options)   X-Ref
set option array in an exiting database object

param: object  $db       MDB object
param: mixed   $options  An associative array of option names and

factory($type)   X-Ref
Create a new DB connection object for the specified database
type
IMPORTANT: In order for MDB 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 =& MDB::factory($dsn);
^^
And not:
$mdb = MDB::factory($dsn);
^^

param: string  $type   database type, for example 'mysql'
return: mixed   a newly created MDB connection object, or a MDB

connect($dsn, $options = FALSE)   X-Ref
Create a new MDB connection object and connect to the specified
database

IMPORTANT: In order for MDB 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 =& MDB::connect($dsn);
^^
And not:
$mdb = MDB::connect($dsn);
^^

param: mixed   $dsn      'data source name', see the MDB::parseDSN
param: mixed   $options  An associative array of option names and
return: mixed   a newly created MDB connection object, or a MDB

singleton($dsn = NULL, $options = FALSE)   X-Ref
Returns a MDB connection with the requested DSN.
A newnew MDB connection object is only created if no object with the
reuested DSN exists yet.

IMPORTANT: In order for MDB 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 =& MDB::sngleton($dsn);
^^
And not:
$mdb = MDB::singleton($dsn);
^^

param: mixed   $dsn      'data source name', see the MDB::parseDSN
param: mixed   $options  An associative array of option names and
return: mixed   a newly created MDB connection object, or a MDB

loadFile($file)   X-Ref
load a file (like 'Date.php' or 'Manager.php')

return: $file    name of the file to be included from the MDB dir without

apiVersion()   X-Ref
Return the MDB API version

return: int     the MDB API version number

isError($value)   X-Ref
Tell whether a result code from a MDB method is an error

param: int       $value  result code
return: boolean   whether $value is an MDB_Error

isConnection($value)   X-Ref
Tell whether a value is a MDB connection

param: mixed $value value to test
return: bool whether $value is a MDB connection

isManip($query)   X-Ref
Tell whether a query is a data manipulation query (insert,
update or delete) or a data definition query (create, drop,
alter, grant, revoke).

param: string   $query the query
return: boolean  whether $query is a data manipulation query

errorMessage($value)   X-Ref
Return a textual error message for a MDB error code

param: int     $value error code
return: string  error message, or false if the error code was

parseDSN($dsn)   X-Ref
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

author: Tomas V.V.Cox <cox@idecnet.com>
param: string  $dsn Data Source Name to be parsed
return: array   an associative array

Classe: MDB_Error  - X-Ref

MDB_Error implements a class for reporting portable database error
messages.

MDB_Error($code = MDB_ERROR, $mode = PEAR_ERROR_RETURN,$level = E_USER_NOTICE, $debuginfo = NULL)   X-Ref
MDB_Error constructor.

param: mixed   $code      MDB error code, or string with error message.
param: integer $mode      what 'error mode' to operate in
param: integer $level     what error level to use for
param: smixed  $debuginfo additional debug info, such as the last query



Généré le : Sun Feb 25 14:08:00 2007 par Balluche grâce à PHPXref 0.7