CopyCode The 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 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 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;
}
}
?>