Documentation

Connection
in package
implements IConnection

FinalYes

Class for connecting to the PostgreSql database.

This class provides methods for establishing and managing connections to a PostgreSql database.

Table of Contents

Interfaces

IConnection
Interface for managing database connections.

Properties

$connection  : resource
$isAlive  : bool
$raw  : resource
$resource  : resource
$_connectioninfo  : object|null
$_resource  : Connection|null

Methods

__construct()  : mixed
Connection constructor.
__get()  : mixed
Magic getter method.
Close()  : void
Closes the PostgreSql database connection.
Open()  : bool
Opens a connection to the PostgreSql database server.
Reopen()  : bool
Reopens the PostgreSql database connection.

Properties

$connection read-only

public resource $connection

Alias for $resource.

$isAlive read-only

public bool $isAlive

Indicates whether the connection to the PostgreSql server is alive.

$raw read-only

public resource $raw

The raw PostgreSql connection resource.

$resource read-only

public resource $resource

The PostgreSql connection resource.

$_connectioninfo

private object|null $_connectioninfo = null

Connection information object containing host, port, user, password, and database.

$_resource

private Connection|null $_resource = null

The PostgreSql connection resource.

Methods

__construct()

Connection constructor.

public __construct(string $host, string $port, string $user, string $password[, bool $persistent = false ][, string|null $database = null ]) : mixed

Initializes a new Connection object with the provided connection information.

Parameters
$host : string

The hostname or IP address of the PostgreSql server.

$port : string

The port number of the PostgreSql server.

$user : string

The PostgreSql username.

$password : string

The PostgreSql password.

$persistent : bool = false

Whether to use a persistent connection (true) or not (false).

$database : string|null = null

(Optional) The name of the default database to connect to.

__get()

Magic getter method.

public __get(string $property) : mixed

Allows access to read-only properties such as $resource, $raw, $connection, and $isAlive.

Parameters
$property : string

The name of the property to retrieve.

Return values
mixed

Returns the value of the requested property, or null if the property does not exist.

Close()

Closes the PostgreSql database connection.

public Close() : void

Open()

Opens a connection to the PostgreSql database server.

public Open() : bool
Tags
throws
Exception

If an error occurs while establishing the connection.

Return values
bool

Returns true if the connection was successful; otherwise, false.

Reopen()

Reopens the PostgreSql database connection.

public Reopen() : bool

This method is an alias for Open().

Return values
bool

Returns true if the connection was successfully reopened; otherwise, false.


        
On this page

Search results