PHP Class Dibi\Connection

Inheritance: use trait dibi\Strict
Afficher le fichier Open project: dg/dibi Class Usage Examples

Méthodes publiques

Свойство Type Description
$onEvent of function (Event $event); Occurs after query is executed

Méthodes publiques

Méthode 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

Méthodes protégées

Méthode Description
onEvent ( $arg )

Private Methods

Méthode Description
translateArgs ( $args ) : string Generates SQL query.

Method Details

__construct() public méthode

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 méthode

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

__sleep() public méthode

Prevents serialization.
public __sleep ( )

__wakeup() public méthode

Prevents unserialization.
public __wakeup ( )

affectedRows() public méthode

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

alias() public static méthode

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

begin() public méthode

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

command() public méthode

public command ( ) : dibi\Fluent
Résultat dibi\Fluent

commit() public méthode

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

connect() final public méthode

Connects to a database.
final public connect ( ) : void
Résultat void

createResultSet() public méthode

Result set factory.
public createResultSet ( dibi\ResultDriver $resultDriver ) : Result
$resultDriver dibi\ResultDriver
Résultat Result

dataSource() final public méthode

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

delete() public méthode

public delete ( $table ) : dibi\Fluent
Résultat dibi\Fluent

disconnect() final public méthode

Disconnects from a database.
final public disconnect ( ) : void
Résultat void

fetch() public méthode

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

fetchAll() public méthode

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

fetchPairs() public méthode

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

fetchSingle() public méthode

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

getAffectedRows() public méthode

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

getConfig() final public méthode

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

getDatabaseInfo() public méthode

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

getDriver() final public méthode

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

getInsertId() public méthode

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

getSubstitutes() public méthode

Returns substitution hashmap.
public getSubstitutes ( ) : HashMap
Résultat HashMap

insert() public méthode

public insert ( $table, $args ) : dibi\Fluent
Résultat dibi\Fluent

insertId() public méthode

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

isConnected() final public méthode

Returns TRUE when connection was established.
final public isConnected ( ) : boolean
Résultat boolean

literal() public static méthode

public static literal ( $value ) : dibi\Literal
Résultat dibi\Literal

loadFile() public méthode

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

nativeQuery() final public méthode

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

onEvent() protected méthode

protected onEvent ( $arg )

query() final public méthode

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

rollback() public méthode

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

select() public méthode

public select ( $args ) : dibi\Fluent
Résultat dibi\Fluent

substitute() public méthode

Provides substitution.
public substitute ( $value ) : string
Résultat string

test() final public méthode

Generates and prints SQL query.
final public test ( $args ) : boolean
Résultat boolean

translate() final public méthode

Generates SQL query.
final public translate ( $args ) : string
Résultat string

update() public méthode

public update ( $table, $args ) : dibi\Fluent
Résultat dibi\Fluent

Property Details

$onEvent public_oe property

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