Packageindex Classtrees Modulegroups Elementlist Report XML Files

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

DB_common

DB_common

DB_common is a base class for DB implementations, and should be
inherited by all such.

 

private class DB_common

DB_common is a base class for DB implementations, and should be
inherited by all such.

 
Direct known subclasses: DB_ibase, DB_msql, DB_mssql, DB_mysql, DB_oci8, DB_odbc, DB_pgsql, DB_sybase

Public Method Summary

void

&getOne(array $query, array $params)

Fetch the first column of the first row of data returned from
array

&getRow( $query, string $fetchmode, array $params)

Fetch the first row of data returned from a query. Takes care
array

&getCol(integer $query, integer $col, array $params)

Fetch a single column from a result set and return it as an
array

&getAssoc(array $query, boolean $force_array, array $params)

Fetch the entire result set of a query and return it as an
array

&getAll( $query, string $fetchmode, array $params)

Fetch all the rows returned from a query.
void

DB_common()

Private Method Summary

string

quoteString(string $string)

Quotes a string so it can be safely used within string delimiters
bool

provides( $feature)

Tell whether a DB implementation or its backend extension
int

errorCode(string $nativecode)

Map native error codes to DB's portable ones. Requires that
string

errorMessage( $dbcode)

Map a DB error code to a textual message. This is actually
void

&raiseError(string $code, boolean $mode, boolean $level, boolean $debuginfo, boolean $nativecode)

This method is called by DB to generate an error.
void

setErrorHandling(int $mode, [ boolean $options ])

Sets how errors generated by this DB object should be handled.
void

setFetchMode(int $fetchmode)

Sets which fetch mode should be used by default on queries
void

prepare( $query)

Prepares a query for multiple execution with execute(). With
PostgreSQL, this is emulated.
string

execute_emulate_query( $stmt, boolean $data)

void

executeMultiple( $stmt, &$data)

This function does several execute() calls on the same
statement handle. $data must be an array indexed numerically
from 0, one execute call is done for every "row" in the array.

If an error occurs during execute(), executeMultiple() does not
execute the unfinished rows, but rather returns that error.
void

toString()

Private Field Summary

unknown

$features

unknown

$errorcode_map

unknown

$type

unknown

$prepare_tokens

unknown

$prepare_types

unknown

$prepare_maxstmt

string

$error_mode

string

$error_level

unknown

$error_callback

string

$last_query

string

$fetchmode

Public Method Details

&getOne

public void &getOne( array $query, array $params )

  Fetch the first column of the first row of data returned from
a query. Takes care of doing the query and freeing the results
when finished.

Parameter
array $query
as execute parameters
array $params
Returns void


&getRow

public array &getRow( $query, string $fetchmode, array $params )

  Fetch the first row of data returned from a query. Takes care
of doing the query and freeing the results when finished.

Parameter
$query
string $fetchmode
array $params
Returns array

the first row of results as an array indexed from
0, or a DB error code.


&getCol

public array &getCol( integer $query, integer $col, array $params )

  Fetch a single column from a result set and return it as an
indexed array.

Parameter
integer $query
[column number,
starting at 0] or string [column name])
integer $col
array $params
Returns array

an indexed array with the data from the first
row at index 0, or a DB error code.


&getAssoc

public array &getAssoc( array $query, boolean $force_array, array $params )

  Fetch the entire result set of a query and return it as an
associative array using the first column as the key.

Parameter
array $query
(optional) used only when the query returns
exactly two columns. If true, the values of the returned array
will be one-element arrays instead of scalars.
boolean $force_array
array $params
Returns array

associative array with results from the query.
If the result set contains more than two columns, the value
will be an array of the values from column 2-n. If the result
set contains only two columns, the returned value will be a
scalar with the value of the second column (unless forced to an
array with the $force_array parameter). A DB error code is
returned on errors. If the result set contains fewer than two
columns, a DB_ERROR_TRUNCATED error is returned.

For example, if the table "mytable" contains:

ID TEXT DATE
--------------------------------
1 'one' 944679408
2 'two' 944679408
3 'three' 944679408

Then the call getAssoc('SELECT id,text FROM mytable') returns:
array(
'1' => 'one',
'2' => 'two',
'3' => 'three',
)

...while the call getAssoc('SELECT id,text,date FROM mydate') returns:
array(
'1' => array('one', '944679408'),
'2' => array('two', '944679408'),
'3' => array('three', '944679408')
)

Keep in mind that database functions in PHP usually return string
values for results regardless of the database's internal type.


&getAll

public array &getAll( $query, string $fetchmode, array $params )

  Fetch all the rows returned from a query.

Parameter
$query
string $fetchmode
array $params
Returns array

an nested array, or a DB error


DB_common

public void DB_common( )

 

Returns void


Private Method Details

quoteString

private string quoteString( string $string )

  Quotes a string so it can be safely used within string delimiters
in a query.

Parameter
string $string
the input string to quote
Returns string

the quoted string


provides

private bool provides( $feature )

  Tell whether a DB implementation or its backend extension
supports a given feature.

Parameter
$feature
Returns bool

whether this DB implementation supports $feature


errorCode

private int errorCode( string $nativecode )

  Map native error codes to DB's portable ones. Requires that
the DB implementation's constructor fills in the $errorcode_map
property.

Parameter
string $nativecode
or integer)
Returns int

a portable DB error code, or FALSE if this DB
implementation has no mapping for the given error code.


errorMessage

private string errorMessage( $dbcode )

  Map a DB error code to a textual message. This is actually
just a wrapper for DB::errorMessage().

Parameter
$dbcode
Returns string

the corresponding error message, of FALSE
if the error code was unknown


&raiseError

private void &raiseError( string $code, boolean $mode, boolean $level, boolean $debuginfo, boolean $nativecode )

  This method is called by DB to generate an error.

Parameter
string $code
boolean $mode
boolean $level
boolean $debuginfo
boolean $nativecode
Returns void


setErrorHandling

private void setErrorHandling( int $mode, [ boolean $options ] )

  Sets how errors generated by this DB object should be handled.

Parameter
int $mode
one of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
PEAR_ERROR_CALLBACK.
boolean $options = >>false<<
Ignored unless $mode is PEAR_ERROR_TRIGGER or
PEAR_ERROR_CALLBACK. When $mode is PEAR_ERROR_TRIGGER,
this parameter is expected to be an integer among
E_USER_NOTICE, E_USER_WARNING or E_USER_ERROR. When
$mode is PEAR_ERROR_CALLBACK, this parameter is expected
to be the callback function or method. A callback
function is a string with the name of the function, a
callback method is an array of two elements: the element
at index 0 is an object, and the element at index 1 is
the name of the method to call in the object.
Returns void

See Also P::P, P::P, P::P, P::P, P::P

setFetchMode

private void setFetchMode( int $fetchmode )

  Sets which fetch mode should be used by default on queries
on this connection.

Parameter
int $fetchmode
DB_FETCHMODE_ORDERED or
DB_FETCHMODE_ASSOC, possibly bit-wise OR'ed with
DB_FETCHMODE_FLIPPED.
Returns void

See Also D::D, D::D, D::D

prepare

private void prepare( $query )

  Prepares a query for multiple execution with execute(). With
PostgreSQL, this is emulated.

Parameter
$query
Returns void


execute_emulate_query

private string execute_emulate_query( $stmt, boolean $data )

 

Parameter
$stmt
boolean $data
Returns string

containing the real query run when emulating
prepare/execute. A DB error code is returned on failure.


executeMultiple

private void executeMultiple( $stmt, &$data )

  This function does several execute() calls on the same
statement handle. $data must be an array indexed numerically
from 0, one execute call is done for every "row" in the array.

If an error occurs during execute(), executeMultiple() does not
execute the unfinished rows, but rather returns that error.

Parameter
$stmt
&$data
Returns void


toString

private void toString( )

 

Returns void


Private Field Details

$features

private unknown $features

>>unknown<<


$errorcode_map

private unknown $errorcode_map

>>unknown<<


$type

private unknown $type

>>unknown<<


$prepare_tokens

private unknown $prepare_tokens

>>unknown<<


$prepare_types

private unknown $prepare_types

>>unknown<<


$prepare_maxstmt

private unknown $prepare_maxstmt

>>unknown<<


$error_mode

private string $error_mode

>>PEAR_ERROR_RETURN<<


$error_level

private string $error_level

>>E_USER_NOTICE<<


$error_callback

private unknown $error_callback

>>unknown<<


$last_query

private string $last_query

>>''<<


$fetchmode

private string $fetchmode

>>DB_FETCHMODE_DEFAULT<<



Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta