Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /home/cch/www/pear/DB.php
PEAR Repository -

DB

DB

The main "DB" class is simply a container class with some static

 

private class DB

The main "DB" 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):

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

DB_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.
|
+-DB_mysql The DB implementation for MySQL. Inherits DB_common.
When calling DB::factory or DB::connect for MySQL
connections, the object returned is an instance of this
class.

AuthorsStig Bakken <ssb@fast.no>
SincePHP 4.0
Version2

 

Public Method Summary

void

DB_Error([ string $code, string $mode ], string $level, string $debuginfo)

DB_Error constructor.
void

DB_Warning([ string $code, string $mode ], string $level, string $debuginfo)

DB_Warning constructor.

Private Method Summary

object [unknown]

&factory(string $type)

Create a new DB object for the specified database type
object [unknown]

&connect(string $dsn, [ boolean $persistent ])

Create a new DB object and connect to the specified database
int

apiVersion()

Return the DB API version
bool

isError(int $value)

Tell whether a result code from a DB method is an error
bool

isWarning(mixed $value)

Tell whether a result code from a DB method is a warning.
string

errorMessage(int $value)

Return a textual error message for a DB error code
array

parseDSN(string $dsn)

Parse a data source name
void

DB_result(object [unknown] &$dbh, $result)

DB_result constructor.
array

fetchRow(string $fetchmode)

Fetch and return a row of data.
int

fetchInto( &$arr, string $fetchmode)

Fetch a row of data into an existing array.
int

numCols()

Get the the number of columns in a result set.
int

free()

Frees the resources allocated for this result set.

Private Field Summary

unknown

$dbh

unknown

$result

Private Constant Summary

DB_FETCHMODE_DEFAULT >>0<< This is a special constant that tells DB the user hasn't specified
any particular get mode, so the default should be used.
DB_FETCHMODE_ORDERED >>1<< Column data indexed by numbers, ordered from 0 and up
DB_FETCHMODE_ASSOC >>2<< Column data indexed by column names
DB_FETCHMODE_FLIPPED >>4<< For multi-dimensional results: normally the first level of arrays
is the row number, and the second level indexed by column number or name.
DB_FETCHMODE_FLIPPED switches this order, so the first level of arrays
is the column name, and the second level the row number.
DB_OK >>0<<
DB_ERROR >>-1<<
DB_ERROR_SYNTAX >>-2<<
DB_ERROR_CONSTRAINT >>-3<<
DB_ERROR_NOT_FOUND >>-4<<
DB_ERROR_ALREADY_EXISTS >>-5<<
DB_ERROR_UNSUPPORTED >>-6<<
DB_ERROR_MISMATCH >>-7<<
DB_ERROR_INVALID >>-8<<
DB_ERROR_NOT_CAPABLE >>-9<<
DB_ERROR_TRUNCATED >>-10<<
DB_ERROR_INVALID_NUMBER >>-11<<
DB_ERROR_INVALID_DATE >>-12<<
DB_ERROR_DIVZERO >>-13<<
DB_ERROR_NODBSELECTED >>-14<<
DB_ERROR_CANNOT_CREATE >>-15<<
DB_ERROR_CANNOT_DELETE >>-16<<
DB_ERROR_CANNOT_DROP >>-17<<
DB_ERROR_NOSUCHTABLE >>-18<<
DB_ERROR_NOSUCHFIELD >>-19<<
DB_ERROR_NEED_MORE_DATA >>-20<<
DB_ERROR_NOT_LOCKED >>-21<<
DB_ERROR_VALUE_COUNT_ON_ROW >>-22<<
DB_WARNING >>-1000<<
DB_WARNING_READ_ONLY >>-1001<<
DB_PARAM_SCALAR >>1<<
DB_PARAM_OPAQUE >>2<<
DB_BINMODE_PASSTHRU >>1<<
DB_BINMODE_RETURN >>2<<
DB_BINMODE_CONVERT >>3<<
DB_GETMODE_ORDERED >>DB_FETCHMODE_ORDERED<<
DB_GETMODE_ASSOC >>DB_FETCHMODE_ASSOC<<
DB_GETMODE_FLIPPED >>DB_FETCHMODE_FLIPPED<<

Included files Summary, Type: include_once

DB/$.php

Public Method Details

DB_Error

public void DB_Error( [ string $code, string $mode ], string $level, string $debuginfo )

  DB_Error constructor.

Parameter
string $code = >>DB_ERROR,<<
DB error code, or string with error message.
string $mode = >>PEAR_ERROR_RETURN,<<
what "error mode" to operate in
string $level
string $debuginfo
Returns void

See Also P::P

DB_Warning

public void DB_Warning( [ string $code, string $mode ], string $level, string $debuginfo )

  DB_Warning constructor.

Parameter
string $code = >>DB_WARNING,<<
DB error code, or string with error message.
string $mode = >>PEAR_ERROR_RETURN,<<
what "error mode" to operate in
string $level
string $debuginfo
Returns void

See Also P::P

Private Method Details

&factory

private object [unknown] &factory( string $type )

  Create a new DB object for the specified database type

Parameter
string $type
database type, for example "mysql"
Returns object [unknown]

a newly created DB object, or a DB error code on
error


&connect

private object [unknown] &connect( string $dsn, [ boolean $persistent ] )

  Create a new DB object and connect to the specified database

Parameter
string $dsn
"data source name", see the DB::parseDSN
method for a description of the dsn format.
boolean $persistent = >>false<<
whether this connection should be
persistent. Ignored if the backend extension does not support
persistent connections.
Returns object [unknown]

a newly created DB object, or a DB error code on
error


apiVersion

private int apiVersion( )

  Return the DB API version

Returns int

the DB API version number


isError

private bool isError( int $value )

  Tell whether a result code from a DB method is an error

Parameter
int $value
result code
Returns bool

whether $value is an error


isWarning

private bool isWarning( mixed $value )

  Tell whether a result code from a DB method is a warning.
Warnings differ from errors in that they are generated by DB,
and are not fatal.

Parameter
mixed $value
result value
Returns bool

whether $value is a warning


errorMessage

private string errorMessage( int $value )

  Return a textual error message for a DB error code

Parameter
int $value
error code
Returns string

error message, or false if the error code was
not recognized


parseDSN

private array parseDSN( string $dsn )

  Parse a data source name

Parameter
string $dsn
Data Source Name to be parsed
Returns array

an associative array with the following keys:
<dl>
<dt>phptype</dt>
<dd>Database backend used in PHP (mysql, odbc etc.)</dd>
<dt>dbsyntax</dt>
<dd>Database used with regards to SQL syntax etc.</dd>
<dt>protocol</dt>
<dd>Communication protocol to use (tcp, unix etc.)</dd>
<dt>hostspec</dt>
<dd>Host specification (hostname[:port])</dd>
<dt>database</dt>
<dd>Database to use on the DBMS server</dd>
<dt>username</dt>
<dd>User name for login</dd>
<dt>password</dt>
<dd>Password for login</dd>
</dl>
</p>

<p>
The format of the supplied DSN is in its fullest form:
<ul>
<li>phptype(dbsyntax)://username:password@protocol+hostspec/database</li>
</ul>
Most variations are allowed:
<ul>
<li>phptype://username:password@protocol+hostspec/database</li>
<li>phptype://username:password@hostspec/database</li>
<li>phptype://username:password@hostspec</li>
<li>phptype://hostspec/database</li>
<li>phptype://hostspec</li>
<li>phptype(dbsyntax)</li>
<li>phptype</li>
</ul>
</p>


DB_result

private void DB_result( object [unknown] &$dbh, $result )

  DB_result constructor.

Parameter
object [unknown] &$dbh
reference
$result
Returns void


fetchRow

private array fetchRow( string $fetchmode )

  Fetch and return a row of data.

Parameter
string $fetchmode
Returns array

a row of data, or false on error


fetchInto

private int fetchInto( &$arr, string $fetchmode )

  Fetch a row of data into an existing array.

Parameter
&$arr
string $fetchmode
Returns int

error code


numCols

private int numCols( )

  Get the the number of columns in a result set.

Returns int

the number of columns, or a DB error code


free

private int free( )

  Frees the resources allocated for this result set.

Returns int

error code


Private Field Details

$dbh

private unknown $dbh

>>unknown<<


$result

private unknown $result

>>unknown<<


Private Constant Details

DB_FETCHMODE_DEFAULT

define( DB_FETCHMODE_DEFAULT, >>0<< )
Case: default: case sensitive

DB_FETCHMODE_ORDERED

define( DB_FETCHMODE_ORDERED, >>1<< )
Case: default: case sensitive

DB_FETCHMODE_ASSOC

define( DB_FETCHMODE_ASSOC, >>2<< )
Case: default: case sensitive

DB_FETCHMODE_FLIPPED

define( DB_FETCHMODE_FLIPPED, >>4<< )
Case: default: case sensitive

DB_OK

define( DB_OK, >>0<< )
Case: default: case sensitive

DB_ERROR

define( DB_ERROR, >>-1<< )
Case: default: case sensitive

DB_ERROR_SYNTAX

define( DB_ERROR_SYNTAX, >>-2<< )
Case: default: case sensitive

DB_ERROR_CONSTRAINT

define( DB_ERROR_CONSTRAINT, >>-3<< )
Case: default: case sensitive

DB_ERROR_NOT_FOUND

define( DB_ERROR_NOT_FOUND, >>-4<< )
Case: default: case sensitive

DB_ERROR_ALREADY_EXISTS

define( DB_ERROR_ALREADY_EXISTS, >>-5<< )
Case: default: case sensitive

DB_ERROR_UNSUPPORTED

define( DB_ERROR_UNSUPPORTED, >>-6<< )
Case: default: case sensitive

DB_ERROR_MISMATCH

define( DB_ERROR_MISMATCH, >>-7<< )
Case: default: case sensitive

DB_ERROR_INVALID

define( DB_ERROR_INVALID, >>-8<< )
Case: default: case sensitive

DB_ERROR_NOT_CAPABLE

define( DB_ERROR_NOT_CAPABLE, >>-9<< )
Case: default: case sensitive

DB_ERROR_TRUNCATED

define( DB_ERROR_TRUNCATED, >>-10<< )
Case: default: case sensitive

DB_ERROR_INVALID_NUMBER

define( DB_ERROR_INVALID_NUMBER, >>-11<< )
Case: default: case sensitive

DB_ERROR_INVALID_DATE

define( DB_ERROR_INVALID_DATE, >>-12<< )
Case: default: case sensitive

DB_ERROR_DIVZERO

define( DB_ERROR_DIVZERO, >>-13<< )
Case: default: case sensitive

DB_ERROR_NODBSELECTED

define( DB_ERROR_NODBSELECTED, >>-14<< )
Case: default: case sensitive

DB_ERROR_CANNOT_CREATE

define( DB_ERROR_CANNOT_CREATE, >>-15<< )
Case: default: case sensitive

DB_ERROR_CANNOT_DELETE

define( DB_ERROR_CANNOT_DELETE, >>-16<< )
Case: default: case sensitive

DB_ERROR_CANNOT_DROP

define( DB_ERROR_CANNOT_DROP, >>-17<< )
Case: default: case sensitive

DB_ERROR_NOSUCHTABLE

define( DB_ERROR_NOSUCHTABLE, >>-18<< )
Case: default: case sensitive

DB_ERROR_NOSUCHFIELD

define( DB_ERROR_NOSUCHFIELD, >>-19<< )
Case: default: case sensitive

DB_ERROR_NEED_MORE_DATA

define( DB_ERROR_NEED_MORE_DATA, >>-20<< )
Case: default: case sensitive

DB_ERROR_NOT_LOCKED

define( DB_ERROR_NOT_LOCKED, >>-21<< )
Case: default: case sensitive

DB_ERROR_VALUE_COUNT_ON_ROW

define( DB_ERROR_VALUE_COUNT_ON_ROW, >>-22<< )
Case: default: case sensitive

DB_WARNING

define( DB_WARNING, >>-1000<< )
Case: default: case sensitive

DB_WARNING_READ_ONLY

define( DB_WARNING_READ_ONLY, >>-1001<< )
Case: default: case sensitive

DB_PARAM_SCALAR

define( DB_PARAM_SCALAR, >>1<< )
Case: default: case sensitive

DB_PARAM_OPAQUE

define( DB_PARAM_OPAQUE, >>2<< )
Case: default: case sensitive

DB_BINMODE_PASSTHRU

define( DB_BINMODE_PASSTHRU, >>1<< )
Case: default: case sensitive

DB_BINMODE_RETURN

define( DB_BINMODE_RETURN, >>2<< )
Case: default: case sensitive

DB_BINMODE_CONVERT

define( DB_BINMODE_CONVERT, >>3<< )
Case: default: case sensitive

DB_GETMODE_ORDERED

define( DB_GETMODE_ORDERED, >>DB_FETCHMODE_ORDERED<< )
Case: default: case sensitive

DB_GETMODE_ASSOC

define( DB_GETMODE_ASSOC, >>DB_FETCHMODE_ASSOC<< )
Case: default: case sensitive

DB_GETMODE_FLIPPED

define( DB_GETMODE_FLIPPED, >>DB_FETCHMODE_FLIPPED<< )
Case: default: case sensitive

Included Files, Type: include_once

DB/$.php

include_once( DB/$.php )


Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta