Packageindex Classtrees Modulegroups Elementlist Report XML Files

File: /home/inri/public_html/daCode-HEAD/daCode/src/phplib/dbpgsql.php3
daCode - PostgreSQL

Db

Db

Abstraction layer for databases.

 

private class Db

Abstraction layer for databases.
Responsibility: all access to DB

daCode http://daCode.org
src/phplib/dbpgsql.php3
$Id: dbpgsql.php3,v 1.26 2002/05/11 14:23:44 jbcombes Exp $

Depends: Config

AuthorsRolland Dudemaine <karllim@apologia.cx>, Fabien Seisen <seisen@linuxfr.org>

 

Public Method Summary

void

Db()

Class constructor

Private Method Summary

void

clone()

Duplicates a DB maintaining consistency.
integer

connect(string $host, string $login, string $passwd, string $database)

Connects to the database
integer

pconnect(string $host, string $login, string $passwd, string $database)

Opens a persistent connection to the database
integer

close()

Closes the connection to the database
void

select_db(string $database)

Really useful???
integer

query(string $query)

Sends an SQL query, with limitations.
mixed

result(integer $nb, string $fieldname)

Gets the value of fieldname in row nb.
void

free()

Frees the result buffer.
array

fetch_array()

Gets the current row in data set.
void

fetch_field()

Hmm, unused one?
integer

num_rows()

Gets the number of rows in the result set
integer

num_fields()

Gets the nuimber of fields in the result set.
string

error()

Gets the last DBMS error message
integer

last_insert_id()

Gets last inserted ID
int

affected_rows()

Returns the number of rows affected by last query.
string

compat_limit(integer $nb, [ integer $offset ])

Creates a Pgsql-compatible (specific?) LIMIT clause
string

compat_date_add(integer $sec)

Creates a SQL expression for now + sec
string

timestamp14_to_dbms_stamp(string $t)

Converts a timestamp14 (YYYYMMDDhhmmss) into DBMS stamp
string

date8_to_dbms_date(string $t)

Converts a date8 (YYYYMMDD) into DBMS date (YYYY-MM-DD for PostgreSQL).
integer

insertLob(string $table, array $values, array $lobFields)

Inserts a LOB into the database.
string

getLobByID(string $table, string $pkField, integer $pk, string $lobField)

Gets a LOB identified by its primary key
array

fetchLOB(array $lobFields)

Gets a row from current dataset containing LOBs
integer

deleteLOB(string $table, string $pkField, integer $pk, string $lobField)

Deletes a row containing a LOB

Private Field Summary

unknown

$db

unknown

$results

unknown

$currentrow

Public Method Details

Db

public void Db( )

  Class constructor

Returns void


Private Method Details

clone

private void clone( )

  Duplicates a DB maintaining consistency.

Returns void


connect

private integer connect( string $host, string $login, string $passwd, string $database )

  Connects to the database

Parameter
string $host
DB host
string $login
login
string $passwd
password
string $database
name to connect to.
Returns integer

the dabase link identifier or NULL on failure(?)


pconnect

private integer pconnect( string $host, string $login, string $passwd, string $database )

  Opens a persistent connection to the database

Parameter
string $host
DB host
string $login
login
string $passwd
password
string $database
name to connect to.
Returns integer

the dabase link identifier or NULL on failure(?)


close

private integer close( )

  Closes the connection to the database

Returns integer

return code of pg_close().


select_db

private void select_db( string $database )

  Really useful???

Parameter
string $database
name of the database
Returns void


query

private integer query( string $query )

  Sends an SQL query, with limitations.
WARNING: don't send unduly long queries with this method! That is, query
length shall be less than 8000 characters long, because of a PgSQL
limitation. This limit may be lowered when we add support for other databases.

Parameter
string $query
query to b exectuted
Returns integer

a result index if the query has been successfully executed, false on failure.


result

private mixed result( integer $nb, string $fieldname )

  Gets the value of fieldname in row nb.
Row numbering starts at 0.

Parameter
integer $nb
number of the row
string $fieldname
field to return
Returns mixed

the value.


free

private void free( )

  Frees the result buffer.

Returns void


fetch_array

private array fetch_array( )

  Gets the current row in data set.
Automatically converts the "timestamp" field from pgsql timestamp
to a MySQL one.

Returns array

the fetched row; false if no more rows.


fetch_field

private void fetch_field( )

  Hmm, unused one?
Call to pg_fetch_array DOES NOT MATCH prototype

Returns void

Deprecated unsused in dacode? May not work.

num_rows

private integer num_rows( )

  Gets the number of rows in the result set

Returns integer


num_fields

private integer num_fields( )

  Gets the nuimber of fields in the result set.

Returns integer

(What else would you expect?)


error

private string error( )

  Gets the last DBMS error message

Returns string

the clear (hopefully!) english error message


last_insert_id

private integer last_insert_id( )

  Gets last inserted ID
REALLY USEFUL?

Returns integer


affected_rows

private int affected_rows( )

  Returns the number of rows affected by last query.

Returns int


compat_limit

private string compat_limit( integer $nb, [ integer $offset ] )

  Creates a Pgsql-compatible (specific?) LIMIT clause

Parameter
integer $nb
number of rows the result set should be limited to
integer $offset = >>0<<
number of rows to be skipped before the result set.
Returns string

a valid pgsql LIMIT clause


compat_date_add

private string compat_date_add( integer $sec )

  Creates a SQL expression for now + sec
Creates the SQL expression which will give a timestamp for
current time + sec seconds.

Parameter
integer $sec
number of seconds from now.
Returns string

the SQL order.


timestamp14_to_dbms_stamp

private string timestamp14_to_dbms_stamp( string $t )

  Converts a timestamp14 (YYYYMMDDhhmmss) into DBMS stamp
(YYYY-MM-DD hh:mm:ss for PostgreSQL).

Parameter
string $t
timestamp14
Returns string

a PostgreSQL timestamp


date8_to_dbms_date

private string date8_to_dbms_date( string $t )

  Converts a date8 (YYYYMMDD) into DBMS date (YYYY-MM-DD for PostgreSQL).

Parameter
string $t
date8
Returns string

a PostgreSQL date


insertLob

private integer insertLob( string $table, array $values, array $lobFields )

  Inserts a LOB into the database.
Takes care of any encoding needed for LOB. Other values must be valid SQL ie strings inside ' '.

Parameter
string $table
name of the table
array $values
(column, value) pair; valid SQL except LOB fields which are raw data.
array $lobFields
of fields to be treated as LOB
Returns integer

true on success, false otherwise


getLobByID

private string getLobByID( string $table, string $pkField, integer $pk, string $lobField )

  Gets a LOB identified by its primary key

Parameter
string $table
of the table...
string $pkField
the name of the primary key
integer $pk
the primary key itself
string $lobField
name of the LOB field.
Returns string

the LOB


fetchLOB

private array fetchLOB( array $lobFields )

  Gets a row from current dataset containing LOBs
Careful: you may run into inconsitencies if you use numeric indexes.
Always use name indexes.

Parameter
array $lobFields
of fields containing LOBs
Returns array

the fethed row, with LOBs...


deleteLOB

private integer deleteLOB( string $table, string $pkField, integer $pk, string $lobField )

  Deletes a row containing a LOB

Parameter
string $table
of the table...
string $pkField
the name of the primary key
integer $pk
the primary key itself
string $lobField
name of the LOB field.
Returns integer

true on success


Private Field Details

$db

private unknown $db

>><<



$results

private unknown $results

>><<



$currentrow

private unknown $currentrow

>><<




Packageindex Classtrees Modulegroups Elementlist Report XML Files
PHPDoc 1.0beta