class MySQLiConnector extends DBConnector (View source)

Connector for MySQL using the MySQLi method

Traits

Provides extensions to this object to integrate it with standard config API methods.

Properties

static private array $write_operations

List of operations to treat as write Implicitly includes all ddl_operations

from  DBConnector
static private array $ddl_operations

List of operations to treat as DDL

from  DBConnector
static private string $ssl_cipher_default

Default strong SSL cipher to be used

Methods

static Config_ForClass
config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

mixed
stat(string $name) deprecated

Get inherited config value

mixed
uninherited(string $name)

Gets the uninherited value for the given config option

$this
set_stat(string $name, mixed $value) deprecated

Update the config value for a given property

bool
isQueryMutable(string $sql)

Determine if this SQL statement is a destructive operation (write or ddl)

bool
isQueryDDL(string $sql)

Determine if this SQL statement is a DDL operation

bool
isQueryWrite(string $sql)

Determine if this SQL statement is a write operation (alters content but not structure)

connect(array $parameters, bool $selectDB = false)

Link this connector to the database given the specified parameters Will throw an exception rather than return a success state.

string
getVersion()

Query for the version of the currently connected database

string
escapeString(string $value)

Given a value escape this for use in a query for the current database connector. Note that this does not quote the value.

string
quoteString(string $value)

Given a value escape and quote this appropriately for the current database connector.

query(string $sql, int $errorLevel = E_USER_ERROR)

Executes the following query with the specified error level.

preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)

Execute the given SQL parameterised query with the specified arguments

bool
selectDatabase(string $name)

Select a database by name

string
getSelectedDatabase()

Retrieves the name of the currently selected database

unloadDatabase()

De-selects the currently selected database

string
getLastError()

Retrieves the last error generated from the database connection

int
getGeneratedID(string $table)

Determines the last ID generated from the specified table.

int
affectedRows()

Determines the number of affected rows from the last SQL query

bool
isActive()

Determines if we are connected to a server AND have a valid database selected.

mysqli_stmt
prepareStatement(string $sql, bool $success)

Retrieve a prepared statement for a given SQL string

__destruct()

No description

array
parsePreparedParameters(array $parameters, array $blobs)

Prepares the list of parameters in preparation for passing to mysqli_stmt_bind_param

bindParameters(mysqli_stmt $statement, array $parameters)

Binds a list of parameters to a statement

Details

static Config_ForClass config()

Get a configuration accessor for this class. Short hand for Config::inst()->get($this->class, .....).

Return Value

Config_ForClass

mixed stat(string $name) deprecated

deprecated 5.0 Use ->config()->get() instead

Get inherited config value

Parameters

string $name

Return Value

mixed

mixed uninherited(string $name)

Gets the uninherited value for the given config option

Parameters

string $name

Return Value

mixed

$this set_stat(string $name, mixed $value) deprecated

deprecated 5.0 Use ->config()->set() instead

Update the config value for a given property

Parameters

string $name
mixed $value

Return Value

$this

bool isQueryMutable(string $sql)

Determine if this SQL statement is a destructive operation (write or ddl)

Parameters

string $sql

Return Value

bool

bool isQueryDDL(string $sql)

Determine if this SQL statement is a DDL operation

Parameters

string $sql

Return Value

bool

bool isQueryWrite(string $sql)

Determine if this SQL statement is a write operation (alters content but not structure)

Parameters

string $sql

Return Value

bool

connect(array $parameters, bool $selectDB = false)

Link this connector to the database given the specified parameters Will throw an exception rather than return a success state.

The connector should not select the database once connected until explicitly called by selectDatabase()

Parameters

array $parameters

List of parameters such as

  • type
  • server
  • username
  • password
  • database
  • path
bool $selectDB

By default database selection should be handled by the database controller (to enable database creation on the fly if necessary), but some interfaces require that the database is specified during connection (SQLite, Azure, etc).

string getVersion()

Query for the version of the currently connected database

Return Value

string

Version of this database

string escapeString(string $value)

Given a value escape this for use in a query for the current database connector. Note that this does not quote the value.

Parameters

string $value

The value to be escaped

Return Value

string

The appropritaely escaped string for value

string quoteString(string $value)

Given a value escape and quote this appropriately for the current database connector.

Parameters

string $value

The value to be injected into a query

Return Value

string

The appropriately escaped and quoted string for $value

query(string $sql, int $errorLevel = E_USER_ERROR)

Executes the following query with the specified error level.

Implementations of this function should respect previewWrite and benchmarkQuery

Parameters

string $sql

The SQL query to execute

int $errorLevel

For errors to this query, raise PHP errors using this error level.

Query preparedQuery(string $sql, array $parameters, int $errorLevel = E_USER_ERROR)

Execute the given SQL parameterised query with the specified arguments

Parameters

string $sql

The SQL query to execute. The ? character will denote parameters.

array $parameters

An ordered list of arguments.

int $errorLevel

The level of error reporting to enable for the query

Return Value

Query

bool selectDatabase(string $name)

Select a database by name

Parameters

string $name

Name of database

Return Value

bool

Flag indicating success

string getSelectedDatabase()

Retrieves the name of the currently selected database

Return Value

string

Name of the database, or null if none selected

unloadDatabase()

De-selects the currently selected database

string getLastError()

Retrieves the last error generated from the database connection

Return Value

string

The error message

int getGeneratedID(string $table)

Determines the last ID generated from the specified table.

Note that some connectors may not be able to return $table specific responses, and this parameter may be ignored.

Parameters

string $table

The target table to return the last generated ID for

Return Value

int

ID value

int affectedRows()

Determines the number of affected rows from the last SQL query

Return Value

int

Number of affected rows

bool isActive()

Determines if we are connected to a server AND have a valid database selected.

Return Value

bool

Flag indicating that a valid database is connected

mysqli_stmt prepareStatement(string $sql, bool $success)

Retrieve a prepared statement for a given SQL string

Parameters

string $sql
bool $success

Return Value

mysqli_stmt

__destruct()

array parsePreparedParameters(array $parameters, array $blobs)

Prepares the list of parameters in preparation for passing to mysqli_stmt_bind_param

Parameters

array $parameters

List of parameters

array $blobs

Out parameter for list of blobs to bind separately

Return Value

array

List of parameters appropriate for mysqli_stmt_bind_param function

bindParameters(mysqli_stmt $statement, array $parameters)

Binds a list of parameters to a statement

Parameters

mysqli_stmt $statement

MySQLi statement

array $parameters

List of parameters to pass to bind_param