## Simple Power SQLite Class v.0.6

Description

Simple Power SQLite class: Class in PHP for easy SQLite operation.

Tested on PHP 4.3.3 (Win XP) - PHP5.0.0b2dev (Win XP).

- link: http://www.php-power.it/SPSQLite.class.php
- license: http://www.php.net/license/3_0.txt
- copyright: Copyright 2003 Alan D'Angelo
- version: v 0.6 - 2003/07/15
- since: PHP 4.3.3 (SQLite PECL extension)
- author: Alan D'Angelo <mailto:info@php-power.it>

Variable Summary
bool $_buffer
int $_busyTimeout
array $_colsType
string $_command
resource $_conn
string $_file
bool $_openTransaction
string $_rememberType
resource $_result
bool $_showError
array $_tableInfo
array $_transaction
string $_type
string $_version
Method Summary
void SPSQLite (string $file, [bool $persistent = false], [bool $showError = true], [bool $rememberType = true])
void addFunction (string $name, string $originalFunction, int $args)
void addQuery (string $query)
int affectedRows ()
void alterTable (mixed $tableName, array $newDefinition, [array $sourceCols = null], [array $targetCols = null], string $tablename)
void beginTransaction ()
string classVersion ()
void close ()
void commitTransaction ([bool $stop = false])
string decodeBinary (string $content)
string encodeBinary (string $file)
string escapeString (string $string)
array getColsType ([string $colname = ''])
array getTableInfo (string $tablename, [string $type = ''])
int lastInsertId ()
string libEncoding ()
string libVersion ()
int numRows ()
void optimizeDatabase (string $indexOrTable)
bool query (string $query, [bool $buffer = true])
mixed returnRows ([string $type = null])
mixed selectRows (int $index01, [int $index02 = null], [string $type = null])
void setWaitingTime (int $milliseconds)
void turboMode ()
array _colsTypeCombine (mixed $name, mixed $type)
string _createColsQuery (mixed $colsDefinition, [mixed $onlyName = false], array $colsfinition)
string _filterName (mixed $col)
string _filterTrim (mixed $col)
string _filterType (mixed $col)
void _rollbackTransaction ()
void _setColsType ()
void _setTableInfo (string $tablename)
void _setType (string $type)
void _showError ([string $message = ''])
Variables
bool $_buffer = true (line 107)

Use or not use buffer/unbeffered result?

- see: SPSQLite::query()
- access: private

int $_busyTimeout = 30000 (line 160)

Milliseconds

- see: SPSQLite::setWaitingTime()
- access: private

array $_colsType = '' (line 180)

Array with cols name and type

- see:
- access: private

string $_command = '' (line 87)

the SQL query

- see: SPSQLite::query()
- access: private

resource $_conn = null (line 67)

Resouce of SQLite connection

- see: SPSQLite::SPSQLite()
- access: private

string $_file = '' (line 57)

The name of database

- see: SPQSLite()
- access: private

bool $_openTransaction = false (line 150)

The state of transaction

- see: SPSQLite::beginTransaction(), SPSQLite::commitTransaction()
- access: private

string $_rememberType = true (line 120)

Set behaviour (reset or not reset the type setting?)

If $_rememberType is true, it comes remembered between one call and the other of returnRow() and selectRow(), if it is false, $_type always comes set on 'both'

- see: SPSQLite::returnRows(), SPSQLite::selectRows()
- access: private

resource $_result = null (line 97)

The result resource

- see: SPSQLite::query()
- access: private

bool $_showError = false (line 77)

Show or not show the error message?

- see: SPSQLite::SPSQLite(), SPSQLite::_showError()
- access: private

array $_tableInfo = '' (line 170)

Array with table information

- see:
- access: private

array $_transaction = array() (line 140)

Array of query

- var: of string (query)
- see: SPSQLite::beginTransaction(), SPSQLite::commitTransaction()
- access: private

string $_type = SQLITE_BOTH (line 130)

Type of array index (row)

- see: SPSQLite::returnRows(), SPSQLite::selectRows()
- access: private

string $_version = 'SPSQLite Class v 0.6' (line 47)

The class version

- see: SPSQLite::classVersion()
- access: private

Methods
Constructor SPSQLite (line 198)

Set the properties $file, $persistent and $showMessage.

Connect to database.

- access: public

void SPSQLite (string $file, [bool $persistent = false], [bool $showError = true], [bool $rememberType = true])

- string $file: filename (the SQLite database)
- bool $persistent: true or false
- bool $showError: true or false
- bool $rememberType: true or false

addFunction (line 500)

This method expand the SQLite ability

The functions added with this method, can be used in the sql query. The functgion of PHP, they can be called with the sintax: php('functionName', param, param, ...)

- access: public

void addFunction (string $name, string $originalFunction, int $args)

- string $name: name of SQLite function
- string $originalFunction: name of the original funtion to call
- int $args: number of aguments

addQuery (line 760)

Add a query to transaction

- access: public

void addQuery (string $query)

- string $query

affectedRows (line 659)

Return how many lines are changed

- access: public

int affectedRows ()
alterTable (line 265)

Alter the structure of table

- access: public

void alterTable (mixed $tableName, array $newDefinition, [array $sourceCols = null], [array $targetCols = null], string $tablename)

- string $tablename: name of table
- array $newDefinition: array that it define a columns name and type. Es: array('name1'=>'type1','name1'=>'type1',...);
- array $sourceCols: array that define a columns name of table source Es: array('name1','name1',...);
- array $targetCols: array that define destination columns

beginTransaction (line 696)

Start transaction process

- access: public

void beginTransaction ()
classVersion (line 829)

The version of class

- access: public

string classVersion ()
close (line 872)

Close a connection to database

- access: public

void close ()
commitTransaction (line 715)

Finish the transaction process

- access: public

void commitTransaction ([bool $stop = false])

- bool $stop: true or false, if $stop is true

decodeBinary (line 460)

This method return decoded binary data

- access: public

string decodeBinary (string $content)

- string $content: binary data

encodeBinary (line 428)

This method return encoded binary data

- access: public

string encodeBinary (string $file)

- string $file: name/path of file

escapeString (line 781)

Prepare a string with special characters

- access: public

string escapeString (string $string)

- string $string

getColsType (line 405)

This method return an array with columns name and type of the current table

- return: or string
- access: public

array getColsType ([string $colname = ''])

- string $colname: a specific column name

getTableInfo (line 359)

This method return an array of table info or a specific info

- return: or string
- access: public

array getTableInfo (string $tablename, [string $type = ''])

- string $tablename: the name of table
- string $type: specific the typo of information to obtain valid values are: 'type','name','tbl_name','rootpage','sql'

lastInsertId (line 643)

Return the last insert id (column declared INTEGER PRIMARY KEY )

- access: public

int lastInsertId ()
libEncoding (line 797)

The encoding of library

- access: public

string libEncoding ()
libVersion (line 813)

The version of library

- access: public

string libVersion ()
numRows (line 675)

Return the number of rows

- access: public

int numRows ()
optimizeDatabase (line 477)

Optimize dimension of database with the SQLite statemant VACUUM

- access: public

void optimizeDatabase (string $indexOrTable)

- string $indexOrTable: an index of a name of table

query (line 520)

Submit a SQL query to database

- access: public

bool query (string $query, [bool $buffer = true])

- string $query: query SQL SQLite compatible
- bool $buffer: true or false (If you only need sequential access to

returnRows (line 552)

Get rows !!

- access: public

mixed returnRows ([string $type = null])

- string $type: 'both', 'assoc' or 'num'

selectRows (line 584)

Select a portion of rowset

- access: public

mixed selectRows (int $index01, [int $index02 = null], [string $type = null])

- int $index01: first row number
- int $index02: last row number
- string $type: type of index 'both', 'num' or 'assoc'

setWaitingTime (line 226)

Set the waiting time to busy

- access: public

void setWaitingTime (int $milliseconds)

- int $milliseconds: number of missiseconds

turboMode (line 243)

Increase the performance of SQLite

- access: public

void turboMode ()
_colsTypeCombine (line 945)

Accessory method

- access: private

array _colsTypeCombine (mixed $name, mixed $type)
_createColsQuery (line 309)

This method create a fragment of query (process the array whith columns definition)

- access: private

string _createColsQuery (mixed $colsDefinition, [mixed $onlyName = false], array $colsfinition)

- array $colsfinition: array that it define a columns name or columns name and type

_filterName (line 888)

Accessory method

- access: private

string _filterName (mixed $col)
_filterTrim (line 928)

Accessory method

- access: private

string _filterTrim (mixed $col)
_filterType (line 908)

Accessory method

- access: private

string _filterType (mixed $col)
_rollbackTransaction (line 743)

If a query fails in a transaction, this method it takes part

- access: private

void _rollbackTransaction ()
_setColsType (line 381)

Set the array _colsType with columns information

- access: private

void _setColsType ()
_setTableInfo (line 338)

This method set _tableInfo

- access: private

void _setTableInfo (string $tablename)

- string $tablename: the name of table

_setType (line 621)

This method set a type-index of the array rows

- access: private

void _setType (string $type)

- string $type: 'both', 'num' or 'assoc'

_showError (line 846)

Print the last error

- access: private

void _showError ([string $message = ''])

- string $message: the error message

Documention generated on Mon, 14 Jul 2003 14:38:56 +0200 by phpDocumentor 1.2.1