class ODBCConnection implements IConnection, IFetch, IStatements, IDSN, IArguments, ITransactions (View source)

Dynamic and Static container class for ODBCConnection 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

__construct()

Empty constructor since initialization is handled by traits and interface methods

mixed
__get(string $name)

Magic method to access dynamic properties

from  Methods
void
__set(string $name, mixed $value)

Magic method to set dynamic properties

from  Methods
bool
__isset(string $name)

Magic method to check if a property exists

from  Methods
void
__unset(string $name)

Magic method to remove a property

from  Methods
array
__sleep()

Magic method for serialization

from  Methods
void
__wakeup()

Magic method for deserialization

from  Methods
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, either the last one inserted during the current transaction, or by passing in the optional name parameter.

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 sets an attribute from 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 ODBCConnection|void
setDriver(mixed $value)

Sets a driver from the database.

static ODBCConnection|string
getDriver(mixed $value)

Retrieves a driver from the database.

static ODBCConnection|void
setHost(mixed $value)

Sets a host from the database.

static ODBCConnection|string
getHost(mixed $value)

Retrieves a host from the database.

static ODBCConnection|void
setPort(mixed $value)

Sets a port from the database.

static ODBCConnection|int
getPort(mixed $value)

Retrieves a port from the database.

static ODBCConnection|void
setUser(mixed $value)

Sets a user from the database.

static ODBCConnection|string
getUser(mixed $value)

Retrieves a user from the database.

static ODBCConnection|void
setPassword(mixed $value)

Sets a password from the database.

static ODBCConnection|string
getPassword(mixed $value)

Retrieves a password from the database.

static ODBCConnection|void
setDatabase(mixed $value)

Sets a database name from the database.

static ODBCConnection|string
getDatabase(mixed $value)

Retrieves a database name from the database.

static ODBCConnection|void
setOptions(mixed $value)

Sets an options from the database.

static ODBCConnection|array|null
getOptions(mixed $value)

Retrieves an options from the database.

static ODBCConnection|static
setConnected(mixed $value)

Sets a connected status from the database.

static ODBCConnection|mixed
getConnected(mixed $value)

Retrieves a connected status from the database.

static ODBCConnection|void
setDsn(mixed $value)

Sets a dsn string from the database.

static ODBCConnection|mixed
getDsn(mixed $value)

Retrieves a dsn string from the database.

static ODBCConnection|void
setAttributes(mixed $value)

Sets an attributes from the database.

static ODBCConnection|mixed
getAttributes(mixed $value)

Retrieves an attributes from the database.

static ODBCConnection|void
setCharset(mixed $value)

Sets a charset from the database.

static ODBCConnection|string
getCharset(mixed $value)

Retrieves a charset from the database.

static ODBCConnection|void
setException(mixed $value)

Sets an exception from the database.

static ODBCConnection|mixed
getException(mixed $value)

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

Parameters

string $name

Property name

Return Value

mixed

void __set(string $name, mixed $value)

Magic method to set dynamic properties

Parameters

string $name

Property name

mixed $value

Value to be assigned

Return Value

void

bool __isset(string $name)

Magic method to check if a property exists

Parameters

string $name

Property name

Return Value

bool

void __unset(string $name)

Magic method to remove a property

Parameters

string $name

Property name

Return Value

void

array __sleep()

Magic method for serialization

Return Value

array

void __wakeup()

Magic method for deserialization

Return Value

void

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

Parameters

string|null $hash

Optional unique identifier for multiple instances

Return Value

Singleton

static Singleton newInstance(string|null $hash = null)

Create a new instance of the class and set it as the instance

Parameters

string|null $hash

Optional unique identifier for multiple instances

Return Value

Singleton

The newly created instance

static void setInstance(Singleton $instance, string|null $hash = null)

Set a specific instance

Parameters

Singleton $instance

The instance to set

string|null $hash

Optional unique identifier for multiple instances

Return Value

void

static void clearInstance(string|null $hash = null)

Clear instance(s)

Parameters

string|null $hash

Optional unique identifier for multiple instances

Return Value

void

static void clearAllInstances()

Clear all instances including the classic singleton instance

Return Value

void

IConnection|string|int|bool|array|null __call(string $name, array $arguments)

Triggered when invoking inaccessible methods in an object context

Parameters

string $name

Name of the method

array $arguments

Array of arguments

Return Value

IConnection|string|int|bool|array|null

Exceptions

ReflectionException

static IConnection|string|int|bool|array|null __callStatic(string $name, array $arguments)

Triggered when invoking inaccessible methods in a static context

Parameters

string $name

Name of the static method

array $arguments

Array of arguments

Return Value

IConnection|string|int|bool|array|null

Exceptions

ReflectionException

mixed connect()

This method is used to establish a database connection and set the connection instance

Return Value

mixed

Exceptions

Exception

bool ping()

Pings a server connection, or tries to reconnect if the connection has gone down

Return Value

bool

void disconnect()

Disconnects from a database.

Return Value

void

Exceptions

ReflectionException

bool isConnected()

Returns true when connection was established.

Return Value

bool

mixed getConnection()

This method is used to get the database connection instance

Return Value

mixed

mixed setConnection(mixed $connection)

This method is used to assign the database connection instance

Parameters

mixed $connection

Sets an instance of the connection with the database

Return Value

mixed

bool beginTransaction()

This function creates a new transaction, in order to be able to commit or rollback changes made to the database.

Return Value

bool

bool commit()

This function commits any changes made to the database during this transaction.

Return Value

bool

bool rollback()

This function rolls back any changes made to the database during this transaction and restores the data to its original state.

Return Value

bool

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.

Return Value

bool

string|int|false lastInsertId(string|null $name = null)

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.

Parameters

string|null $name

= null Resource name, table or view

Return Value

string|int|false

mixed quote(mixed ...$params)

This function quotes a string for use in an SQL statement and escapes special characters (such as quotes).

Parameters

mixed ...$params

Content to be quoted

Return Value

mixed

void setAllMetadata()

Reset query metadata

Return Value

void

object getAllMetadata()

Returns an object containing the number of queried rows and the number of affected rows.

Return Value

object

An associative object with keys 'queryRows' and 'affectedRows'.

string getQueryString()

Returns the query string.

Return Value

string

The query string associated with this instance.

void setQueryString(string $params)

Sets the query string for the Connection instance.

Parameters

string $params

The query string to set.

Return Value

void

array|null getQueryParameters()

Returns the parameters associated with this instance.

Return Value

array|null

The parameters associated with this instance.

void setQueryParameters(array|null $params)

Sets the query parameters for the Connection instance.

Parameters

array|null $params

The query parameters to set.

Return Value

void

int|false getQueryRows()

Returns the number of rows affected by an operation.

Return Value

int|false

The number of affected rows

void setQueryRows(callable|int|false $params)

Sets the number of query rows for the Connection instance.

Parameters

callable|int|false $params

The number of query rows to set.

Return Value

void

int|false getQueryColumns()

Returns the number of columns in a statement result.

Return Value

int|false

The number of columns in the result or false in case of an error.

void setQueryColumns(int|false $params)

Sets the number of columns in the query result.

Parameters

int|false $params

The number of columns or false if there are no columns.

Return Value

void

int|false getAffectedRows()

Returns the number of rows affected by an operation.

Return Value

int|false

The number of affected rows

void setAffectedRows(int|false $params)

Sets the number of affected rows for the Connection instance.

Parameters

int|false $params

The number of affected rows to set.

Return Value

void

mixed getStatement()

Returns the statement for the function.

Return Value

mixed

void setStatement(mixed $statement)

Set the statement for the function.

Parameters

mixed $statement

The statement to be set.

Return Value

void

void bindParam(object $params)

Binds a parameter to a variable in the SQL statement.

Parameters

object $params

The name of the parameter or an array of parameters and values.

Return Value

void

string parse(mixed ...$params)

Parses an SQL statement and returns an statement.

Parameters

mixed ...$params

The parameters for the query function.

Return Value

string

The statement resulting from the SQL statement.

mixed query(mixed ...$params)

This function executes an SQL statement and returns the result set as a statement object.

Parameters

mixed ...$params

Statement to be queried

Return Value

mixed

mixed prepare(mixed ...$params)

This function binds the parameters to a prepared query.

Parameters

mixed ...$params

Statement to be prepared

Return Value

mixed

mixed exec(mixed ...$params)

This function runs an SQL statement and returns the number of affected rows.

Parameters

mixed ...$params

Statement to be executed

Return Value

mixed

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.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

mixed

The query result.

mixed fetchAll(int|null $fetchStyle = null, mixed $fetchArgument = null, mixed $optArgs = null)

Fetches all rows from the statement and returns them as an array.

Parameters

int|null $fetchStyle

The fetch style to use.

mixed $fetchArgument

The fetch argument to use.

mixed $optArgs

Additional options for the fetch operation.

Return Value

mixed

The query result.

mixed getAttribute(mixed $name)

This function retrieves an attribute from the database.

Parameters

mixed $name

The attribute name

Return Value

mixed

Exceptions

ReflectionException

void setAttribute(mixed $name, mixed $value)

This function sets an attribute from the database.

Parameters

mixed $name

The attribute name

mixed $value

The attribute value

Return Value

void

Exceptions

ReflectionException

int|string|array|bool|null errorCode(mixed $inst = null)

This function returns an SQLSTATE code for the last operation executed by the database.

Parameters

mixed $inst

= null Resource name, table or view

Return Value

int|string|array|bool|null

string|array|bool|null errorInfo(mixed $inst = null)

This function returns an array containing error information about the last operation performed by the database.

Parameters

mixed $inst

= null Resource name, table or view

Return Value

string|array|bool|null

static ODBCConnection|void setDriver(mixed $value)

Sets a driver from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getDriver(mixed $value)

Retrieves a driver from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setHost(mixed $value)

Sets a host from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getHost(mixed $value)

Retrieves a host from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setPort(mixed $value)

Sets a port from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|int getPort(mixed $value)

Retrieves a port from the database.

Parameters

mixed $value

Return Value

ODBCConnection|int

static ODBCConnection|void setUser(mixed $value)

Sets a user from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getUser(mixed $value)

Retrieves a user from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setPassword(mixed $value)

Sets a password from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getPassword(mixed $value)

Retrieves a password from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setDatabase(mixed $value)

Sets a database name from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getDatabase(mixed $value)

Retrieves a database name from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setOptions(mixed $value)

Sets an options from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|array|null getOptions(mixed $value)

Retrieves an options from the database.

Parameters

mixed $value

Return Value

ODBCConnection|array|null

static ODBCConnection|static setConnected(mixed $value)

Sets a connected status from the database.

Parameters

mixed $value

Return Value

ODBCConnection|static

static ODBCConnection|mixed getConnected(mixed $value)

Retrieves a connected status from the database.

Parameters

mixed $value

Return Value

ODBCConnection|mixed

static ODBCConnection|void setDsn(mixed $value)

Sets a dsn string from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|mixed getDsn(mixed $value)

Retrieves a dsn string from the database.

Parameters

mixed $value

Return Value

ODBCConnection|mixed

static ODBCConnection|void setAttributes(mixed $value)

Sets an attributes from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|mixed getAttributes(mixed $value)

Retrieves an attributes from the database.

Parameters

mixed $value

Return Value

ODBCConnection|mixed

static ODBCConnection|void setCharset(mixed $value)

Sets a charset from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|string getCharset(mixed $value)

Retrieves a charset from the database.

Parameters

mixed $value

Return Value

ODBCConnection|string

static ODBCConnection|void setException(mixed $value)

Sets an exception from the database.

Parameters

mixed $value

Return Value

ODBCConnection|void

static ODBCConnection|mixed getException(mixed $value)

Retrieves an exception from the database.

Parameters

mixed $value

Return Value

ODBCConnection|mixed