phpDocumentor

Mydb
in package
implements MydbInterface, RemoteResourceInterface

Tags
author

Sergei Shilko contact@sshilko.com

license

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

see
https://github.com/sshilko/php-sql-mydb
SuppressWarnings

(PHPMD.CouplingBetweenObjects)

Table of Contents

Interfaces

MydbInterface
RemoteResourceInterface

Properties

$credentials  : MydbCredentialsInterface
$environment  : MydbEnvironmentInterface
$eventListener  : MydbListenerInterface
$logger  : LoggerInterface
$mysqli  : MydbMysqliInterface
$options  : MydbOptionsInterface
$queryBuilder  : MydbQueryBuilderInterface
$terminating  : bool

Methods

__construct()  : mixed
__destruct()  : mixed
A destructor may be called as soon as there are no references to an object.
beginTransaction()  : void
close()  : void
Cleanup remote server connection will NOT close persistent connections
command()  : bool
commitTransaction()  : void
delete()  : int|null
deleteWhere()  : int|null
escape()  : string
getEnumValues()  : array<string|int, string>
getPrimaryKeys()  : array<string|int, string>|null
insert()  : string|null
insertMany()  : void
insertOne()  : string|null
open()  : bool
Open connection to remote server
query()  : array<string|int, mixed>|null
Execute raw SQL query and return results
replace()  : string|null
replaceOne()  : string|null
rollbackTransaction()  : void
select()  : array<string|int, mixed>|null
update()  : int|null
updateWhere()  : int|null
updateWhereMany()  : void
connect()  : bool
onError()  : void
onWarning()  : void
readServerResponse()  : MydbMysqliResultInterface|null
sendClientRequest()  : bool

Properties

$logger

protected LoggerInterface $logger

$terminating

protected bool $terminating = false

Methods

__construct()

public __construct(MydbCredentialsInterface $credentials, LoggerInterface $logger[, MydbOptionsInterface|null $options = null ][, MydbMysqliInterface|null $mysqli = null ][, MydbEnvironmentInterface|null $environment = null ][, MydbQueryBuilderInterface|null $queryBuilder = null ][, MydbListenerInterface|null $eventListener = null ]) : mixed
Parameters
$credentials : MydbCredentialsInterface
$logger : LoggerInterface
$options : MydbOptionsInterface|null = null
$mysqli : MydbMysqliInterface|null = null
$environment : MydbEnvironmentInterface|null = null
$queryBuilder : MydbQueryBuilderInterface|null = null
$eventListener : MydbListenerInterface|null = null

close()

Cleanup remote server connection will NOT close persistent connections

public close() : void
Tags
throws
MydbException

command()

public command(string $query) : bool
Parameters
$query : string
Tags
phpcs:disable

SlevomatCodingStandard.Complexity.Cognitive

throws
MydbException
Return values
bool

delete()

public delete(string $query) : int|null
Parameters
$query : string
Tags
throws
MydbException
Return values
int|null

deleteWhere()

public deleteWhere(array<string|int, mixed> $whereFields, string $table[, array<string|int, mixed> $whereNotFields = [] ]) : int|null
Parameters
$whereFields : array<string|int, mixed>
$table : string
$whereNotFields : array<string|int, mixed> = []
Tags
throws
MydbException
Return values
int|null

getEnumValues()

public getEnumValues(string $table, string $column) : array<string|int, string>
Parameters
$table : string
$column : string
Tags
throws
MydbException
psalm-return

list

Return values
array<string|int, string>

getPrimaryKeys()

public getPrimaryKeys(string $table) : array<string|int, string>|null
Parameters
$table : string
Tags
throws
MydbException
throws
ConnectException
Return values
array<string|int, string>|null

insertMany()

public insertMany(array<string|int, mixed> $data, array<string|int, string> $cols, string $table[, bool $ignore = false ][, string $onDuplicateSql = '' ]) : void
Parameters
$data : array<string|int, mixed>
$cols : array<string|int, string>
$table : string
$ignore : bool = false
$onDuplicateSql : string = ''
Tags
throws
ConnectException
throws
MydbException
psalm-param

array<array-key, array<array-key, (float|int|string|\sql\MydbExpressionInterface|null)>> $data

open()

Open connection to remote server

public open([int $retry = 0 ]) : bool
Parameters
$retry : int = 0

retry failed connection attempts

Tags
throws
MydbException
Return values
bool

query()

Execute raw SQL query and return results

public query(string $query) : array<string|int, mixed>|null
Parameters
$query : string
Tags
phpcs:disable

SlevomatCodingStandard.Complexity.Cognitive

phpcs:disable

SlevomatCodingStandard.TypeHints.ReturnTypeHint

psalm-return

array<array-key, array<array-key, (float|int|string|null)>>|null

throws
ConnectException
throws
MydbException
Return values
array<string|int, mixed>|null

select()

public select(string $query) : array<string|int, mixed>|null
Parameters
$query : string
Tags
phpcs:disable

SlevomatCodingStandard.TypeHints.ReturnTypeHint

throws
MydbException
throws
ConnectException
Return values
array<string|int, mixed>|null

update()

public update(string $query) : int|null
Parameters
$query : string
Tags
throws
MydbException
Return values
int|null

updateWhere()

public updateWhere(array<string, float|int|string|MydbExpressionInterface|null> $update, array<string|int, mixed> $whereFields, string $table[, array<string|int, mixed> $whereNotFields = [] ]) : int|null
Parameters
$update : array<string, float|int|string|MydbExpressionInterface|null>
$whereFields : array<string|int, mixed>
$table : string
$whereNotFields : array<string|int, mixed> = []
Tags
throws
MydbException
Return values
int|null

updateWhereMany()

public updateWhereMany(array<string|int, mixed> $columnSetWhere, array<string|int, mixed> $where, string $table) : void
Parameters
$columnSetWhere : array<string|int, mixed>

['col1' => [ ['current1', 'new1'], ['current2', 'new2']]

$where : array<string|int, mixed>

['col2' => 'value2', 'col3' => ['v3', 'v4']]

$table : string

'mytable'

Tags
throws
MydbException

onWarning()

protected onWarning(string $warningMessage[, string|null $sql = null ]) : void
Parameters
$warningMessage : string
$sql : string|null = null

        
On this page

Search results