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.
Gets the number of affected rows. Alias for getAffectedRows().
Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
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 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 56
__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 138
void
__destruct()
Automatically frees the resources allocated for this result set.
at line 149
final void
connect()
Connects to a database.
at line 168
final void
disconnect()
Disconnects from a database.
at line 179
final bool
isConnected()
Returns TRUE when connection was established.
at line 192
final mixed
getConfig($key = NULL, $default = NULL)
Returns configuration variable. If no $key is passed, returns the entire array.
at line 207
static
alias($config, $key, $alias)
deprecated
deprecated
No description
at line 218
final Driver
getDriver()
Returns the driver and connects to a database in lazy mode.
at line 231
final Result|int
query($args)
Generates (translates) and executes SQL query.
at line 244
final string
translate($args)
Generates SQL query.
at line 256
final bool
test($args)
Generates and prints SQL query.
at line 280
final DataSource
dataSource($args)
Generates (translates) and returns SQL query as DataSource.
at line 292
protected string
translateArgs($args)
Generates SQL query.
at line 309
final Result|int
nativeQuery($sql)
Executes the SQL query.
at line 339
int
getAffectedRows()
Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
at line 355
int
affectedRows()
Gets the number of affected rows. Alias for getAffectedRows().
at line 367
int
getInsertId($sequence = NULL)
Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
at line 384
int
insertId($sequence = NULL)
Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
at line 395
void
begin($savepoint = NULL)
Begins a transaction (if supported).
at line 415
void
commit($savepoint = NULL)
Commits statements in a transaction.
at line 435
void
rollback($savepoint = NULL)
Rollback changes in a transaction.
at line 455
Result
createResultSet(ResultDriver $resultDriver)
Result set factory.
at line 469
Fluent
command()
No description
at line 479
Fluent
select($args)
No description
at line 491
Fluent
update($table, $args)
No description
at line 505
Fluent
insert($table, $args)
No description
at line 521
Fluent
delete($table)
No description
at line 534
HashMap
getSubstitutes()
Returns substitution hashmap.
at line 544
string
substitute($value)
Provides substitution.
at line 561
Row|false
fetch($args)
Executes SQL query and fetch result - shortcut for query() & fetch().
at line 574
Row[]
fetchAll($args)
Executes SQL query and fetch results - shortcut for query() & fetchAll().
at line 587
mixed
fetchSingle($args)
Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
at line 600
array
fetchPairs($args)
Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
at line 610
static Literal
literal($value)
No description
at line 624
int
loadFile($file)
Import SQL dump from file.
at line 634
Database
getDatabaseInfo()
Gets a information about the current database.
at line 644
__wakeup()
Prevents unserialization.
at line 653
__sleep()
Prevents serialization.
at line 659
protected
onEvent($arg)
No description
Traits
Better OOP experience.