PHP SQLite类
更新时间:2009年05月07日 00:34:44 作者:
PHP SQLite类代码。
复制代码 代码如下:
<?
/**
* SQLite类
* 2009-5-6
* 连万春
*
*/
class SQLite {
// 当前SQL指令
public $_mQueryStr = '';
// 当前结果
public $_mResult = null;
// SQLite连接句柄
protected $_mSqlite;
// 警告信息
protected $_mErrorInfo;
/**
* 数据库连接 构造类
*
* @param string $databaseFile 数据库文件
* @return unknown
*/
public function __construct($databaseFile){
if(file_exists($databaseFile)){
$this->_mSqlite = new PDO('sqlite:'.$databaseFile);
}else{
$this->_mErrorInfo="未找到数据库文件";
return false;
}
}
/**
* 数据库有返回结果的语句操作
*
* @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;
}
/**
* 执行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;
}
}
?>
相关文章
使用php+apc实现上传进度条且在IE7下不显示的问题解决方法
本篇文章介绍了,使用php+apc实现上传进度条且在IE7下不显示的问题解决方法。需要的朋友参考下2013-04-04php打开本地exe程序,js打开本地exe应用程序,并传递相关参数方法
下面小编就为大家分享一篇php打开本地exe程序,js打开本地exe应用程序,并传递相关参数方法,具有很好的参考价值,希望对大家有所帮助。一起跟随小编过来看看吧2018-02-02
最新评论