Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: c:/www/apache/doc2//pear/DB/common.php
PEAR 2000/12/03 -

DB_common

DB_common

DB_common is a base class for DB implementations, and should be

 

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()

Warning: documentation is missing.

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, [ mixed $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
string

execute_emulate_query( $stmt, boolean $data)

void

executeMultiple( $stmt, &$data)

This function does several execute() calls on the same
void

toString()

Warning: documentation is missing.

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 resultswhen finished.

Parameter
array $query
execute parameters
array $params
Warning: documentation is missing.
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
Warning: documentation is missing.
string $fetchmode
Warning: documentation is missing.
array $params
Warning: documentation is missing.
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
Warning: documentation is missing.
array $params
Warning: documentation is missing.
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
Warning: documentation is missing.
array $params
Warning: documentation is missing.
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
Warning: documentation is missing.
string $fetchmode
Warning: documentation is missing.
array $params
Warning: documentation is missing.
Returns array

an nested array, or a DB error


DB_common

public void DB_common( )

 

Warning: documentation is missing.

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
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
Warning: documentation is missing.
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_mapproperty.

Parameter
string $nativecode
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
Warning: documentation is missing.
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
Warning: documentation is missing.
boolean $mode
Warning: documentation is missing.
boolean $level
Warning: documentation is missing.
boolean $debuginfo
Warning: documentation is missing.
boolean $nativecode
Warning: documentation is missing.
Returns void


setErrorHandling

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

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

Parameter
int $mode
of PEAR_ERROR_RETURN, PEAR_ERROR_PRINT,
PEAR_ERROR_TRIGGER, PEAR_ERROR_DIE or
PEAR_ERROR_CALLBACK.
mixed $options = >>false<<
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


setFetchMode

private void setFetchMode( int $fetchmode )

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

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


prepare

private void prepare( $query )

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

Parameter
$query
Warning: documentation is missing.
Returns void


execute_emulate_query

private string execute_emulate_query( $stmt, boolean $data )

 

Parameter
$stmt
Warning: documentation is missing.
boolean $data
Warning: documentation is missing.
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 numericallyfrom 0, one execute call is done for every "row" in the array.If an error occurs during execute(), executeMultiple() does notexecute the unfinished rows, but rather returns that error.

Parameter
$stmt
Warning: documentation is missing.
&$data
Warning: documentation is missing.
Returns void


toString

private void toString( )

 

Warning: documentation is missing.

Returns void


Private Field Details

$features

private unknown $features

>><<



$errorcode_map

private unknown $errorcode_map

>><<



$type

private unknown $type

>><<



$prepare_tokens

private unknown $prepare_tokens

>><<



$prepare_types

private unknown $prepare_types

>><<



$prepare_maxstmt

private unknown $prepare_maxstmt

>><<



$error_mode

private string $error_mode

>>PEAR_ERROR_RETURN<<



$error_level

private string $error_level

>>E_USER_NOTICE<<



$error_callback

private unknown $error_callback

>><<



$last_query

private string $last_query

>>''<<



$fetchmode

private string $fetchmode

>>DB_FETCHMODE_DEFAULT<<




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta