PHP Class Dibi\Connection

Inheritance: use trait dibi\Strict
Datei anzeigen Open project: dg/dibi Class Usage Examples

Public Properties

Property Type Description
$onEvent of function (Event $event); Occurs after query is executed

Public Methods

Method Description
__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)
__destruct ( ) : void Automatically frees the resources allocated for this result set.
__sleep ( ) Prevents serialization.
__wakeup ( ) Prevents unserialization.
affectedRows ( ) : integer Gets the number of affected rows. Alias for getAffectedRows().
alias ( &$config, $key, $alias )
begin ( $savepoint = NULL ) : void Begins a transaction (if supported).
command ( ) : dibi\Fluent
commit ( $savepoint = NULL ) : void Commits statements in a transaction.
connect ( ) : void Connects to a database.
createResultSet ( dibi\ResultDriver $resultDriver ) : Result Result set factory.
dataSource ( $args ) : dibi\DataSource Generates (translates) and returns SQL query as DataSource.
delete ( $table ) : dibi\Fluent
disconnect ( ) : void Disconnects from a database.
fetch ( $args ) : Row Executes SQL query and fetch result - shortcut for query() & fetch().
fetchAll ( $args ) : Row[] Executes SQL query and fetch results - shortcut for query() & fetchAll().
fetchPairs ( $args ) : array Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
fetchSingle ( $args ) : string Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
getAffectedRows ( ) : integer Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
getConfig ( $key = NULL, $default = NULL ) : mixed Returns configuration variable. If no $key is passed, returns the entire array.
getDatabaseInfo ( ) : Dibi\Reflection\Database Gets a information about the current database.
getDriver ( ) : dibi\Driver Returns the driver and connects to a database in lazy mode.
getInsertId ( $sequence = NULL ) : integer Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
getSubstitutes ( ) : HashMap Returns substitution hashmap.
insert ( $table, $args ) : dibi\Fluent
insertId ( $sequence = NULL ) : integer Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
isConnected ( ) : boolean Returns TRUE when connection was established.
literal ( $value ) : dibi\Literal
loadFile ( $file ) : integer Import SQL dump from file.
nativeQuery ( $sql ) : Result | integer Executes the SQL query.
query ( $args ) : Result | integer Generates (translates) and executes SQL query.
rollback ( $savepoint = NULL ) : void Rollback changes in a transaction.
select ( $args ) : dibi\Fluent
substitute ( $value ) : string Provides substitution.
test ( $args ) : boolean Generates and prints SQL query.
translate ( $args ) : string Generates SQL query.
update ( $table, $args ) : dibi\Fluent

Protected Methods

Method Description
onEvent ( $arg )

Private Methods

Method Description
translateArgs ( $args ) : string Generates SQL query.

Method Details

__construct() public method

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)
public __construct ( $config, $name = NULL )

__destruct() public method

Automatically frees the resources allocated for this result set.
public __destruct ( ) : void
return void

__sleep() public method

Prevents serialization.
public __sleep ( )

__wakeup() public method

Prevents unserialization.
public __wakeup ( )

affectedRows() public method

Gets the number of affected rows. Alias for getAffectedRows().
public affectedRows ( ) : integer
return integer number of rows

alias() public static method

Deprecation:
public static alias ( &$config, $key, $alias )

begin() public method

Begins a transaction (if supported).
public begin ( $savepoint = NULL ) : void
return void

command() public method

public command ( ) : dibi\Fluent
return dibi\Fluent

commit() public method

Commits statements in a transaction.
public commit ( $savepoint = NULL ) : void
return void

connect() final public method

Connects to a database.
final public connect ( ) : void
return void

createResultSet() public method

Result set factory.
public createResultSet ( dibi\ResultDriver $resultDriver ) : Result
$resultDriver dibi\ResultDriver
return Result

dataSource() final public method

Generates (translates) and returns SQL query as DataSource.
final public dataSource ( $args ) : dibi\DataSource
return dibi\DataSource

delete() public method

public delete ( $table ) : dibi\Fluent
return dibi\Fluent

disconnect() final public method

Disconnects from a database.
final public disconnect ( ) : void
return void

fetch() public method

Executes SQL query and fetch result - shortcut for query() & fetch().
public fetch ( $args ) : Row
return Row

fetchAll() public method

Executes SQL query and fetch results - shortcut for query() & fetchAll().
public fetchAll ( $args ) : Row[]
return Row[]

fetchPairs() public method

Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().
public fetchPairs ( $args ) : array
return array

fetchSingle() public method

Executes SQL query and fetch first column - shortcut for query() & fetchSingle().
public fetchSingle ( $args ) : string
return string

getAffectedRows() public method

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.
public getAffectedRows ( ) : integer
return integer number of rows

getConfig() final public method

Returns configuration variable. If no $key is passed, returns the entire array.
See also: self::__construct
final public getConfig ( $key = NULL, $default = NULL ) : mixed
return mixed

getDatabaseInfo() public method

Gets a information about the current database.
public getDatabaseInfo ( ) : Dibi\Reflection\Database
return Dibi\Reflection\Database

getDriver() final public method

Returns the driver and connects to a database in lazy mode.
final public getDriver ( ) : dibi\Driver
return dibi\Driver

getInsertId() public method

Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
public getInsertId ( $sequence = NULL ) : integer
return integer

getSubstitutes() public method

Returns substitution hashmap.
public getSubstitutes ( ) : HashMap
return HashMap

insert() public method

public insert ( $table, $args ) : dibi\Fluent
return dibi\Fluent

insertId() public method

Retrieves the ID generated for an AUTO_INCREMENT column. Alias for getInsertId().
public insertId ( $sequence = NULL ) : integer
return integer

isConnected() final public method

Returns TRUE when connection was established.
final public isConnected ( ) : boolean
return boolean

literal() public static method

public static literal ( $value ) : dibi\Literal
return dibi\Literal

loadFile() public method

Import SQL dump from file.
public loadFile ( $file ) : integer
return integer count of sql commands

nativeQuery() final public method

Executes the SQL query.
final public nativeQuery ( $sql ) : Result | integer
return Result | integer result set object (if any)

onEvent() protected method

protected onEvent ( $arg )

query() final public method

Generates (translates) and executes SQL query.
final public query ( $args ) : Result | integer
return Result | integer result set object (if any)

rollback() public method

Rollback changes in a transaction.
public rollback ( $savepoint = NULL ) : void
return void

select() public method

public select ( $args ) : dibi\Fluent
return dibi\Fluent

substitute() public method

Provides substitution.
public substitute ( $value ) : string
return string

test() final public method

Generates and prints SQL query.
final public test ( $args ) : boolean
return boolean

translate() final public method

Generates SQL query.
final public translate ( $args ) : string
return string

update() public method

public update ( $table, $args ) : dibi\Fluent
return dibi\Fluent

Property Details

$onEvent public_oe property

of function (Event $event); Occurs after query is executed
public $onEvent