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

PHP
PHP实例教程:Output Control输出函数
memcached和mysql主从环境下PHP开发
基于LAMP架构设计的WEB框架
PHP代码:验证IPV6地址是否合法的正则
PHP环境快读搭建绿色软件包PHPnow
PHP教程:$_SERVER的详细参数整理
php获取url字符串截取路径的文件名和扩展名的函数
在命令行下运行PHP脚本[带参数]的方法
PHP 实用代码收集
PHP 时间转换Unix时间戳代码
关于php fread()使用技巧
PHPMailer 中文使用说明小结
php addslashes和mysql_real_escape_string
php cout<<的一点看法
PHP 变量的定义方法
php学习之 认清变量的作用范围
php 静态变量与自定义常量的使用方法
认识并使用PHP超级全局变量
通过具体程序来理解PHP里面的抽象类
php读取xml实例代码

PHP SQLite类


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