sqlite 类 php,PHP SQLite类

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/24555.htmlwww.phpzy.comtrue/php/24555.htmlTechArticlePHP SQLite类 复制代码 代码如下: ? /** * SQLite类 * 2009-5-6 * 连万春 * */ class SQLite { // 当前SQL指令 public $_mQueryStr = ''; // 当前结果 public $_mResult = null; // SQLite连接句柄 protected $_mSqlite; // 警告信...

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值