PHP Class dibi

Show file Open project: dg/dibi Class Usage Examples

Public Properties

Property Type Description
$defaultDriver Default dibi driver
$elapsedTime Elapsed time for last query
$numOfQueries Number or queries
$sql Last SQL command @see dibi::query()
$totalTime Elapsed time for all queries

Public Methods

Method Description
__construct ( ) Static class - cannot be instantiated.
activate ( $name )
affectedRows ( ) : integer Gets the number of affected rows. Alias for getAffectedRows().
begin ( $savepoint = NULL ) : void Begins a transaction - Monostate for Dibi\Connection::begin().
command ( ) : Dibi\Fluent
commit ( $savepoint = NULL ) : void Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = NULL).
connect ( $config = [], $name ) : Dibi\Connection Creates a new Connection object and connects it to specified database.
dataSource ( $args ) : Dibi\DataSource Generates and returns SQL query as DataSource - Monostate for Dibi\Connection::test().
delete ( $table ) : Dibi\Fluent
disconnect ( ) : void Disconnects from database (doesn't destroy Connection object).
dump ( $sql = NULL, $return = FALSE ) : string Prints out a syntax highlighted version of the SQL command or Result.
fetch ( $args ) : Dibi\Row Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().
fetchAll ( $args ) : Dibi\Row[] Executes SQL query and fetch results - Monostate for Dibi\Connection::query() & fetchAll().
fetchPairs ( $args ) : array Executes SQL query and fetch pairs - Monostate for Dibi\Connection::query() & fetchPairs().
fetchSingle ( $args ) : string Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().
getAffectedRows ( ) : integer Gets the number of affected rows.
getConnection ( $name = NULL ) : Dibi\Connection Retrieve active connection.
getDatabaseInfo ( ) : Dibi\Reflection\Database Gets a information about the current database - Monostate for Dibi\Connection::getDatabaseInfo().
getInsertId ( $sequence = NULL ) : integer Retrieves the ID generated for an AUTO_INCREMENT column by the previous INSERT query.
getSubstitutes ( ) : Dibi\HashMap Returns substitution hashmap - Monostate for Dibi\Connection::getSubstitutes().
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.
loadFile ( $file ) : integer Import SQL dump from file - extreme fast!
nativeQuery ( $sql ) : Dibi\Result | integer Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().
query ( $args ) : Dibi\Result | integer Generates and executes SQL query - Monostate for Dibi\Connection::query().
rollback ( $savepoint = NULL ) : void Rollback changes in a transaction - Monostate for Dibi\Connection::rollback().
select ( $args ) : Dibi\Fluent
setConnection ( Dibi\Connection $connection ) : Dibi\Connection Sets connection.
test ( $args ) : boolean Generates and prints SQL query - Monostate for Dibi\Connection::test().
update ( $table, $args ) : Dibi\Fluent

Method Details

__construct() final public method

Static class - cannot be instantiated.
final public __construct ( )

activate() public static method

Deprecation:
public static activate ( $name )

affectedRows() public static method

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

begin() public static method

Begins a transaction - Monostate for Dibi\Connection::begin().
public static begin ( $savepoint = NULL ) : void
return void

command() public static method

public static command ( ) : Dibi\Fluent
return Dibi\Fluent

commit() public static method

Commits statements in a transaction - Monostate for Dibi\Connection::commit($savepoint = NULL).
public static commit ( $savepoint = NULL ) : void
return void

connect() public static method

Creates a new Connection object and connects it to specified database.
public static connect ( $config = [], $name ) : Dibi\Connection
return Dibi\Connection

dataSource() public static method

Generates and returns SQL query as DataSource - Monostate for Dibi\Connection::test().
public static dataSource ( $args ) : Dibi\DataSource
return Dibi\DataSource

delete() public static method

public static delete ( $table ) : Dibi\Fluent
return Dibi\Fluent

disconnect() public static method

Disconnects from database (doesn't destroy Connection object).
public static disconnect ( ) : void
return void

dump() public static method

Prints out a syntax highlighted version of the SQL command or Result.
public static dump ( $sql = NULL, $return = FALSE ) : string
return string

fetch() public static method

Executes SQL query and fetch result - Monostate for Dibi\Connection::query() & fetch().
public static fetch ( $args ) : Dibi\Row
return Dibi\Row

fetchAll() public static method

Executes SQL query and fetch results - Monostate for Dibi\Connection::query() & fetchAll().
public static fetchAll ( $args ) : Dibi\Row[]
return Dibi\Row[]

fetchPairs() public static method

Executes SQL query and fetch pairs - Monostate for Dibi\Connection::query() & fetchPairs().
public static fetchPairs ( $args ) : array
return array

fetchSingle() public static method

Executes SQL query and fetch first column - Monostate for Dibi\Connection::query() & fetchSingle().
public static fetchSingle ( $args ) : string
return string

getAffectedRows() public static method

Monostate for Dibi\Connection::getAffectedRows()
public static getAffectedRows ( ) : integer
return integer number of rows

getConnection() public static method

Retrieve active connection.
public static getConnection ( $name = NULL ) : Dibi\Connection
return Dibi\Connection

getDatabaseInfo() public static method

Gets a information about the current database - Monostate for Dibi\Connection::getDatabaseInfo().
public static getDatabaseInfo ( ) : Dibi\Reflection\Database
return Dibi\Reflection\Database

getInsertId() public static method

Monostate for Dibi\Connection::getInsertId()
public static getInsertId ( $sequence = NULL ) : integer
return integer

getSubstitutes() public static method

Returns substitution hashmap - Monostate for Dibi\Connection::getSubstitutes().
public static getSubstitutes ( ) : Dibi\HashMap
return Dibi\HashMap

insert() public static method

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

insertId() public static method

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

isConnected() public static method

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

loadFile() public static method

Import SQL dump from file - extreme fast!
public static loadFile ( $file ) : integer
return integer count of sql commands

nativeQuery() public static method

Executes the SQL query - Monostate for Dibi\Connection::nativeQuery().
public static nativeQuery ( $sql ) : Dibi\Result | integer
return Dibi\Result | integer result set object (if any)

query() public static method

Generates and executes SQL query - Monostate for Dibi\Connection::query().
public static query ( $args ) : Dibi\Result | integer
return Dibi\Result | integer result set object (if any)

rollback() public static method

Rollback changes in a transaction - Monostate for Dibi\Connection::rollback().
public static rollback ( $savepoint = NULL ) : void
return void

select() public static method

public static select ( $args ) : Dibi\Fluent
return Dibi\Fluent

setConnection() public static method

Sets connection.
public static setConnection ( Dibi\Connection $connection ) : Dibi\Connection
$connection Dibi\Connection
return Dibi\Connection

test() public static method

Generates and prints SQL query - Monostate for Dibi\Connection::test().
public static test ( $args ) : boolean
return boolean

update() public static method

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

Property Details

$defaultDriver public static property

Default dibi driver
public static $defaultDriver

$elapsedTime public static property

Elapsed time for last query
public static $elapsedTime

$numOfQueries public static property

Number or queries
public static $numOfQueries

$sql public static property

Last SQL command @see dibi::query()
public static $sql

$totalTime public static property

Elapsed time for all queries
public static $totalTime