PHP SQLite class

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.