PostgreSQLDBC
A PHP library for managing PostgreSQL database connections with prepared statements.
Loading...
Searching...
No Matches
PostgreSQLDatabase Class Reference

Public Member Functions

 __destruct ()
 
 ConfigureSTMT ($name, $query)
 
 ExecuteAsyncQuery ($query)
 
 ExecuteSTMT ($name,... $params)
 
 ExecuteAsyncSTMT ($name,... $params)
 
 GetAffectedRowsSTMT ($name)
 
 IsConnected ()
 
 ShowAllSTMTNames ()
 
 StartTransaction ()
 
 LockTable ($tablename)
 
 EndTransaction ($commit=true)
 
 StartCopyFromSTDIN ($tablename)
 
 PutDataSTDIN ($data)
 
 EndCopyFromSTDIN ()
 
 EscapeString ($string)
 
 GetSQLQueryExecutedCount ()
 
 EscapeByteA ($bytea)
 
 UnEscapeByteA ($bytea)
 
 GetExecutedSTMTStatistics ()
 
 GetTimeSpent ()
 

Public Attributes

const SMALLINT_MIN = "-32768"
 
const SMALLINT_MAX = "32767"
 
const INT_MIN = "-2147483648"
 
const INT_MAX = "2147483647"
 
const BIGINT_MIN = "-9223372036854775808"
 
const BIGINT_MAX = "9223372036854775807"
 

Protected Member Functions

 __construct ()
 
 Connect ()
 
 Configure ($server, $user, $pass, $db)
 
 DeleteSTMT ($name)
 
 DeleteAllSTMT ()
 
 ExecuteQuery ($query)
 
 LoadAllSTMTs ()
 
 GetAllConfiguredSTMTs ()
 
 GetSTMTExecStats ()
 

Static Protected Attributes

static $_instance = NULL
 

Constructor & Destructor Documentation

◆ __construct()

PostgreSQLDatabase::__construct ( )
protected

Constructor.

Initializes internal variables and prepares the class for use.

◆ __destruct()

PostgreSQLDatabase::__destruct ( )

Destructor.

Ensures the database connection is closed and resources are freed.

Member Function Documentation

◆ Configure()

PostgreSQLDatabase::Configure (   $server,
  $user,
  $pass,
  $db 
)
finalprotected

Configures the database connection settings.

Parameters
string$serverThe database server address.
string$userThe username for the database.
string$passThe password for the database.
string$dbThe name of the database.

◆ ConfigureSTMT()

PostgreSQLDatabase::ConfigureSTMT (   $name,
  $query 
)
final

Configures a prepared statement.

Parameters
string$nameThe name of the prepared statement.
string$queryThe SQL query for the prepared statement.

◆ Connect()

PostgreSQLDatabase::Connect ( )
finalprotected

Connects to the PostgreSQL database.

Exceptions
ExceptionIf the connection fails.

◆ DeleteAllSTMT()

PostgreSQLDatabase::DeleteAllSTMT ( )
finalprotected

Deletes all prepared statements.

◆ DeleteSTMT()

PostgreSQLDatabase::DeleteSTMT (   $name)
finalprotected

Deletes a prepared statement by its name.

Parameters
string$nameThe name of the prepared statement.

◆ EndCopyFromSTDIN()

PostgreSQLDatabase::EndCopyFromSTDIN ( )
final

Ends copying data from STDIN.

◆ EndTransaction()

PostgreSQLDatabase::EndTransaction (   $commit = true)
final

Ends a transaction.

Parameters
bool$commitTrue to commit data, false to rollback.

◆ EscapeByteA()

PostgreSQLDatabase::EscapeByteA (   $bytea)

Escapes a bytea value for use in a SQL query.

Parameters
string$byteaThe bytea value to escape.
Returns
string The escaped bytea value.

◆ EscapeString()

PostgreSQLDatabase::EscapeString (   $string)
final

Escapes a string for use in a SQL query.

Parameters
string$stringThe string to escape.
Returns
string The escaped string.

◆ ExecuteAsyncQuery()

PostgreSQLDatabase::ExecuteAsyncQuery (   $query)
final

Executes a query asynchronously.

Parameters
string$queryThe SQL query to execute.

◆ ExecuteAsyncSTMT()

PostgreSQLDatabase::ExecuteAsyncSTMT (   $name,
  $params 
)
final

Executes a prepared statement asynchronously (ignoring result).

Parameters
string$nameThe name of the prepared statement.
mixed...$params The parameters for the prepared statement.

◆ ExecuteQuery()

PostgreSQLDatabase::ExecuteQuery (   $query)
finalprotected

Executes a raw SQL query.

Parameters
string$queryThe SQL query to execute.
Returns
array|bool The result of the query, or false on failure.

◆ ExecuteSTMT()

PostgreSQLDatabase::ExecuteSTMT (   $name,
  $params 
)
final

Executes and fetches results from a prepared statement.

Parameters
string$nameThe name of the prepared statement.
mixed...$params The parameters for the prepared statement.
Returns
array|bool|int The result of the execution, or false on failure.

◆ GetAffectedRowsSTMT()

PostgreSQLDatabase::GetAffectedRowsSTMT (   $name)
final

Obtain affected rows of a prepared statement previously executed.

Parameters
string$nameThe name of the prepared statement.
Returns
int The number of affected rows.

◆ GetAllConfiguredSTMTs()

PostgreSQLDatabase::GetAllConfiguredSTMTs ( )
finalprotected

Gets all configured prepared statements (for debug).

Returns
array The configured prepared statements.

◆ GetExecutedSTMTStatistics()

PostgreSQLDatabase::GetExecutedSTMTStatistics ( )

Gets statistics for executed prepared statements.

Returns
array The statistics for executed prepared statements.

◆ GetSQLQueryExecutedCount()

PostgreSQLDatabase::GetSQLQueryExecutedCount ( )

Gets the count of executed SQL queries.

Returns
int The count of executed SQL queries.

◆ GetSTMTExecStats()

PostgreSQLDatabase::GetSTMTExecStats ( )
finalprotected

Gets the execution count of prepared statements.

Returns
array The execution count of prepared statements.

◆ GetTimeSpent()

PostgreSQLDatabase::GetTimeSpent ( )

Gets the total time spent executing SQL queries.

Returns
float The total time spent executing SQL queries.

◆ IsConnected()

PostgreSQLDatabase::IsConnected ( )

Checks if the server is connected.

Returns
bool True if connected, false otherwise.

◆ LoadAllSTMTs()

PostgreSQLDatabase::LoadAllSTMTs ( )
finalprotected

Debug function to load and parse all prepared statements in search for an error.

◆ LockTable()

PostgreSQLDatabase::LockTable (   $tablename)
final

Locks a table within a transaction.

Parameters
string$tablenameThe name of the table to lock.

◆ PutDataSTDIN()

PostgreSQLDatabase::PutDataSTDIN (   $data)
final

Puts data to STDIN for a copy.

Parameters
string$dataThe data to copy.

◆ ShowAllSTMTNames()

PostgreSQLDatabase::ShowAllSTMTNames ( )
final

Function to show all prepared statement names.

◆ StartCopyFromSTDIN()

PostgreSQLDatabase::StartCopyFromSTDIN (   $tablename)
final

Starts a copy from STDIN.

Parameters
string$tablenameThe name of the table.

◆ StartTransaction()

PostgreSQLDatabase::StartTransaction ( )
final

Starts a transaction.

◆ UnEscapeByteA()

PostgreSQLDatabase::UnEscapeByteA (   $bytea)

Unescapes a bytea value.

Parameters
string$byteaThe bytea value to unescape.
Returns
string The unescaped bytea value.

Member Data Documentation

◆ BIGINT_MAX

const PostgreSQLDatabase::BIGINT_MAX = "9223372036854775807"

Maximum value for BIGINT.

◆ BIGINT_MIN

const PostgreSQLDatabase::BIGINT_MIN = "-9223372036854775808"

Minimum value for BIGINT.

◆ INT_MAX

const PostgreSQLDatabase::INT_MAX = "2147483647"

Maximum value for INT.

◆ INT_MIN

const PostgreSQLDatabase::INT_MIN = "-2147483648"

Minimum value for INT.

◆ SMALLINT_MAX

const PostgreSQLDatabase::SMALLINT_MAX = "32767"

Maximum value for SMALLINT.

◆ SMALLINT_MIN

const PostgreSQLDatabase::SMALLINT_MIN = "-32768"

Minimum value for SMALLINT.


The documentation for this class was generated from the following file: