PHP SQLite類
更新時(shí)間:2009年05月07日 00:34:44 作者:
PHP SQLite類代碼。
復(fù)制代碼 代碼如下:
<?
/**
* SQLite類
* 2009-5-6
* 連萬(wàn)春
*
*/
class SQLite {
// 當(dāng)前SQL指令
public $_mQueryStr = '';
// 當(dāng)前結(jié)果
public $_mResult = null;
// SQLite連接句柄
protected $_mSqlite;
// 警告信息
protected $_mErrorInfo;
/**
* 數(shù)據(jù)庫(kù)連接 構(gòu)造類
*
* @param string $databaseFile 數(shù)據(jù)庫(kù)文件
* @return unknown
*/
public function __construct($databaseFile){
if(file_exists($databaseFile)){
$this->_mSqlite = new PDO('sqlite:'.$databaseFile);
}else{
$this->_mErrorInfo="未找到數(shù)據(jù)庫(kù)文件";
return false;
}
}
/**
* 數(shù)據(jù)庫(kù)有返回結(jié)果的語(yǔ)句操作
*
* @param srting $sql SQL語(yǔ)句
* @return unknown
*/
public function getAll($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL語(yǔ)句錯(cuò)誤";
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語(yǔ)句
* @return unknown
*/
public function query($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL語(yǔ)句錯(cuò)誤";
return false;
}
//$this->_mSqlite->exec($sql)or die(print_r($this->_mSqlite->errorInfo()));
$this->_mSqlite->exec($sql);
return true;
}
/**
* 返回錯(cuò)誤信息
*
* @return unknown
*/
public function setError(){
return $this->_mErrorInfo;
}
}
?>
您可能感興趣的文章:
- php讀取sqlite數(shù)據(jù)庫(kù)入門實(shí)例代碼
- php SQLite學(xué)習(xí)筆記與常見問題分析
- 小文件php+SQLite存儲(chǔ)方案
- PHP實(shí)現(xiàn)的sqlite數(shù)據(jù)庫(kù)連接類
- php使用pdo連接sqlite3的配置示例
- PHP+sqlite數(shù)據(jù)庫(kù)操作示例(創(chuàng)建/打開/插入/檢索)
- php基于SQLite實(shí)現(xiàn)的分頁(yè)功能示例
- PHP用PDO如何封裝簡(jiǎn)單易用的DB類詳解
- php封裝db類連接sqlite3數(shù)據(jù)庫(kù)的方法實(shí)例
相關(guān)文章
PHP數(shù)組去重的更快實(shí)現(xiàn)方式分析
這篇文章主要介紹了PHP數(shù)組去重的更快實(shí)現(xiàn)方式,結(jié)合實(shí)例形式對(duì)比分析了php實(shí)現(xiàn)數(shù)組去重的各種常見操作技巧與注意事項(xiàng),需要的朋友可以參考下2018-05-05
PHP 多維數(shù)組的排序問題 根據(jù)二維數(shù)組中某個(gè)項(xiàng)排序
PHP 多維數(shù)組排序 根據(jù)二維數(shù)組中某個(gè)項(xiàng)排序,需要的朋友可以參考下。2011-11-11
使用php+apc實(shí)現(xiàn)上傳進(jìn)度條且在IE7下不顯示的問題解決方法
本篇文章介紹了,使用php+apc實(shí)現(xiàn)上傳進(jìn)度條且在IE7下不顯示的問題解決方法。需要的朋友參考下2013-04-04
PHP ajax 異步執(zhí)行不等待執(zhí)行結(jié)果的處理方法
這篇文章主要介紹了PHP ajax 異步執(zhí)行不等待執(zhí)行結(jié)果的處理方法,本文直接給出實(shí)現(xiàn)代碼,需要的朋友可以參考下2015-05-05
PHP單例模式模擬Java Bean實(shí)現(xiàn)方法示例
這篇文章主要介紹了PHP單例模式模擬Java Bean實(shí)現(xiàn)方法,涉及php面向?qū)ο蟪绦蛟O(shè)計(jì)相關(guān)操作技巧,需要的朋友可以參考下2018-12-12
php打開本地exe程序,js打開本地exe應(yīng)用程序,并傳遞相關(guān)參數(shù)方法
下面小編就為大家分享一篇php打開本地exe程序,js打開本地exe應(yīng)用程序,并傳遞相關(guān)參數(shù)方法,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來(lái)看看吧2018-02-02

