SofaDoc

SofaDoc Map Usage

inc/dba.php

Provides abstraction for DBA functions and implents a swDba class using Sqlite3
File also sets default $swDbaHandler to 'sqlite3'. You can change than in site/configuration.php.

Classes

swDba

Provides a class to to use Sqlite3 as a key-value database (DBA).
Don't confuse $db var of this class with the global $db object.
$path holds the file path of the Sqlite3 database.
$db holds the Sqlite3 database.
$rows holds the relation (allowing holding status firstkey-nextkey
$journal holds modifications that are not synched

Methods

__construct($path)
firstKey()
nextKey()
exists($key)
fetch($key)
delete($key)
replace($key,$value)
sync()
close()
__destruct()
listDatabases()
count()

Properties

$path
$db
$rows
$journal

swPersistanceDba extends swPersistance

Last resort class if neither Sqlite nor dba functions are present

Methods

Properties

$dict

swDbaError extends

Holds an error class.

Methods

notify()

Properties

Functions

swDbaOpen($file,$mode,$handler='')

Opens a database and returns it
@param $file path to file
@param $mode rdt, wdt, c...
@param $handler 'db', 'db4', 'sqlite3'

swDbaFirstKey($db)

Sets the cursor to the first record, returns false if not possible
@param $db

swDbaNextKey($db)

Sets the cursor to the next record, returns false if not possible
@param $db

swDbaExists($key,$db)

Returns true if a key exists in the database.
@param $key
@param $db

swDbaFetch($key,$db)

Returns a value for a given key. Throws an exception if the key does not exists
@param $key
@param $db

swDbaReplace($key,$value,$db)

Sets a value for a given key.
@param $key
@param $value
@param $db

swDbaSync($db)

Saves the database to disks.
Before sync, new rows live only in the journal.
@param $db

swDbaDelete($key,$db)

Deletes a value for a given key. Throws an exception if the key does not exists
@param $key
@param $db

swDbaClose($db)

Closes the database, syncs first if neede.
@param $db

swDbaCount($db)

Returns the number of keys
@param $db

Used elements

Classes

SQLite3, swDba, swDbaError, swPersistanceDba

Functions

echotime, swLog

Globals

$action, $lang, $name, $query, $swDbaHandler, $swRoot, $username

Variables

$error, $file, $handler, $lines, $message, $mode, $path, $result, $statement, $test, $value

Short variables: $bd, $db, $err, $k, $key, $q, $r, $row, $v

Features

array, dba, exception, math, sqlite3, str

Others

Exception, key, next