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

PHP
PHP日期时间函数的高级应用技巧
php 无限级 SelectTree 类
简单的php 验证图片生成函数
php print EOF实现方法
php session 错误
PHP的单引号和双引号 字符串效率
php 字符过滤类,用于过滤各类用户输入的数据
php 字符转义 注意事项
PHP mail 通过Windows的SMTP发送邮件失败的解决方案
PHP XML备份Mysql数据库
很好用的PHP数据库类
phpMyAdmin 安装及问题总结
UCenter Home二次开发指南
PHP5.2中date()函数显示时间与北京时间相差8小时的解决办法
php $_ENV为空的原因分析
php Undefined index的问题
PHP 服务器配置(使用Apache及IIS两种方法)
一个很不错的PHP翻页类
php 正则 过滤html 的超链接
PHP 文件扩展名 获取函数

PHP SQLite类


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-09-13   浏览: 153 ::
收藏到网摘: 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;
}
}
?>