PHP SQLite類
更新時間:2009年05月07日 00:34:44 作者:
PHP SQLite類代碼。
復(fù)制代碼 代碼如下:
<?
/**
* SQLite類
* 2009-5-6
* 連萬春
*
*/
class SQLite {
// 當前SQL指令
public $_mQueryStr = '';
// 當前結(jié)果
public $_mResult = null;
// SQLite連接句柄
protected $_mSqlite;
// 警告信息
protected $_mErrorInfo;
/**
* 數(shù)據(jù)庫連接 構(gòu)造類
*
* @param string $databaseFile 數(shù)據(jù)庫文件
* @return unknown
*/
public function __construct($databaseFile){
if(file_exists($databaseFile)){
$this->_mSqlite = new PDO('sqlite:'.$databaseFile);
}else{
$this->_mErrorInfo="未找到數(shù)據(jù)庫文件";
return false;
}
}
/**
* 數(shù)據(jù)庫有返回結(jié)果的語句操作
*
* @param srting $sql SQL語句
* @return unknown
*/
public function getAll($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL語句錯誤";
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;
}
/**
* 執(zhí)行INSERT,DELETE,UPDATA操作
*
* @param srting $sql SQL語句
* @return unknown
*/
public function query($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL語句錯誤";
return false;
}
//$this->_mSqlite->exec($sql)or die(print_r($this->_mSqlite->errorInfo()));
$this->_mSqlite->exec($sql);
return true;
}
/**
* 返回錯誤信息
*
* @return unknown
*/
public function setError(){
return $this->_mErrorInfo;
}
}
?>
相關(guān)文章
PHP利用Socket獲取網(wǎng)站的SSL證書與公鑰
這篇文章主要給大家介紹了PHP利用Socket獲取網(wǎng)站的SSL證書與公鑰的相關(guān)資料,文中給出了詳細的示例代碼供大家參考學(xué)習,對大家具有一定的參考學(xué)習價值,需要的朋友們下面來一起看看吧。2017-06-06
PHP小技巧之JS和CSS優(yōu)化工具Minify的使用方法
為減少HTTP請求,我們往往需要合并和壓縮多個JS和CSS文件,下面記錄下網(wǎng)上關(guān)于實現(xiàn)這個功能的PHP源碼以及開源項目Minify的使用方法2014-05-05

