class MySqliDriver implements Driver

The driver for MySQL database.

Driver options:

  • host => the MySQL server host name
  • port (int) => the port number to attempt to connect to the MySQL server
  • socket => the socket or named pipe
  • username (or user)
  • password (or pass)
  • database => the database name to select
  • options (array) => array of driver specific constants (MYSQLI_*) and values {\Dibi\Drivers\mysqli_options}
  • flags (int) => driver specific constants (MYSQLICLIENT*) {\Dibi\Drivers\mysqli_real_connect}
  • charset => character encoding to set (default is utf8)
  • persistent (bool) => try to find a persistent link?
  • unbuffered (bool) => sends query without fetching and buffering the result rows automatically?
  • sqlmode => see http://dev.mysql.com/doc/refman/5.0/en/server-sql-mode.html
  • resource (mysqli) => existing connection resource

Constants

ERROR_ACCESS_DENIED

ERROR_DUPLICATE_ENTRY

ERROR_DATA_TRUNCATED

Methods

__construct(array $config)

No description

void
disconnect()

Disconnects from a database.

bool
ping()

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

ResultDriver|null
query(string $sql)

Executes the SQL query.

static DriverException
createException(string $message, int|string $code, string $sql)

No description

array
getInfo()

Retrieves information about the most recently executed query.

int|null
getAffectedRows()

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.

int|null
getInsertId(string|null $sequence)

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.

void
begin(string $savepoint = null)

Begins a transaction (if supported).

void
commit(string $savepoint = null)

Commits statements in a transaction.

void
rollback(string $savepoint = null)

Rollback changes in a transaction.

mixed
getResource()

Returns the connection resource.

getReflector()

Returns the connection reflector.

createResultDriver(mysqli_result $result)

Result set driver factory.

string
escapeText(string $value)

Encodes data for use in a SQL statement.

string
escapeBinary(string $value)

No description

string
escapeIdentifier(string $value)

No description

string
escapeBool(bool $value)

No description

string
escapeDate(DateTimeInterface $value)

No description

string
escapeDateTime(DateTimeInterface $value)

No description

string
escapeDateInterval(DateInterval $value)

No description

string
escapeLike(string $value, int $pos)

Encodes string for use in a LIKE statement.

void
applyLimit(string $sql, int|null $limit, int|null $offset)

Injects LIMIT/OFFSET to the SQL query.

Details

at line 51
__construct(array $config)

No description

Parameters

array $config

Exceptions

NotSupportedException

at line 127
void disconnect()

Disconnects from a database.

Return Value

void

at line 136
bool ping()

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

Return Value

bool

at line 146
ResultDriver|null query(string $sql)

Executes the SQL query.

Parameters

string $sql

Return Value

ResultDriver|null

Exceptions

DriverException

at line 163
static DriverException createException(string $message, int|string $code, string $sql)

No description

Parameters

string $message
int|string $code
string $sql

Return Value

DriverException

at line 183
array getInfo()

Retrieves information about the most recently executed query.

Return Value

array

at line 201
int|null getAffectedRows()

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.

Return Value

int|null

at line 212
int|null getInsertId(string|null $sequence)

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.

Parameters

string|null $sequence

Return Value

int|null

at line 222
void begin(string $savepoint = null)

Begins a transaction (if supported).

Parameters

string $savepoint

Return Value

void

Exceptions

DriverException

at line 232
void commit(string $savepoint = null)

Commits statements in a transaction.

Parameters

string $savepoint

Return Value

void

Exceptions

DriverException

at line 242
void rollback(string $savepoint = null)

Rollback changes in a transaction.

Parameters

string $savepoint

Return Value

void

Exceptions

DriverException

at line 251
mixed getResource()

Returns the connection resource.

Return Value

mixed

at line 260
Reflector getReflector()

Returns the connection reflector.

Return Value

Reflector

at line 269
MySqliResult createResultDriver(mysqli_result $result)

Result set driver factory.

Parameters

mysqli_result $result

Return Value

MySqliResult

at line 281
string escapeText(string $value)

Encodes data for use in a SQL statement.

Parameters

string $value

Return Value

string

at line 287
string escapeBinary(string $value)

No description

Parameters

string $value

Return Value

string

at line 293
string escapeIdentifier(string $value)

No description

Parameters

string $value

Return Value

string

at line 299
string escapeBool(bool $value)

No description

Parameters

bool $value

Return Value

string

at line 305
string escapeDate(DateTimeInterface $value)

No description

Parameters

DateTimeInterface $value

Return Value

string

at line 311
string escapeDateTime(DateTimeInterface $value)

No description

Parameters

DateTimeInterface $value

Return Value

string

at line 317
string escapeDateInterval(DateInterval $value)

No description

Parameters

DateInterval $value

Return Value

string

at line 329
string escapeLike(string $value, int $pos)

Encodes string for use in a LIKE statement.

Parameters

string $value
int $pos

Return Value

string

at line 339
void applyLimit(string $sql, int|null $limit, int|null $offset)

Injects LIMIT/OFFSET to the SQL query.

Parameters

string $sql
int|null $limit
int|null $offset

Return Value

void

Traits

Better OOP experience.