class dibi

This class is static container class for creating DB objects and store connections info.

Constants

AFFECTED_ROWS

IDENTIFIER

VERSION

version

REVISION

version

ASC

sorting order

DESC

sorting order

deprecated TEXT

deprecated BINARY

deprecated BOOL

deprecated INTEGER

deprecated FLOAT

deprecated DATE

deprecated DATETIME

deprecated TIME

deprecated FIELD_TEXT

deprecated FIELD_BINARY

deprecated FIELD_BOOL

deprecated FIELD_INTEGER

deprecated FIELD_FLOAT

deprecated FIELD_DATE

deprecated FIELD_DATETIME

deprecated FIELD_TIME

Properties

static string $sql
static int $elapsedTime
static int $totalTime
static int $numOfQueries
static string $defaultDriver

Methods

__construct()

Static class - cannot be instantiated.

static Connection
connect($config = [], $name = '0')

Creates a new Connection object and connects it to specified database.

static void
disconnect()

Disconnects from database (doesn't destroy Connection object).

static bool
isConnected()

Returns TRUE when connection was established.

static Connection
getConnection($name = NULL)

Retrieve active connection.

static Connection
setConnection(Connection $connection)

Sets connection.

static 
activate($name) deprecated

No description

static Result|int
query($args)

Generates and executes SQL query - Monostate for Dibi\Connection::query().

static Result|int
nativeQuery($sql)

Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().

static bool
test($args)

Generates and prints SQL query - Monostate for Dibi\Connection::test().

static DataSource
dataSource($args)

Generates and returns SQL query as DataSource - Monostate for Dibi\Connection::test().

static Row
fetch($args)

Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().

static Row[]
fetchAll($args)

Executes SQL query and fetch results - Monostate for Dibi\Connection::query() & fetchAll().

static mixed
fetchSingle($args)

Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().

static array
fetchPairs($args)

Executes SQL query and fetch pairs - Monostate for Dibi\Connection::query() & fetchPairs().

static int
getAffectedRows()

Gets the number of affected rows.

static int
affectedRows()

Gets the number of affected rows. Alias for getAffectedRows().

static int
getInsertId($sequence = NULL)

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.

static int
insertId($sequence = NULL)

Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().

static void
begin($savepoint = NULL)

Begins a transaction - Monostate for Dibi\Connection::begin().

static void
commit($savepoint = NULL)

Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = NULL).

static void
rollback($savepoint = NULL)

Rollback changes in a transaction - Monostate for Dibi\Connection::rollback().

static Database
getDatabaseInfo()

Gets a information about the current database - Monostate for Dibi\Connection::getDatabaseInfo().

static int
loadFile($file)

Import SQL dump from file - extreme fast!

static Fluent
command()

No description

static Fluent
select($args)

No description

static Fluent
update($table, $args)

No description

static Fluent
insert($table, $args)

No description

static Fluent
delete($table)

No description

static HashMap
getSubstitutes()

Returns substitution hashmap - Monostate for Dibi\Connection::getSubstitutes().

static string
dump($sql = NULL, $return = FALSE)

Prints out a syntax highlighted version of the SQL command or Result.

Details

at line 77
final __construct()

Static class - cannot be instantiated.

at line 93
static Connection connect($config = [], $name = '0')

Creates a new Connection object and connects it to specified database.

Parameters

$config
$name

Return Value

Connection

Exceptions

Exception

at line 103
static void disconnect()

Disconnects from database (doesn't destroy Connection object).

Return Value

void

at line 113
static bool isConnected()

Returns TRUE when connection was established.

Return Value

bool

at line 125
static Connection getConnection($name = NULL)

Retrieve active connection.

Parameters

$name

Return Value

Connection

Exceptions

Exception

at line 148
static Connection setConnection(Connection $connection)

Sets connection.

Parameters

Connection $connection

Return Value

Connection

at line 157
static activate($name) deprecated

deprecated

No description

Parameters

$name

at line 173
static Result|int query($args)

Generates and executes SQL query - Monostate for Dibi\Connection::query().

Parameters

$args

Return Value

Result|int

result set or number of affected rows

Exceptions

Exception

at line 185
static Result|int nativeQuery($sql)

Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().

Parameters

$sql

Return Value

Result|int

result set or number of affected rows

at line 196
static bool test($args)

Generates and prints SQL query - Monostate for Dibi\Connection::test().

Parameters

$args

Return Value

bool

at line 208
static DataSource dataSource($args)

Generates and returns SQL query as DataSource - Monostate for Dibi\Connection::test().

Parameters

$args

Return Value

DataSource

at line 221
static Row fetch($args)

Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().

Parameters

$args

Return Value

Row

Exceptions

Exception

at line 234
static Row[] fetchAll($args)

Executes SQL query and fetch results - Monostate for Dibi\Connection::query() & fetchAll().

Parameters

$args

Return Value

Row[]

Exceptions

Exception

at line 247
static mixed fetchSingle($args)

Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().

Parameters

$args

Return Value

mixed

Exceptions

Exception

at line 260
static array fetchPairs($args)

Executes SQL query and fetch pairs - Monostate for Dibi\Connection::query() & fetchPairs().

Parameters

$args

Return Value

array

Exceptions

Exception

at line 273
static int getAffectedRows()

Gets the number of affected rows.

Monostate for Dibi\Connection::getAffectedRows()

Return Value

int

number of rows

Exceptions

Exception

at line 284
static int affectedRows()

Gets the number of affected rows. Alias for getAffectedRows().

Return Value

int

number of rows

Exceptions

Exception

at line 297
static int getInsertId($sequence = NULL)

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.

Monostate for Dibi\Connection::getInsertId()

Parameters

$sequence

Return Value

int

Exceptions

Exception

at line 309
static int insertId($sequence = NULL)

Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().

Parameters

$sequence

Return Value

int

Exceptions

Exception

at line 321
static void begin($savepoint = NULL)

Begins a transaction - Monostate for Dibi\Connection::begin().

Parameters

$savepoint

Return Value

void

Exceptions

Exception

at line 333
static void commit($savepoint = NULL)

Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = NULL).

Parameters

$savepoint

Return Value

void

Exceptions

Exception

at line 345
static void rollback($savepoint = NULL)

Rollback changes in a transaction - Monostate for Dibi\Connection::rollback().

Parameters

$savepoint

Return Value

void

Exceptions

Exception

at line 355
static Database getDatabaseInfo()

Gets a information about the current database - Monostate for Dibi\Connection::getDatabaseInfo().

Return Value

Database

at line 366
static int loadFile($file)

Import SQL dump from file - extreme fast!

Parameters

$file

Return Value

int

count of sql commands

at line 378
static Fluent command()

No description

Return Value

Fluent

at line 388
static Fluent select($args)

No description

Parameters

$args

Return Value

Fluent

at line 400
static Fluent update($table, $args)

No description

Parameters

$table
$args

Return Value

Fluent

at line 411
static Fluent insert($table, $args)

No description

Parameters

$table
$args

Return Value

Fluent

at line 421
static Fluent delete($table)

No description

Parameters

$table

Return Value

Fluent

at line 434
static HashMap getSubstitutes()

Returns substitution hashmap - Monostate for Dibi\Connection::getSubstitutes().

Return Value

HashMap

at line 449
static string dump($sql = NULL, $return = FALSE)

Prints out a syntax highlighted version of the SQL command or Result.

Parameters

$sql
$return

Return Value

string

Traits

Better OOP experience.