back to web

Database Classes

 

Database.zip

 

Originally written by Ricocheting for MySQL databases but since then heavily modified and ported to MSSQL and SQLite. Takes care of the time-consuming insert and update command construction, as well as proper handling of NULLs and escaping unsafe characters. Also has a built-in database update system for facilitating automatic database updates. Great error information while developing. Written in PHP.

 

The MySQLi and SQLite files are the most current and have the automated database update functionality. The MySQL and MSSQL files are less modified from the original source and have the most hours on them. The latter are very reliable but are definitely outdated in current PHP environments. Of the former, the SQLite file has the most hours on it and is very reliable.

 

In order to use automated database updates, the database must have a 'settings' table with the primary key called 'id' and a 'value' column. This of course can all be easily adjusted in the 'databaseUpdate()' method.

 

Methods:

query( $sql )
fetch_all_array( $sql, $removeNumericKeys=TRUE )
fetch_single_array( $sql )
query_first( $sql )
query_single( $sql, $fullRow=FALSE )
query_update( $table, $dataArr, $where="" )
query_insert( $table, $dataArr )

isReadOnly()
setReadOnly( $readonly=TRUE )
setAllowIdentityInsert( $allow=TRUE )
getDBName()
isConnected()
Escape( $string )
getErrors()

Connect( $database=NULL, $createIfMissing=FALSE )
SwitchDB( $new_db )
Close()