Documentation

ConnectionDB extends PDO Uses ConnectionDBUtils

Table of Contents

QUERY_TYPE_MODIFY  = 2
QUERY_TYPE_SEARCH  = 1
__construct()  : ConnectionDB
Create a new instance of ConnectionDB.
from_file()  : ConnectionDB
Create a new instance of ConnectionDB from a ini file.
get()  : stdClass
Perform a SELECT/SHOW/DESCRIB request and get the first result
modify()  : int
Perform a UPDATE/INSERT/DELETE and return the number of affected rows
search()  : array<string|int, mixed>
Perform a SELECT/SHOW/DESCRIB request and expect multiple results
bind_values()  : mixed
cast_data()  : mixed
check_query_type()  : mixed
fecth_data()  : mixed
get_casted_value()  : mixed
is_oci()  : mixed
parse_ini()  : stdClass

Constants

Methods

__construct()

Create a new instance of ConnectionDB.

public __construct(string $dsn[, string $username = NULL ][, string $passwd = NULL ][, array<string|int, mixed> $options = NULL ]) : ConnectionDB
Parameters
$dsn : string
$username : string = NULL
$passwd : string = NULL
$options : array<string|int, mixed> = NULL
Return values
ConnectionDB —

from_file()

Create a new instance of ConnectionDB from a ini file.

public static from_file(mixed $path[, mixed $section = null ]) : ConnectionDB

The ini file MUST have the following keys : HOST,DB,USER,PWD,PORT

Parameters
$path : mixed
$section : mixed = null
Tags
throws
Exception

If the ini file don't provide the mandatory keys "HOST", "DB", "USER", "PWD", "PORT", "DRIVER"

Return values
ConnectionDB —

get()

Perform a SELECT/SHOW/DESCRIB request and get the first result

public get(string $request[, array<string|int, mixed> $args = [] ][, bool $assoc = true ]) : stdClass
Parameters
$request : string

the request to execute. You can use preparedQuery placeholder in $request

$args : array<string|int, mixed> = []

Argument of the prepared query

$assoc : bool = true

if assoc is true, $args must be an associative array with string key else a 0 indexed array

Tags
throws
Exception

If the query is not SELECT/SHOW/DESCRIB

see
property_exists
Return values
stdClass —

return You must check if result is relevant with property_exists function.

modify()

Perform a UPDATE/INSERT/DELETE and return the number of affected rows

public modify(string $request[, array<string|int, mixed> $args = [] ][, bool $assoc = true ]) : int
Parameters
$request : string

the request to execute. You can use preparedQuery placeholder in $request

$args : array<string|int, mixed> = []

Argument of the prepared query

$assoc : bool = true

if assoc is true, $args must be an associative array with string key else a 0 indexed array

Tags
throws
Exception

If the query is not UPDATE/INSERT/DELETE

Return values
int —

the number of affected rows

Perform a SELECT/SHOW/DESCRIB request and expect multiple results

public search(string $request[, array<string|int, mixed> $args = [] ][, bool $assoc = true ]) : array<string|int, mixed>
Parameters
$request : string

the request to execute. You can use preparedQuery placeholder in $request

$args : array<string|int, mixed> = []

Argument of the prepared query

$assoc : bool = true

if assoc is true, $args must be an associative array with string key else a 0 indexed array

Tags
throws
Exception

If the query is not SELECT/SHOW/DESCRIB

Return values
array<string|int, mixed> —

An array of stdClass object.

bind_values()

private bind_values(PDOStatement &$stmt, array<string|int, mixed> $args, mixed $assoc) : mixed
Parameters
$stmt : PDOStatement
$args : array<string|int, mixed>
$assoc : mixed
Return values
mixed —

cast_data()

private cast_data(PDOStatement $stmt) : mixed
Parameters
$stmt : PDOStatement
Return values
mixed —

check_query_type()

private check_query_type(string $query, int $type) : mixed
Parameters
$query : string
$type : int
Return values
mixed —

fecth_data()

private fecth_data(PDOStatement $stmt) : mixed
Parameters
$stmt : PDOStatement
Return values
mixed —

get_casted_value()

private get_casted_value(mixed $meta, mixed $value) : mixed
Parameters
$meta : mixed
$value : mixed
Return values
mixed —

is_oci()

private is_oci() : mixed
Return values
mixed —

parse_ini()

private static parse_ini(mixed $path, mixed $section) : stdClass
Parameters
$path : mixed
$section : mixed
Return values
stdClass —

Search results