Documentation

DbUtil
in package

Table of Contents

Methods

connect()  : mysqli
decodeHostPort()  : array<string|int, mixed>
encodeDsn()  : string
Convert a datasource from array notation to URL notation.
encodeHostPort()  : string
Combine a host and port number.
execute()  : mixed
Execute query. Ignore the results.
fetchAll()  : array<string|int, mixed>
Get all the results of a SQL query, as an array.
findTables()  : array<string|int, mixed>
Get a list of concrete tables in the given database.
findViews()  : array<string|int, mixed>
Get a list of views in the given database.
parseDsn()  : array<string|int, mixed>
parseSSL()  : array<string|int, mixed>
For SSL you can have client certificates, which has some required and optional parameters, or you can have anonymous SSL, which just requires some indication that you want that.
softConnect()  : mysqli
sourceSQL()  : mixed

Methods

connect()

public static connect(array<string|int, mixed> $db) : mysqli
Parameters
$db : array<string|int, mixed>
Tags
throws
SqlException
Return values
mysqli

decodeHostPort()

public static decodeHostPort(string $host) : array<string|int, mixed>
Parameters
$host : string

Ex: 'localhost', Ex: 'localhost:123' Ex: '127.0.0.1:123' Ex: '[1234:abcd]' Ex: '[1234:abcd]:123' Ex: 'localhost:/path/to/socket.sock Ex: 'unix(/path/to/socket.sock)

Return values
array<string|int, mixed>

Combination: [0 => string $host, 1 => numeric|NULL $port, 2 => string|NULL]. Ex: ['localhost', NULL, NULL]. Ex: ['127.0.0.1', 3306, NULL]

encodeDsn()

Convert a datasource from array notation to URL notation.

public static encodeDsn(array<string|int, mixed> $db) : string

FIXME: Doesn't support SSL

Parameters
$db : array<string|int, mixed>
Return values
string

encodeHostPort()

Combine a host and port number.

public static encodeHostPort(string $host, int|null $port) : string
Parameters
$host : string
$port : int|null
Return values
string

Ex: 'localhost'. Ex: '127.0.0.1:3307'.

execute()

Execute query. Ignore the results.

public static execute(mysqli|array<string|int, mixed> $conn, string $sql) : mixed
Parameters
$conn : mysqli|array<string|int, mixed>

The DB to query. Either a mysqli connection, or credentials for establishing one.

$sql : string
Tags
throws
SqlException

fetchAll()

Get all the results of a SQL query, as an array.

public static fetchAll(mysqli|array<string|int, mixed> $conn, string $sql) : array<string|int, mixed>
Parameters
$conn : mysqli|array<string|int, mixed>

The DB to query. Either a mysqli connection, or credentials for establishing one.

$sql : string
Tags
throws
Exception
Return values
array<string|int, mixed>

findTables()

Get a list of concrete tables in the given database.

public static findTables(mysqli|array<string|int, mixed> $conn, string $databaseName) : array<string|int, mixed>
Parameters
$conn : mysqli|array<string|int, mixed>

The DB to query. Either a mysqli connection, or credentials for establishing one.

$databaseName : string
Return values
array<string|int, mixed>

Ex: ['civicrm_view1', 'civicrm_view2']

findViews()

Get a list of views in the given database.

public static findViews(mysqli|array<string|int, mixed> $conn, string $databaseName) : array<string|int, mixed>
Parameters
$conn : mysqli|array<string|int, mixed>

The DB to query. Either a mysqli connection, or credentials for establishing one.

$databaseName : string
Return values
array<string|int, mixed>

Ex: ['civicrm_view1', 'civicrm_view2']

parseDsn()

public static parseDsn(string $dsn) : array<string|int, mixed>
Parameters
$dsn : string
Return values
array<string|int, mixed>

parseSSL()

For SSL you can have client certificates, which has some required and optional parameters, or you can have anonymous SSL, which just requires some indication that you want that.

public static parseSSL(string $query_string) : array<string|int, mixed>
Parameters
$query_string : string
Return values
array<string|int, mixed>

softConnect()

public static softConnect(array<string|int, mixed> $db) : mysqli
Parameters
$db : array<string|int, mixed>
Return values
mysqli

sourceSQL()

public static sourceSQL(array<string|int, mixed> $db, string $SQLcontent[, bool $lineMode = FALSE ]) : mixed
Parameters
$db : array<string|int, mixed>
$SQLcontent : string
$lineMode : bool = FALSE

What does this mean? Seems weird.


        
On this page

Search results