Packages

  • dibi
    • drivers
    • nette
    • reflection
  • None
  • PHP

Classes

  • dibi
  • DibiConnection
  • DibiDataSource
  • DibiDateTime
  • DibiEvent
  • DibiFileLogger
  • DibiFirePhpLogger
  • DibiFluent
  • DibiObject
  • DibiResult
  • DibiResultIterator
  • DibiRow
  • DibiTranslator

Interfaces

  • IDataSource
  • IDibiDriver
  • IDibiReflector
  • IDibiResultDriver

Exceptions

  • DibiDriverException
  • DibiException
  • DibiNotImplementedException
  • DibiNotSupportedException
  • DibiPcreException
  • Overview
  • Package
  • Class
  • Tree

Class DibiConnection

dibi connection.

DibiObject
Extended by DibiConnection
Package: dibi
Author: David Grudl
Located at libs/DibiConnection.php
Methods summary
public
# __construct( mixed $config, string $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)

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)

Parameters

$config
mixed
connection parameters
$name
string
connection name

Throws

DibiException
public
# __destruct( )

Automatically frees the resources allocated for this result set.

Automatically frees the resources allocated for this result set.

final public
# connect( )

Connects to a database.

Connects to a database.

final public
# disconnect( )

Disconnects from a database.

Disconnects from a database.

final public boolean
# isConnected( )

Returns TRUE when connection was established.

Returns TRUE when connection was established.

Returns

boolean
final public mixed
# getConfig( string $key = NULL, mixed $default = NULL )

Returns configuration variable. If no $key is passed, returns the entire array.

Returns configuration variable. If no $key is passed, returns the entire array.

Parameters

$key
string
$default
mixed
default value to use if key not found

Returns

mixed

See

DibiConnection::__construct()
public static
# alias( array & $config, string $key, string $alias )

Apply configuration alias or default values.

Apply configuration alias or default values.

Parameters

$config
array
connect configuration
$key
string
key
$alias
string
alias key
final public IDibiDriver
# getDriver( )

Returns the driver and connects to a database in lazy mode.

Returns the driver and connects to a database in lazy mode.

Returns

IDibiDriver
final public DibiResult|integer
# query( array|mixed $args )

Generates (translates) and executes SQL query.

Generates (translates) and executes SQL query.

Parameters

$args
array|mixed
one or more arguments

Returns

DibiResult|integer
result set object (if any)

Throws

DibiException
final public string
# translate( array|mixed $args )

Generates SQL query.

Generates SQL query.

Parameters

$args
array|mixed
one or more arguments

Returns

string

Throws

DibiException
final public boolean
# test( array|mixed $args )

Generates and prints SQL query.

Generates and prints SQL query.

Parameters

$args
array|mixed
one or more arguments

Returns

boolean
final public DibiDataSource
# dataSource( array|mixed $args )

Generates (translates) and returns SQL query as DibiDataSource.

Generates (translates) and returns SQL query as DibiDataSource.

Parameters

$args
array|mixed
one or more arguments

Returns

DibiDataSource

Throws

DibiException
final public DibiResult|integer
# nativeQuery( string $sql )

Executes the SQL query.

Executes the SQL query.

Parameters

$sql
string
SQL statement.

Returns

DibiResult|integer
result set object (if any)

Throws

DibiException
public integer
# getAffectedRows( )

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.

Gets the number of affected rows by the last INSERT, UPDATE or DELETE query.

Returns

integer
number of rows

Throws

DibiException
public integer
# affectedRows( )

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

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

Returns

integer
number of rows

Throws

DibiException
public integer
# getInsertId( string $sequence = NULL )

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

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

Parameters

$sequence
string
optional sequence name

Returns

integer

Throws

DibiException
public integer
# insertId( string $sequence = NULL )

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

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

Parameters

$sequence
string
optional sequence name

Returns

integer

Throws

DibiException
public
# begin( string $savepoint = NULL )

Begins a transaction (if supported).

Begins a transaction (if supported).

Parameters

$savepoint
string
optional savepoint name
public
# commit( string $savepoint = NULL )

Commits statements in a transaction.

Commits statements in a transaction.

Parameters

$savepoint
string
optional savepoint name
public
# rollback( string $savepoint = NULL )

Rollback changes in a transaction.

Rollback changes in a transaction.

Parameters

$savepoint
string
optional savepoint name
public DibiResult
# createResultSet( IDibiResultDriver $resultDriver )

Result set factory.

Result set factory.

Parameters

$resultDriver
IDibiResultDriver

Returns

DibiResult
public DibiFluent
# command( )

Returns

DibiFluent
public DibiFluent
# select( string $args )

Parameters

$args
string
column name

Returns

DibiFluent
public DibiFluent
# update( string $table, array $args )

Parameters

$table
string
table
$args
array

Returns

DibiFluent
public DibiFluent
# insert( string $table, array $args )

Parameters

$table
string
table
$args
array

Returns

DibiFluent
public DibiFluent
# delete( string $table )

Parameters

$table
string
table

Returns

DibiFluent
public DibiHashMap
# getSubstitutes( )

Returns substitution hashmap.

Returns substitution hashmap.

Returns

DibiHashMap
public string
# substitute( $value )

Provides substitution.

Provides substitution.

Returns

string
public DibiRow
# fetch( array|mixed $args )

Executes SQL query and fetch result - shortcut for query() & fetch().

Executes SQL query and fetch result - shortcut for query() & fetch().

Parameters

$args
array|mixed
one or more arguments

Returns

DibiRow

Throws

DibiException
public array
# fetchAll( array|mixed $args )

Executes SQL query and fetch results - shortcut for query() & fetchAll().

Executes SQL query and fetch results - shortcut for query() & fetchAll().

Parameters

$args
array|mixed
one or more arguments

Returns

array
of DibiRow

Throws

DibiException
public string
# fetchSingle( array|mixed $args )

Executes SQL query and fetch first column - shortcut for query() & fetchSingle().

Executes SQL query and fetch first column - shortcut for query() & fetchSingle().

Parameters

$args
array|mixed
one or more arguments

Returns

string

Throws

DibiException
public string
# fetchPairs( array|mixed $args )

Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().

Executes SQL query and fetch pairs - shortcut for query() & fetchPairs().

Parameters

$args
array|mixed
one or more arguments

Returns

string

Throws

DibiException
public integer
# loadFile( string $file )

Import SQL dump from file - extreme fast!

Import SQL dump from file - extreme fast!

Parameters

$file
string
filename

Returns

integer
count of sql commands
public DibiDatabaseInfo
# getDatabaseInfo( )

Gets a information about the current database.

Gets a information about the current database.

Returns

DibiDatabaseInfo
public
# __wakeup( )

Prevents unserialization.

Prevents unserialization.

public
# __sleep( )

Prevents serialization.

Prevents serialization.

Methods inherited from DibiObject
__call(), __callStatic(), __get(), __isset(), __set(), __unset(), extensionMethod(), getClass(), getReflection()
Properties summary
public array $onEvent
#

of function(DibiEvent $event); Occurs after query is executed

of function(DibiEvent $event); Occurs after query is executed

dibi API documentation API documentation generated by ApiGen 2.3.0