Home >Backend Development >PHP Tutorial >PHP SQLite Class_PHP Tutorial

PHP SQLite Class_PHP Tutorial

WBOY
WBOYOriginal
2016-07-21 15:46:281019browse

Copy code 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 message
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);
                                                                                                                                                                }
}
/**
* The database has statement operations that return results
*
* @param srting $sql SQL statement
* @return unknown
*/
public function getAll($sql){
if (empty($sql)) {
$this->_mErrorInfo=" SQL statement error";
              return false;               ; 🎜> return array();
}
execute(); $this->_mResult = $result->fetchAll();
if ( false == = $this->_mResult) {
return array();
}
return $this->_mResult;
}
/**
* Perform INSERT, DELETE, UPDATA operations
*
* @param srting $sql SQL statement
* @return unknown
*/
public function query($sql){
                                                                                                                  / /$this->_mSqlite->exec($sql)or die(print_r($this->_mSqlite->errorInfo()));
$this->_mSqlite->exec($ sql);
return true;
}
/**
* Return error message
*
* @return unknown
*/
public function setError(){
return $this->_mErrorInfo;
}
}
?>

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/320137.htmlTechArticleCopy the code as follows: ? /*** SQLite class * 2009-5-6 * Lian Wanchun **/ class SQLite { // Current SQL command public $ _mQueryStr = ''; // Current result public $_mResult = null; // SQLi...
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn