phpDocumentor

MydbMysqli
in package
implements MydbMysqliInterface

Facade for php mysqli extension

Tags
author

Sergei Shilko contact@sshilko.com

license

https://opensource.org/licenses/mit-license.php MIT

see
https://github.com/sshilko/php-sql-mydb
see
https://www.php.net/manual/en/class.mysqli

Table of Contents

Interfaces

MydbMysqliInterface

Constants

MYSQLI_INIT_COMMAND  = \MYSQLI_INIT_COMMAND
Command to execute when connecting to MySQL server. Will automatically be re-executed when reconnecting.
MYSQLI_OPT_CONNECT_TIMEOUT  = \MYSQLI_OPT_CONNECT_TIMEOUT
Connect timeout in seconds
MYSQLI_OPT_NET_CMD_BUFFER_SIZE  = \MYSQLI_OPT_NET_CMD_BUFFER_SIZE
The size of the internal command/network buffer. Only valid for mysqlnd.
MYSQLI_OPT_NET_READ_BUFFER_SIZE  = \MYSQLI_OPT_NET_READ_BUFFER_SIZE
Maximum read chunk size in bytes when reading the body of a MySQL command packet. Only valid for mysqlnd.
MYSQLI_OPT_READ_TIMEOUT  = \MYSQLI_OPT_READ_TIMEOUT
Command execution result timeout in seconds. Available as of PHP 7.2.0.
MYSQLI_REPORT_ALL  = \MYSQLI_REPORT_ALL
Set all options on (report all), report all warnings/errors.
MYSQLI_REPORT_INDEX  = \MYSQLI_REPORT_INDEX
Report if no index or bad index was used in a query.
MYSQLI_REPORT_STRICT  = \MYSQLI_REPORT_STRICT
Throw a mysqli_sql_exception for errors instead of warnings.
MYSQLI_STORE_RESULT_COPY_DATA  = \MYSQLI_STORE_RESULT_COPY_DATA
Copy results from the internal mysqlnd buffer into the PHP variables fetched.
MYSQLI_TRANS_COR_NO_RELEASE  = \MYSQLI_TRANS_COR_NO_RELEASE
Appends "NO RELEASE" to mysqli_commit() or mysqli_rollback().
MYSQLI_TRANS_COR_RELEASE  = \MYSQLI_TRANS_COR_RELEASE
Appends "RELEASE" to mysqli_commit() or mysqli_rollback().
MYSQLI_TRANS_START_READ_ONLY  = \MYSQLI_TRANS_START_READ_ONLY
Start the transaction as "START TRANSACTION READ ONLY" with mysqli_begin_transaction().
MYSQLI_TRANS_START_READ_WRITE  = \MYSQLI_TRANS_START_READ_WRITE
Start the transaction as "START TRANSACTION READ WRITE" with mysqli_begin_transaction().
SQL_MODE  = 'TRADITIONAL'
Safe MySQL SQL_MODE

Properties

$isConnected  : bool
Flag indicating whether physical connection was established with remote server Is connected to remove server
$isTransaction  : bool
Flag indicating whether SQL transaction was started WARNING: best-effort, only guaranteed when library is used correctly Is transaction started
$mysqli  : mysqli|null
Mysqli instance The mysqli extension allows you to access the functionality provided by MySQL 4.1 and above

Methods

__construct()  : mixed
autocommit()  : bool
beginTransactionReadonly()  : bool
beginTransactionReadwrite()  : bool
close()  : bool
commit()  : bool
commitAndRelease()  : bool
Commit transaction and release connection from server side
extractServerResponse()  : mysqli_result|null
getAffectedRows()  : int|null
getConnectErrno()  : int|null
getConnectError()  : string|null
getErrNo()  : int|null
getError()  : string|null
getInsertId()  : int|string|null
getMysqli()  : mysqli|null
getWarnings()  : array<string|int, mixed>
init()  : bool
Allocate mysqli resource instance, no physical connection to remote is done
isConnected()  : bool
isServerGone()  : bool
isTransactionOpen()  : bool
mysqliReport()  : bool
readServerResponse()  : MydbMysqliResult|null
React to mysqli resource changes after query/command execution
realConnect()  : bool
realEscapeString()  : string|null
realQuery()  : bool
rollback()  : bool
setTransactionIsolationLevel()  : bool
setTransportOptions()  : bool
Set various options that affect mysqli resource, before connection is established
getFieldCount()  : int|null
Returns fields count caused by query execution Requires store_result to be called first
getWarningCount()  : int|null
Returns warnings caused by query execution Requires store_result to be called first

Constants

MYSQLI_STORE_RESULT_COPY_DATA

Copy results from the internal mysqlnd buffer into the PHP variables fetched.

public mixed MYSQLI_STORE_RESULT_COPY_DATA = \MYSQLI_STORE_RESULT_COPY_DATA

By default, mysqlnd will use a reference logic to avoid copying and duplicating results held in memory. For certain result sets, for example, result sets with many small rows, the copy approach can reduce the overall memory usage because PHP variables holding results may be released earlier (available with mysqlnd only)

Tags
see
https://www.php.net/manual/en/mysqli.constants.php

Properties

$isConnected

Flag indicating whether physical connection was established with remote server Is connected to remove server

protected bool $isConnected = false

$isTransaction

Flag indicating whether SQL transaction was started WARNING: best-effort, only guaranteed when library is used correctly Is transaction started

protected bool $isTransaction = false

Methods

__construct()

public __construct([mysqli|null $resource = null ]) : mixed
Parameters
$resource : mysqli|null = null

autocommit()

public autocommit(bool $enable) : bool
Parameters
$enable : bool
Return values
bool

close()

public close() : bool
Return values
bool

commit()

public commit() : bool
Return values
bool

commitAndRelease()

Commit transaction and release connection from server side

public commitAndRelease() : bool
Return values
bool

extractServerResponse()

public extractServerResponse(MydbEnvironmentInterface $environment, array<int, string> &$events) : mysqli_result|null
Parameters
$environment : MydbEnvironmentInterface
$events : array<int, string>
Tags
phpcs:disable

SlevomatCodingStandard.PHP.DisallowReference.DisallowedPassingByReference

Return values
mysqli_result|null

getAffectedRows()

public getAffectedRows() : int|null
Return values
int|null

getConnectErrno()

public getConnectErrno() : int|null
Return values
int|null

getConnectError()

public getConnectError() : string|null
Return values
string|null

getErrNo()

public getErrNo() : int|null
Return values
int|null

getError()

public getError() : string|null
Return values
string|null

getInsertId()

public getInsertId() : int|string|null
Tags
phpcs:disable

SlevomatCodingStandard.TypeHints.ReturnTypeHint.MissingNativeTypeHint

Return values
int|string|null

getMysqli()

public getMysqli() : mysqli|null
Return values
mysqli|null

getWarnings()

public getWarnings() : array<string|int, mixed>
Return values
array<string|int, mixed>

init()

Allocate mysqli resource instance, no physical connection to remote is done

public init() : bool
Return values
bool

isConnected()

public isConnected() : bool
Return values
bool

isServerGone()

public isServerGone() : bool
Return values
bool

isTransactionOpen()

public isTransactionOpen() : bool
Return values
bool

mysqliReport()

public mysqliReport(int $level) : bool
Parameters
$level : int
Return values
bool

realConnect()

public realConnect(string $host, string $username, string $password, string $dbname, int|null $port, string|null $socket, int $flags) : bool
Parameters
$host : string
$username : string
$password : string
$dbname : string
$port : int|null
$socket : string|null
$flags : int
Return values
bool

setTransactionIsolationLevel()

public setTransactionIsolationLevel(string $level) : bool
Parameters
$level : string
Return values
bool

getFieldCount()

Returns fields count caused by query execution Requires store_result to be called first

protected getFieldCount() : int|null
Tags
see
mysqli::store_result()
Return values
int|null

getWarningCount()

Returns warnings caused by query execution Requires store_result to be called first

protected getWarningCount() : int|null
Tags
see
mysqli::store_result()
Return values
int|null

        
On this page

Search results