MySQLiConnector
class MySQLiConnector extends DBConnector (View source)
Connector for MySQL using the MySQLi method
Properties
protected | MySQLi | $dbConn | Connection to the MySQL database |
|
protected | string | $databaseName | Name of the currently selected database |
|
protected | mysqli_stmt | $lastStatement | The most recent statement returned from MySQLiConnector->preparedQuery |
Methods
Error handler for database errors.
Determine if this SQL statement is a destructive operation (write or ddl)
Determine if this SQL statement is a DDL operation
Determine if this SQL statement is a write operation (alters content but not structure)
Determine if a query is of the given type
Extracts only the parameter values for error reporting
Link this connector to the database given the specified parameters Will throw an exception rather than return a success state.
Given a value escape this for use in a query for the current database connector. Note that this does not quote the value.
Given a value escape and quote this appropriately for the current database connector.
Escapes an identifier (table / database name). Typically the value is simply double quoted. Don't pass in already escaped identifiers in, as this will double escape the value!
Executes the following query with the specified error level.
Execute the given SQL parameterised query with the specified arguments
Determines if we are connected to a server AND have a valid database selected.
Retrieve a prepared statement for a given SQL string
Prepares the list of parameters in preparation for passing to mysqli_stmt_bind_param
Binds a list of parameters to a statement
Details
protected
databaseError(string $msg, int $errorLevel = E_USER_ERROR, string $sql = null, array $parameters = array())
Error handler for database errors.
All database errors will call this function to report the error. It isn't a static function; it will be called on the object itself and as such can be overridden in a subclass. Subclasses should run all errors through this function.
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)
protected
isQueryType(string $sql, string|array $type)
Determine if a query is of the given type
protected array
parameterValues(array $parameters)
Extracts only the parameter values for error reporting
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()
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.
escapeIdentifier(string $value, string $separator = '.')
Escapes an identifier (table / database name). Typically the value is simply double quoted. Don't pass in already escaped identifiers in, as this will double escape the 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
SS_Query
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.
Note that some connectors may not be able to return $table specific responses, and this parameter may be ignored.
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.
protected
setLastStatement(mysqli_stmt $statement)
Store the most recent statement for later use
mysqli_stmt
prepareStatement(string $sql, bool $success)
Retrieve a prepared statement for a given SQL string
__destruct()
No description
protected
beforeQuery(string $sql)
Invoked before any query is executed
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