Connection
class Connection
Dibi connection.
Properties
array | $onEvent | ||
int read-only | $affectedRows | ||
int read-only | $insertId |
Methods
Connection options: (see driver-specific options too)
- lazy (bool) => if true, connection will be established only when required
- result (array) => result set options
- formatDateTime => date-time format (if empty, DateTime objects will be returned)
- profiler (array or bool)
- run (bool) => enable profiler?
- file => file to log
- substitutes (array) => map of driver specific substitutes (under development)
Automatically frees the resources allocated for this result set.
Connects to a database.
Disconnects from a database.
Returns true when connection was established.
Returns configuration variable. If no $key is passed, returns the entire array.
Generates SQL query.
Generates and prints SQL query.
Generates (translates) and returns SQL query as DataSource.
Generates SQL query.
Executes the SQL query.
Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
Begins a transaction (if supported).
Commits statements in a transaction.
Rollback changes in a transaction.
Returns substitution hashmap.
Provides substitution.
Executes SQL query and fetch results - shortcut for query() & fetchAll().
Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
Import SQL dump from file.
Gets a information about the current database.
Prevents unserialization.
Prevents serialization.
No description
Details
at line 55
__construct($config, $name = null)
Connection options: (see driver-specific options too)
- lazy (bool) => if true, connection will be established only when required
- result (array) => result set options
- formatDateTime => date-time format (if empty, DateTime objects will be returned)
- profiler (array or bool)
- run (bool) => enable profiler?
- file => file to log
- substitutes (array) => map of driver specific substitutes (under development)
at line 132
void
__destruct()
Automatically frees the resources allocated for this result set.
at line 144
final void
connect()
Connects to a database.
at line 167
final void
disconnect()
Disconnects from a database.
at line 178
final bool
isConnected()
Returns true when connection was established.
at line 191
final mixed
getConfig($key = null, $default = null)
Returns configuration variable. If no $key is passed, returns the entire array.
at line 206
static
alias($config, $key, $alias)
deprecated
deprecated
No description
at line 217
final Driver
getDriver()
Returns the driver and connects to a database in lazy mode.
at line 232
final Result|int
query($args)
Generates (translates) and executes SQL query.
at line 245
final string
translate($args)
Generates SQL query.
at line 257
final bool
test($args)
Generates and prints SQL query.
at line 281
final DataSource
dataSource($args)
Generates (translates) and returns SQL query as DataSource.
at line 293
protected string
translateArgs($args)
Generates SQL query.
at line 312
final Result|int
nativeQuery($sql)
Executes the SQL query.
at line 348
int
getAffectedRows()
Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
at line 364
affectedRows()
deprecated
deprecated
No description
at line 377
int
getInsertId($sequence = null)
Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
at line 393
insertId($sequence = null)
deprecated
deprecated
No description
at line 405
void
begin($savepoint = null)
Begins a transaction (if supported).
at line 431
void
commit($savepoint = null)
Commits statements in a transaction.
at line 457
void
rollback($savepoint = null)
Rollback changes in a transaction.
at line 483
Result
createResultSet(ResultDriver $resultDriver)
Result set factory.
at line 497
Fluent
command()
No description
at line 507
Fluent
select($args)
No description
at line 519
Fluent
update($table, $args)
No description
at line 533
Fluent
insert($table, $args)
No description
at line 549
Fluent
delete($table)
No description
at line 562
HashMap
getSubstitutes()
Returns substitution hashmap.
at line 572
string
substitute($value)
Provides substitution.
at line 589
Row|false
fetch($args)
Executes SQL query and fetch result - shortcut for query() & fetch().
at line 602
Row[]|array[]
fetchAll($args)
Executes SQL query and fetch results - shortcut for query() & fetchAll().
at line 615
mixed
fetchSingle($args)
Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
at line 628
array
fetchPairs($args)
Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
at line 638
static Literal
literal($value)
No description
at line 653
int
loadFile($file, callable $onProgress = null)
Import SQL dump from file.
at line 663
Database
getDatabaseInfo()
Gets a information about the current database.
at line 675
__wakeup()
Prevents unserialization.
at line 684
__sleep()
Prevents serialization.
at line 690
protected
onEvent($arg)
No description
Traits
Better OOP experience.