当前位置: 首页 > 图文教程 > 网络编程 > PHP > PHP SQLite类

PHP
php的curl实现get和post的代码
PHP6 先修班 JSON实例代码
phpMyAdmin2.11.6安装配置方法
常用的php对象类型判断
php 中文处理函数集合
php 缓存函数代码
php查看session内容的函数
php下删除字符串中HTML标签的函数
php xml分析函数代码
PHP Mysql编程之高级技巧
swfupload 多文件上传实现代码
PHP开发中常用的8个小技巧
PHP define函数的使用说明
超级全面的PHP面试题整理集合
php判断字符以及字符串的包含方法属性
PHP中常用数组处理方法实例分析
php array_slice函数的使用以及参数详解
PHP生成HTML静态页面实例代码
php将数据库中的电话号码读取出来并生成图片
PHP通用分页类page.php[仿google分页]

PHP SQLite类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 182 ::
收藏到网摘: n/a

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;
}
}
?>