• 欢迎访问搞代码网站,推荐使用最新版火狐浏览器和Chrome浏览器访问本网站!
  • 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏搞代码吧

PHP SQLite类(实例代码)

php 搞代码 4年前 (2022-01-22) 18次浏览 已收录 0个评论

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) {       <p style="color:transparent">本文来源gao!%daima.com搞$代*!码$网3</p><strong>搞代gaodaima码</strong>      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 SQLite类(实例代码)的详细内容,更多请关注搞代码gaodaima其它相关文章!


搞代码网(gaodaima.com)提供的所有资源部分来自互联网,如果有侵犯您的版权或其他权益,请说明详细缘由并提供版权或权益证明然后发送到邮箱[email protected],我们会在看到邮件的第一时间内为您处理,或直接联系QQ:872152909。本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:PHP SQLite类(实例代码)
喜欢 (0)
[搞代码]
分享 (0)
发表我的评论
取消评论

表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址