PHPSQLite class. Copy the code as follows :? * ** SQLite class * 2009-5-6 * connected to HiChina ** classSQLite {current SQL command public $ _ mQueryStr; current result public $ _ mResultnull; SQLi
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 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;
}
}
?>
The http://www.bkjia.com/PHPjc/320137.htmlwww.bkjia.comtruehttp://www.bkjia.com/PHPjc/320137.htmlTechArticle code is as follows :? /*** SQLite class ** 2009-5-6 * connected to HiChina **/class SQLite {// Current SQL command public $ _ mQueryStr = ''; // the current result is public $ _ mResult = null; // SQLi...