PgSQLConnection
class PgSQLConnection implements IConnection, IFetch, IStatements, IDSN, IArguments, ITransactions (View source)
Dynamic and Static container class for PgSQLConnection connections.
Traits
This trait provides magic methods for dynamic property access and manipulation
and also includes methods for getting, setting, checking existence, and unsetting
properties dynamically. It also handles serialization and deserialization of the
property using the __sleep and __wakeup magic methods.
This trait provides methods to manage a single instance of a class or multiple instances identified by a unique hash. It includes methods to get, create, set, and clear instances.
Properties
| Settings|null | $property | Property to store settings |
from Methods |
Methods
Empty constructor since initialization is handled by traits and interface methods
Create or obtain an instance If no hash is provided, works as classic singleton If hash is provided, creates/returns instance for that hash
Create a new instance of the class and set it as the instance
Clear all instances including the classic singleton instance
Triggered when invoking inaccessible methods in an object context
Triggered when invoking inaccessible methods in a static context
This method is used to establish a database connection and set the connection instance
Pings a server connection, or tries to reconnect if the connection has gone down
Disconnects from a database.
Returns true when connection was established.
This method is used to get the database connection instance
This method is used to assign the database connection instance
This function creates a new transaction, in order to be able to commit or rollback changes made to the database.
This function commits any changes made to the database during this transaction.
This function rolls back any changes made to the database during this transaction and restores the data to its original state.
This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.
This function returns the last ID generated by an auto-increment column.
This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).
Reset query metadata
Returns an object containing the number of queried rows and the number of affected rows.
Returns the query string.
Sets the query string for the Connection instance.
Returns the parameters associated with this instance.
Sets the query parameters for the Connection instance.
Returns the number of rows affected by an operation.
Sets the number of query rows for the Connection instance.
Returns the number of columns in a statement result.
Sets the number of columns in the query result.
Returns the number of rows affected by an operation.
Sets the number of affected rows for the Connection instance.
Returns the statement for the function.
Set the statement for the function.
Binds a parameter to a variable in the SQL statement.
Parses an SQL statement and returns an statement.
This function executes an SQL statement and returns the result set as a statement object.
This function binds the parameters to a prepared query.
This function runs an SQL statement and returns the number of affected rows.
Fetches the next row from the statement and returns it as an array.
Fetches all rows from the statement and returns them as an array.
This function retrieves an attribute from the database.
This function returns an array containing error information about the last operation performed by the database.
This function returns an SQLSTATE code for the last operation executed by the database.
This function returns an array containing error information about the last operation performed by the database.
Sets a driver from the database.
Retrieves a driver from the database.
Sets a host from the database.
Retrieves a host from the database.
Sets a port from the database.
Retrieves a port from the database.
Sets a user from the database.
Retrieves a user from the database.
Sets a password from the database.
Retrieves a password from the database.
Sets a database name from the database.
Retrieves a database name from the database.
Sets an options from the database.
Retrieves an options from the database.
Sets a connected status from the database.
Retrieves a connected status from the database.
Sets a dsn string from the database.
Retrieves a dsn string from the database.
Sets an attributes from the database.
Retrieves an attributes from the database.
Sets a charset from the database.
Retrieves a charset from the database.
Sets an exception from the database.
Retrieves an exception from the database.
Details
__construct()
Empty constructor since initialization is handled by traits and interface methods
mixed
__get(string $name)
Magic method to access dynamic properties
void
__set(string $name, mixed $value)
Magic method to set dynamic properties
bool
__isset(string $name)
Magic method to check if a property exists
void
__unset(string $name)
Magic method to remove a property
array
__sleep()
Magic method for serialization
void
__wakeup()
Magic method for deserialization
static Singleton
getInstance(string|null $hash = null)
Create or obtain an instance If no hash is provided, works as classic singleton If hash is provided, creates/returns instance for that hash
static Singleton
newInstance(string|null $hash = null)
Create a new instance of the class and set it as the instance
static void
setInstance(Singleton $instance, string|null $hash = null)
Set a specific instance
static void
clearInstance(string|null $hash = null)
Clear instance(s)
static void
clearAllInstances()
Clear all instances including the classic singleton instance
IConnection|string|int|bool|array|null
__call(string $name, array $arguments)
Triggered when invoking inaccessible methods in an object context
static IConnection|string|int|bool|array|null
__callStatic(string $name, array $arguments)
Triggered when invoking inaccessible methods in a static context
mixed
connect()
This method is used to establish a database connection and set the connection instance
bool
ping()
Pings a server connection, or tries to reconnect if the connection has gone down
void
disconnect()
Disconnects from a database.
bool
isConnected()
Returns true when connection was established.
mixed
getConnection()
This method is used to get the database connection instance
mixed
setConnection(mixed $connection)
This method is used to assign the database connection instance
bool
beginTransaction()
This function creates a new transaction, in order to be able to commit or rollback changes made to the database.
bool
commit()
This function commits any changes made to the database during this transaction.
bool
rollback()
This function rolls back any changes made to the database during this transaction and restores the data to its original state.
bool
inTransaction()
This function returns the last ID generated by an auto-increment column, either the last one inserted during the current transaction, or by passing in the optional name parameter.
string|int|false
lastInsertId(string|null $name = null)
This function returns the last ID generated by an auto-increment column.
mixed
quote(mixed ...$params)
This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).
void
setAllMetadata()
Reset query metadata
object
getAllMetadata()
Returns an object containing the number of queried rows and the number of affected rows.
string
getQueryString()
Returns the query string.
void
setQueryString(string $params)
Sets the query string for the Connection instance.
array|null
getQueryParameters()
Returns the parameters associated with this instance.
void
setQueryParameters(array|null $params)
Sets the query parameters for the Connection instance.
int|false
getQueryRows()
Returns the number of rows affected by an operation.
void
setQueryRows(callable|int|false $params)
Sets the number of query rows for the Connection instance.
int|false
getQueryColumns()
Returns the number of columns in a statement result.
void
setQueryColumns(int|false $params)
Sets the number of columns in the query result.
int|false
getAffectedRows()
Returns the number of rows affected by an operation.
void
setAffectedRows(int|false $params)
Sets the number of affected rows for the Connection instance.
mixed
getStatement()
Returns the statement for the function.
void
setStatement(mixed $statement)
Set the statement for the function.
void
bindParam(object $params)
Binds a parameter to a variable in the SQL statement.
string
parse(mixed ...$params)
Parses an SQL statement and returns an statement.
mixed
query(mixed ...$params)
This function executes an SQL statement and returns the result set as a statement object.
mixed
prepare(mixed ...$params)
This function binds the parameters to a prepared query.
mixed
exec(mixed ...$params)
This function runs an SQL statement and returns the number of affected rows.
mixed
fetch(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)
Fetches the next row from the statement and returns it as an array.
mixed
fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)
Fetches all rows from the statement and returns them as an array.
mixed
getAttribute(mixed $name)
This function retrieves an attribute from the database.
void
setAttribute(mixed $name, mixed $value)
This function returns an array containing error information about the last operation performed by the database.
int|string|array|bool|null
errorCode(mixed $inst = null)
This function returns an SQLSTATE code for the last operation executed by the database.
string|array|bool|null
errorInfo(mixed $inst = null)
This function returns an array containing error information about the last operation performed by the database.
static PgSQLConnection|void
setDriver(mixed $value)
Sets a driver from the database.
static PgSQLConnection|string
getDriver(mixed $value)
Retrieves a driver from the database.
static PgSQLConnection|void
setHost(mixed $value)
Sets a host from the database.
static PgSQLConnection|string
getHost(mixed $value)
Retrieves a host from the database.
static PgSQLConnection|void
setPort(mixed $value)
Sets a port from the database.
static PgSQLConnection|int
getPort(mixed $value)
Retrieves a port from the database.
static PgSQLConnection|void
setUser(mixed $value)
Sets a user from the database.
static PgSQLConnection|string
getUser(mixed $value)
Retrieves a user from the database.
static PgSQLConnection|void
setPassword(mixed $value)
Sets a password from the database.
static PgSQLConnection|string
getPassword(mixed $value)
Retrieves a password from the database.
static PgSQLConnection|void
setDatabase(mixed $value)
Sets a database name from the database.
static PgSQLConnection|string
getDatabase(mixed $value)
Retrieves a database name from the database.
static PgSQLConnection|void
setOptions(mixed $value)
Sets an options from the database.
static PgSQLConnection|array|null
getOptions(mixed $value)
Retrieves an options from the database.
static PgSQLConnection|static
setConnected(mixed $value)
Sets a connected status from the database.
static PgSQLConnection|mixed
getConnected(mixed $value)
Retrieves a connected status from the database.
static PgSQLConnection|void
setDsn(mixed $value)
Sets a dsn string from the database.
static PgSQLConnection|mixed
getDsn(mixed $value)
Retrieves a dsn string from the database.
static PgSQLConnection|void
setAttributes(mixed $value)
Sets an attributes from the database.
static PgSQLConnection|mixed
getAttributes(mixed $value)
Retrieves an attributes from the database.
static PgSQLConnection|void
setCharset(mixed $value)
Sets a charset from the database.
static PgSQLConnection|string
getCharset(mixed $value)
Retrieves a charset from the database.
static PgSQLConnection|void
setException(mixed $value)
Sets an exception from the database.
static PgSQLConnection|mixed
getException(mixed $value)
Retrieves an exception from the database.