Class PostgreSQLDatabase

Description

A PostgreSQLDatabase class provides the tools to connect, query, etc., a PostgreSQL database.

  • version: $Id: PostgreSQLDatabase.class.php,v 1.1 2007/09/14 13:57:08 adamfranco Exp $
  • license: GNU General Public License (GPL)
  • copyright: Copyright © 2005, Middlebury College

Located in /harmoni/core/DBHandler/PostgreSQL/PostgreSQLDatabase.class.php (line 29)

DatabaseAbstract
   |
   --PostgreSQLDatabase
Variable Summary
string $_dbHost
string $_dbName
string $_dbPass
string $_dbUser
integer $_failedQueries
mixed $_linkId
Method Summary
integer PostgreSQLDatabase (string $dbHost, string $dbName, string $dbUser, string $dbPass)
mixed connect ()
boolean disconnect ()
ref fromDBDate (mixed $value)
string generateSQL (object $query)
string getStringName ()
array getTableList ()
boolean isConnected ()
mixed pConnect ()
mixed query (Query $query)
boolean selectDatabase (string $database)
mixed toDBDate (DateAndTime $dateAndTime)
mixed _query (mixed $query)
Variables
string $_dbHost (line 39)

The hostname of the database, i.e. myserver.mydomain.edu.

The hostname of the database, i.e. myserver.mydomain.edu.

  • var: The hostname of the database, i.e. myserver.mydomain.edu.
  • access: private
string $_dbName (line 47)

The name of the default database to use.

The name of the default database to use.

  • var: The name of the default database to use.
  • access: private
string $_dbPass (line 63)

The password for $_dbUser with which to connect to the database.

The password for $_dbUser with which to connect to the database.

  • var: The password for $_dbUser with which to connect to the database.
  • access: private
string $_dbUser (line 55)

The username with which to connect to the database.

The username with which to connect to the database.

  • var: The username with which to connect to the database.
  • access: private
integer $_failedQueries (line 91)

The total number of failed queries executed since the last call to connect().

The total number of failed queries executed since the last call to connect().

  • var: The total number of failed queries executed since the last call to connect().
  • access: private
mixed $_linkId (line 73)

Stores the current connection's link identifier.

If a connection is open, this stores the connection's identifier. Otherwise, it stores FALSE.

  • var: If a connection is open, this stores the connection's identifier. Otherwise, it stores FALSE.
  • access: private
integer $_successfulQueries (line 82)

The total number of successful queries executed since the last call to connect().

The total number of failed queries executed since the last call to connect().

  • var: The total number of failed queries executed since the last call to connect().
  • access: private
Methods
Constructor PostgreSQLDatabase (line 103)

Creates a new database connection.

  • return: The index of the new database
  • access: public
integer PostgreSQLDatabase (string $dbHost, string $dbName, string $dbUser, string $dbPass)
  • string $dbHost: The hostname for the database, i.e. myserver.mydomain.edu.
  • string $dbName: The name of the default database to use.
  • string $dbUser: The username with which to connect to the database.
  • string $dbPass: The password for $_dbUser with which to connect to the database.
beginTransaction (line 544)

Begin a transaction.

  • since: 3/9/05
  • access: public
void beginTransaction ()
commitTransaction (line 556)

Commit a transaction. This will roll-back changes if errors occured in the transaction block.

  • since: 3/9/05
  • access: public
void commitTransaction ()
connect (line 158)

Connects to the database.

Connects to the database.

  • return: The connection's link identifier, if successful; False, otherwise.
  • access: public
mixed connect ()
disconnect (line 370)

Disconnects from the database.

Disconnects from the database.

  • return: True, if successful; False, otherwise.
  • access: public
boolean disconnect ()
fromDBDate (line 504)

Converts a database datetime/timestamp/time value (that has been fetched from the db) to a DateAndTime object.

Depending on the server configuration PostgreSQL retrieves date/time types as 4 different formats. (format could be set with SET DateStyle ). The default formatting is 'ISO'. Note that timestamp column types return the full string. Date column types only return the date (no time).

Style Description Example 'ISO' ISO-8601 standard 1997-12-17 07:37:16-08 'SQL' Traditional style 12/17/1997 07:37:16.00 PST 'PostgreSQL' Original style Wed Dec 17 07:37:16 1997 PST 'German' Regional style 17.12.1997 07:37:16.00 PST

  • return: object The DateAndTime object.
  • access: public
ref fromDBDate (mixed $value)
  • mixed $value: A database datetime/timestamp/time value (that has been fetched from the db).
generateSQL (line 311)

Answer the string SQL for the query

  • since: 11/14/06
  • access: public
string generateSQL (object $query)
  • object $query
getNumberFailedQueries (line 418)

Returns the total number of failed queries executed since the last call to connect().

Returns the total number of failed queries executed since the last call to connect().

  • return: The total number of failed queries executed since the last call to connect().
  • access: public
integer getNumberFailedQueries ()
getNumberSuccessfulQueries (line 406)

Returns the total number of successful queries executed since the last call to connect().

Returns the total number of successful queries executed since the last call to connect().

  • return: The total number of successful queries executed since the last call to connect().
  • access: public
integer getNumberSuccessfulQueries ()
getStringName (line 126)

Returns a short string name for this database type. Example: 'MySQL'

  • access: public
string getStringName ()
getTableList (line 135)

Returns a list of the tables that exist in the currently connected database.

  • access: public
array getTableList ()
isConnected (line 391)

Indicates whether there is an open connection to the database.

Indicates whether there is an open connection to the database.

  • return: True if there is an open connection to the database; False, otherwise.
  • access: public
boolean isConnected ()
pConnect (line 197)

Makes a persistent database connection.

Makes a persistent database connection.

  • return: The connection's link identifier, if successful; False, otherwise.
  • access: public
mixed pConnect ()
query (line 243)

Executes an SQL query.

Executes an SQL query. The method is passed a query object, which it converts to a SQL query string using the appropriate SQLGenerator object.

  • return: The appropriate QueryResult object. If the query failed, it would return NULL.
  • access: public
mixed query (Query $query)
  • object Query $query: A Query object from which the SQL query will be constructed.
rollbackTransaction (line 567)

Roll-back a transaction manually instead of committing

  • since: 3/9/05
  • access: public
void rollbackTransaction ()
selectDatabase (line 430)

This method selects the default database to use in queries.

  • return: True, if successful; False, otherwise.
  • access: public
boolean selectDatabase (string $database)
  • string $database: database The name of the default database.
supportsTransactions (line 533)

Return TRUE if this database supports transactions.

  • since: 3/9/05
  • access: public
boolean supportsTransactions ()
toDBDate (line 474)

Converts a DateAndTime object to a proper datetime/timestamp/time representation for this Database.

The easiest way to convert is to create a string in the following format: 'YYYY-MM-DD HH:MM:SS', i.e. 1999-01-08 04:05:06 You can pass this to a PostgreSQL date or timestamp column types and it gets parsed automatically by PostgreSQL.

  • return: A proper datetime/timestamp/time representation for this Database.
  • access: public
mixed toDBDate (DateAndTime $dateAndTime)
  • ref $dateAndTime: object DateAndTime The DateAndTime object to convert.
_query (line 326)

Executes an SQL query.

Executes an SQL query.

  • return: For a SELECT statement, a resource identifier, if successful; For INSERT, DELETE, UPDATE statements, TRUE if successful; for all: FALSE, if not successful. If
    1. $query
    had several queries, this would be the result for the last one.
  • access: private
mixed _query (mixed $query)
  • mixed $query: query Either a string (this would be the case, normally) or an array of strings. Each string is corresponding to an SQL query.

Inherited Methods

Inherited From DatabaseAbstract

DatabaseAbstract::getConnectionErrorInfo()

Documentation generated on Wed, 19 Sep 2007 10:25:32 -0400 by phpDocumentor 1.3.0RC3