abstract class AbstractStatements implements IStatementsAbstract (View source)

The GenericDatabase\Abstract\AbstractStatements that handles database statements.

It implements the IStatements interface and provides a set of methods for managing database connections, options, reports, and metadata.

Main functionalities:

  • Provides a base class for managing database statements.
  • Allows dynamic setting and getting of options using a connection instance and an options array.
  • Provides a common interface for all options classes.

Methods:

  • getInstance: Returns the current database connection instance.
  • set: Sets a value using a dynamic method call on the database connection instance.
  • get: Gets a value using a dynamic method call on the database connection instance.
  • getOptionsHandler: Returns the current options handler instance.
  • getReportHandler: Returns the current report handler instance.
  • setAllMetadata: Resets all metadata to default values.
  • getAllMetadata: Returns the current metadata instance.
  • getQueryString: Returns the current query string.
  • setQueryString: Sets the query string.
  • getQueryParameters: Returns the current query parameters.
  • setQueryParameters: Sets the query parameters.
  • getQueryRows: Returns the number of rows fetched.
  • setQueryRows: Sets the number of rows fetched.
  • getQueryColumns: Returns the number of columns in the result.
  • setQueryColumns: Sets the number of columns in the result.
  • getAffectedRows: Returns the number of affected rows.
  • setAffectedRows: Sets the number of affected rows.
  • getStatement: Returns the current statement object.
  • setStatement: Sets the statement object.

Fields:

  • $instance: The connection instance used for dynamic operations.
  • $optionsHandler: The options handler for managing configuration.
  • $reportHandler: The report handler for managing configuration.
  • $metadata: The metadata handler for managing configuration.
  • $statement: The statement handler for managing configuration.

Note that some of these methods are used to manage metadata, which is an instance of the Metadata class. The metadata is used to store information about the query, such as the query string, parameters, rows fetched, and columns.

Properties

static protected IConnection $instance
static protected IOptions $optionsHandler
static protected IReport $reportHandler
protected Metadata $metadata
protected mixed|null $statement

Methods

__construct(IConnection $instance, IOptions $optionsHandler, IReport $reportHandler)

Initialize statements with required handlers

static IConnection
getInstance()

Get the database connection instance

void
set(string $name, mixed $value)

Set a value using dynamic method call

mixed
get(string $name)

Get a value using dynamic method call

getOptionsHandler()

Get the options handler instance

getReportHandler()

Get the report handler instance

void
setAllMetadata()

Reset all metadata to default values

object
getAllMetadata()

Get all metadata

string
getQueryString()

Get the current query string

void
setQueryString(string $params)

Set the query string

array|null
getQueryParameters()

Get the current query parameters

void
setQueryParameters(array|null $params)

Set the query parameters

int|false
getQueryRows()

Get number of rows fetched

void
setQueryRows(callable|int|false $params)

Set number of rows fetched

int|false
getQueryColumns()

Get number of columns in result

void
setQueryColumns(int|false $params)

Set number of columns in result

int|false
getAffectedRows()

Get number of affected rows

void
setAffectedRows(int|false $params)

Set number of affected rows

mixed
getStatement()

Get current statement object

void
setStatement(mixed $statement)

Set statement object

Details

__construct(IConnection $instance, IOptions $optionsHandler, IReport $reportHandler)

Initialize statements with required handlers

Parameters

IConnection $instance

Database connection instance

IOptions $optionsHandler

Options handler instance

IReport $reportHandler

Report handler instance

static IConnection getInstance()

Get the database connection instance

Return Value

IConnection

Current connection instance

void set(string $name, mixed $value)

Set a value using dynamic method call

Parameters

string $name

Name of property to set

mixed $value

Value to set

Return Value

void

mixed get(string $name)

Get a value using dynamic method call

Parameters

string $name

Name of property to get

Return Value

mixed

Retrieved value

IOptions getOptionsHandler()

Get the options handler instance

Return Value

IOptions

Current options handler

IReport getReportHandler()

Get the report handler instance

Return Value

IReport

Current report handler

void setAllMetadata()

Reset all metadata to default values

Return Value

void

object getAllMetadata()

Get all metadata

Return Value

object

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

string getQueryString()

Get the current query string

Return Value

string

The query string associated with this instance.

void setQueryString(string $params)

Set the query string

Parameters

string $params

The query string to set.

Return Value

void

array|null getQueryParameters()

Get the current query parameters

Return Value

array|null

The parameters associated with this instance.

void setQueryParameters(array|null $params)

Set the query parameters

Parameters

array|null $params

The query parameters to set.

Return Value

void

int|false getQueryRows()

Get number of rows fetched

Return Value

int|false

The number of affected rows

void setQueryRows(callable|int|false $params)

Set number of rows fetched

Parameters

callable|int|false $params

The number of query rows to set.

Return Value

void

int|false getQueryColumns()

Get number of columns in result

Return Value

int|false

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

void setQueryColumns(int|false $params)

Set number of columns in result

Parameters

int|false $params

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

Return Value

void

int|false getAffectedRows()

Get number of affected rows

Return Value

int|false

The number of affected rows

void setAffectedRows(int|false $params)

Set number of affected rows

Parameters

int|false $params

The number of affected rows to set.

Return Value

void

mixed getStatement()

Get current statement object

Return Value

mixed

void setStatement(mixed $statement)

Set statement object

Parameters

mixed $statement

The statement to be set.

Return Value

void