Home > Article > Backend Development > SQLite Operation Guide PHP SQLite Classes
Copy code 如 code as follows: & lt ;?
/ *** SQLite class
* 2009-5-6
* Lian Wanchun
*
*/
Class sqlite {
// Current SQL instructions
Public $ _mquerystr = ''; $_mResult = null;
// SQLite connection handle
protected $_mSqlite;
// Warning message
protected $_mErrorInfo;
/**
* Database connection construction class
*
* @param string $databaseFile Database file
*/
public function __construct($databaseFile){
if(file_exists($ databaseFile)){
$this->_mSqlite = new PDO('sqlite:'.$databaseFile); return false;
}
}
/**
* The database has statement operations that return results
*
* @param srting $sql SQL statement
*/
public function getAll($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL语句错误";
return false;
}
$result=$this->_mSqlite->prepare($sql);
$this ->_mResult = $result->fetchAll();
sult;
}
/ **
use using ‐ ’ s ’s ’ s ‐ ‑ ‐ ‐ ‐ to perform INSERT, */
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;
}
/**
* Return error message
*
* @return unknown
*/
public function setError(){
return $this->_mErrorInfo;
}
}
?>
The above has introduced the SQLite Operation Guide PHP SQLite class, including the content of the SQLite Operation Guide. I hope it will be helpful to friends who are interested in PHP tutorials.