class Utilities (View source)

Some helfull functions for common tasks related to SQL results

Methods

static array
getSystemSchemas()

Get the list of system schemas

static bool
isSystemSchema(string $schemaName, bool $testForMysqlSchema = false)

Checks whether given schema is a system schema

static string
formatError(int $errorNumber, string $errorMessage)

Formats database error message in a friendly way.

static int
usortComparisonCallback(array $a, array $b, string $sortBy, string $sortOrder)

usort comparison callback

static int
versionToInt(string $version)

Convert version string to integer.

static void
debugLogQueryIntoSession(string $query, string|null $errorMessage, ResultInterface|false $result, int|float $time)

Stores query data into session data for debugging purposes

Details

static array getSystemSchemas()

Get the list of system schemas

Return Value

array

list of system schemas

static bool isSystemSchema(string $schemaName, bool $testForMysqlSchema = false)

Checks whether given schema is a system schema

Parameters

string $schemaName

Name of schema (database) to test

bool $testForMysqlSchema

Whether 'mysql' schema should be treated the same as IS and DD

Return Value

bool

static string formatError(int $errorNumber, string $errorMessage)

Formats database error message in a friendly way.

This is needed because some errors messages cannot be obtained by mysql_error().

Parameters

int $errorNumber

Error code

string $errorMessage

Error message as returned by server

Return Value

string

HML text with error details

static int usortComparisonCallback(array $a, array $b, string $sortBy, string $sortOrder)

usort comparison callback

Parameters

array $a

first argument to sort

array $b

second argument to sort

string $sortBy

Key to sort by

string $sortOrder

The order (ASC/DESC)

Return Value

int

a value representing whether $a should be before $b in the sorted array or not

static int versionToInt(string $version)

Convert version string to integer.

Parameters

string $version

MySQL server version

Return Value

int

static void debugLogQueryIntoSession(string $query, string|null $errorMessage, ResultInterface|false $result, int|float $time)

Stores query data into session data for debugging purposes

Parameters

string $query

Query text

string|null $errorMessage

Error message from getError()

ResultInterface|false $result

Query result

int|float $time

Time to execute query

Return Value

void