Constants

NO_WHERE_CLAUSE

NO_WHERE_CLAUSE

USE_PHP_TIMEZONE

USE_PHP_TIMEZONE

INSERT_REPLACE

INSERT_REPLACE

INSERT_IGNORE

INSERT_IGNORE

TRIGGER_INSERT

TRIGGER_INSERT

TRIGGER_UPDATE

TRIGGER_UPDATE

TRIGGER_DELETE

TRIGGER_DELETE

FETCH_ROW

FETCH_ROW

FETCH_ASSOC

FETCH_ASSOC

FETCH_GENERATOR

FETCH_GENERATOR

FETCH_RAW

FETCH_RAW

Properties

$mode

$mode : 

Type

$server

$server : 

Type

$quoteChars

$quoteChars : 

Type

$attached

$attached : 

Type

$tables

$tables : 

Type

$allowNulls

$allowNulls : 

Type

$cacheOptions

$cacheOptions : 

Type

$cacheNext

$cacheNext : 

Type

$triggers

$triggers : 

Type

$transaction

$transaction : 

Type

$log

$log : 

Type

$logDir

$logDir : 

Type

$output

$output : 

Type

$htmlMode

$htmlMode : 

Type

$connected

$connected : 

Type

$options

$options : 

Type

$servers

$servers : 

Type

$instances

$instances : 

Type

$query

$query : 

Type

$params

$params : 

Type

$preparedQuery

$preparedQuery : 

Type

Methods

addServer()

addServer( $server, array $options)

Parameters

$server
array $options

getInstance()

getInstance( $server)

Parameters

$server

getNewInstance()

getNewInstance( $server)

Parameters

$server

__construct()

__construct(array $options)

Parameters

array $options

connect()

connect()

If we have not already connected then connect to the database now

definitions()

definitions( $data)

Parameters

$data

attachDatabase()

attachDatabase( $filename,  $database)

Attach another sqlite database to the current connection

Parameters

$filename
$database

query()

query( $query, array $params)

Execute an sql query

Parameters

$query
array $params

cache()

cache( $query, array $params,  $timeout)

Convienience method to create a cached query instance

Parameters

$query
array $params
$timeout

getError()

getError()

update()

update( $table, array $set,  $where)

Parameters

$table
array $set
$where

insert()

insert( $table, array $params,  $extra)

Parameters

$table
array $params
$extra

bulkInsert()

bulkInsert( $table, array $params,  $extra)

Parameters

$table
array $params
$extra

where()

where( $where,  $params)

Convert an array of parameters into a valid where clause

Parameters

$where
$params

selectFields()

selectFields( $fields)

Convert an array/string of fields into a valid select clause

Parameters

$fields

delete()

delete( $table,  $where)

Parameters

$table
$where

fetch()

fetch(\duncan3dc\SqlClass\AbstractResult $result,  $style)

Fetch the next row from the result set and clean it up

Parameters

\duncan3dc\SqlClass\AbstractResult $result
$style

result()

result(\duncan3dc\SqlClass\AbstractResult $result,  $row,  $col)

Fetch an indiviual value from the result set

Parameters

\duncan3dc\SqlClass\AbstractResult $result
$row
$col

queryFetch()

queryFetch( $query,  $params,  $style)

Execute the query and fetch the first row from the result set This is just a shorter way of doing a query() and then a fetch()

Parameters

$query
$params
$style

queryFetchC()

queryFetchC( $query,  $params,  $style)

Cached version of queryFetch()

Parameters

$query
$params
$style

queryResult()

queryResult( $query,  $params,  $row,  $col)

Execute the query and get a specific value from the result set This is just a shorter way of doing a query() and then a result()

Parameters

$query
$params
$row
$col

queryResultC()

queryResultC( $query,  $params,  $row,  $col)

Cached version of queryResult()

Parameters

$query
$params
$row
$col

select()

select( $table,  $where,  $orderBy)

Grab the first row from a table using the standard select statement This is a convience method for a fieldSelect() where all fields are required

Parameters

$table
$where
$orderBy

selectC()

selectC( $table,  $where,  $orderBy)

Cached version of select()

Parameters

$table
$where
$orderBy

fieldSelect()

fieldSelect( $table,  $fields,  $where,  $orderBy)

Grab specific fields from the first row from a table using the standard select statement

Parameters

$table
$fields
$where
$orderBy

fieldSelectC()

fieldSelectC( $table,  $fields,  $where,  $orderBy)

Parameters

$table
$fields
$where
$orderBy

selectAll()

selectAll( $table,  $where,  $orderBy)

Create a standard select statement and return the result This is a convience method for a fieldSelectAll() where all fields are required

Parameters

$table
$where
$orderBy

selectAllC()

selectAllC( $table,  $where,  $orderBy)

Parameters

$table
$where
$orderBy

fieldSelectAll()

fieldSelectAll( $table,  $fields,  $where,  $orderBy)

Create a standard select statement and return the result

Parameters

$table
$fields
$where
$orderBy

fieldSelectAllC()

fieldSelectAllC( $table,  $fields,  $where,  $orderBy)

Parameters

$table
$fields
$where
$orderBy

insertOrUpdate()

insertOrUpdate( $table, array $set, array $where)

Insert a new record into a table, unless it already exists in which case update it

Parameters

$table
array $set
array $where

updateOrInsert()

updateOrInsert( $table, array $set, array $where)

Synonym for insertOrUpdate()

Parameters

$table
array $set
array $where

orderBy()

orderBy( $fields)

Create an order by clause from a string of fields or an array of fields

Parameters

$fields

search()

search( $query, array $params,  $search, array $fields)

This method allows easy appending of search criteria to queries It takes existing query/params to be edited as the first 2 parameters The third parameter is the string that is being searched for The fourth parameter is an array of fields that should be searched for in the sql

Parameters

$query
array $params
$search
array $fields

startTransaction()

startTransaction()

Start a transaction by turning autocommit off

endTransaction()

endTransaction( $commit)

End a transaction by either committing changes made, or reverting them

Parameters

$commit

commit()

commit()

Commit queries without ending the transaction

rollback()

rollback()

Rollback queries without ending the transaction

lockTables()

lockTables( $tables)

Lock some tables for exlusive write access But allow read access to other processes

Parameters

$tables

unlockTables()

unlockTables()

Unlock all tables previously locked

addTrigger()

addTrigger( $type,  $table, callable $trigger)

Register a trigger to be called when a query is run using one of the built in methods (update/insert/delete)

Parameters

$type
$table
callable $trigger

getDatabases()

getDatabases()

getTables()

getTables( $database)

Parameters

$database

getViews()

getViews( $database)

Parameters

$database

disconnect()

disconnect()

Close the sql connection

__destruct()

__destruct()

Automatically close the connection on destruction

getTableDatabase()

getTableDatabase( $name)

Get the database that should be used for this table

Parameters

$name

getTableName()

getTableName( $name,  $database)

Get the full table name (including database) If the database isn't passed then look it up first

Parameters

$name
$database

modifyQuery()

modifyQuery( $query, callable $callback)

Parameters

$query
callable $callback

quoteChars()

quoteChars( $query)

Replace any quote characters used to the appropriate type for the current mode This function attempts to ignore any instances that are surrounded by single quotes, as these should not be converted

Parameters

$query

functions()

functions( $query)

Replace any non-standard functions with the appropriate function for the current mode

Parameters

$query

limit()

limit( $query)

Convert any limit usage Doesn't work with the mssql variety

Parameters

$query

tableNames()

tableNames( $query)

Convert table references to full database/table names This allows tables to be surrounded in braces, without specifying the database

Parameters

$query

paramArrays()

paramArrays( $query,  $params)

If any of the parameters are arrays, then convert the single marker from the query to handle them

Parameters

$query
$params

namedParams()

namedParams( $query,  $params)

If the params array uses named keys then convert them to the regular markers

Parameters

$query
$params

convertNulls()

convertNulls( $params)

Parameters

$params

prepareQuery()

prepareQuery( $query,  $params)

Parameters

$query
$params

error()

error()

logError()

logError()

quoteField()

quoteField( $field)

Quote a field with the appropriate characters for this mode

Parameters

$field

quoteTable()

quoteTable( $table)

Quote a table with the appropriate characters for this mode

Parameters

$table

callTriggers()

callTriggers( $type,  $table,  $params1,  $params2)

Call any triggers that were previously registered using addTrigger()

Parameters

$type
$table
$params1
$params2