Class DBLite (controller)

DBLite is a lightweight replacement for PEAR::DB. It provides basic functionality for interraction with database.

Obsolete

This class is due to reimplementation in 4.1. New implementation will have the same interface, however will use PDO. It will also introduce new dynamic queries [Roadmap]

Why executing SQL directly is a bad idea?
When you should use DBlite


// reads DSN from configuration file and establishes connection with database
$this->api->dbConnect();

// executes query instantly
$this->api->db->query('SET sort_buffer_size=10000');
Typical use of DBlite


$db2
=$this->add('DBlite')
    ->
connect('mysql://user:secret@1.2.3.4/mydb');

$db2->query('show tables');

while(
$row=$db2->fetchRow()){
    echo 
$row[0];
}
Establishing additional database connection

method init()

method connect()

Establishes connection with database. Returns database connection

Argument dsn

Alternative DSN format

You can specify DSN as associative array instead of string. Example: $dsn=array( 'type'=>'mysql', 'user'=>'john', 'pass'=>'secret', 'host'=>'127.0.0.1', 'db'=>'mydb' ); Different database drivers may have their specific DSN format or additional options in assocative array.

DSN (Database Source Name) is a specifically formatted string identifying location and access information for the database. Example: mysql://john:secret@127.0.0.1/mydb

Argument default_assoc

OBSOLETE. Will be removed in v4.1

method query()

Multiple Cursors

Execution of a query which returns data is typically implemented through use of cursor handles. Using this handle data can be fetched even if additional queries are executed along the way. In reality fetching data from two queries at the same time is a very rare situation and to simplify access, toolkit saves most recent cursor handle into $db->cursor. However in a perfectly normal scenario it may happend that you need to execute a query while data is still being fetched. For that reason, all instant queries such as getOne or getAll as well as those performed through DSQL will not override current cursor.

Executes query. If SELECT is executed, it will make data available, which you can fetch by subsequently calling getRow().

Argument q

Query to execute. Can be either String or Dynamic SQL

Argument param1

Array with values for parametric queries

method fetchRow()

Same as fetchArray

method fetchRow()

Receive next row of data for previously executed query()

Argument handle

OBSOLETE. Will be removed in v4.1

Argument fetchmode

OBSOLETE. Will be removed in v4.1

Argument param1

Array with values for parametric queries