Medical Appointments API

Connection
in package

Connection class for establishing a PDO database connection.

The Connection class provides a static method to obtain a PDO instance for interacting with the database. It uses environment variables to configure the connection parameters.

Tags
author

Luis Graciano contacto@luisgraciano.dev

Table of Contents

$_db  : PDO|null
commitTransaction()  : void
Commit the current transaction.
get()  : PDO
Get a PDO instance for the database connection.
initTransaction()  : bool
Begin a transaction.
rollbackTransaction()  : void
Roll back the current transaction.
__clone()  : mixed
Connection clone method.
__construct()  : mixed
Connection constructor.

Properties

$_db

private static PDO|null $_db = null

The PDO instance for the database connection.

Methods

commitTransaction()

Commit the current transaction.

public static commitTransaction() : void
Tags
throws
UnhandledException

If an error occurs while committing the transaction.

Return values
void

get()

Get a PDO instance for the database connection.

public static get() : PDO
Tags
throws
UnhandledException

If an error occurs while connecting to the database.

Return values
PDO

A PDO instance for the database connection.

initTransaction()

Begin a transaction.

public static initTransaction() : bool
Tags
throws
UnhandledException

If an error occurs while beginning the transaction.

Return values
bool

True if the transaction was started, false if a transaction is already in progress.

rollbackTransaction()

Roll back the current transaction.

public static rollbackTransaction() : void
Tags
throws
UnhandledException

If an error occurs while rolling back the transaction.

Return values
void

__clone()

Connection clone method.

private __clone() : mixed

This method is private to prevent cloning of this class.

Return values
mixed

__construct()

Connection constructor.

private __construct() : mixed

This constructor is private to prevent instantiation of this class.

Return values
mixed

Search results