Copy codeThe Code is as follows:
<?
/**
* SQLite class
* 2009-5-6
* Lian Wanchun
*
*/
Class SQLite {
// Current SQL command
Public $ _ mQueryStr = '';
// Current result
Public $ _ mResult = null;
// SQLite connection handle
Protected $ _ mSqlite;
// Warning information
Protected $ _ mErrorInfo;
/**
* Database connection construction class
*
* @ Param string $ databaseFile database file
* @ Return unknown
*/
Public function _ construct ($ databaseFile ){
If (file_exists ($ databaseFile )){
$ This-> _ mSqlite = new PDO ('sqlite: '. $ databaseFile );
} Else {
$ This-> _ mErrorInfo = "no database file found ";
Return false;
}
}
/**
* The database has statements that return results.
*
* @ Param srting $ SQL SQL statement
* @ Return unknown
*/
Public function getAll ($ SQL ){
If (empty ($ SQL )){
$ This-> _ mErrorInfo = "SQL statement error ";
Return false;
}
$ Result = $ this-> _ mSqlite-> prepare ($ SQL );
If (false ===$ result ){
Return array ();
}
$ Result-> execute ();
$ This-> _ mResult = $ result-> fetchAll ();
If (false ===$ this-> _ mResult ){
Return array ();
}
Return $ this-> _ mResult;
}
/**
* Execute INSERT, DELETE, and UPDATA operations.
*
* @ Param srting $ SQL SQL statement
* @ Return unknown
*/
Public function query ($ SQL ){
If (empty ($ SQL )){
$ This-> _ mErrorInfo = "SQL statement error ";
Return false;
}
// $ This-> _ mSqlite-> exec ($ SQL) or die (print_r ($ this-> _ mSqlite-> errorInfo ()));
$ This-> _ mSqlite-> exec ($ SQL );
Return true;
}
/**
* Error message returned
*
* @ Return unknown
*/
Public function setError (){
Return $ this-> _ mErrorInfo;
}
}
?>