搜尋

PHP SQLite类

Jun 13, 2016 pm 12:23 PM
classphpsqlsqlite程式碼複製指令類別

复制代码 代码如下:



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

陳述
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn

熱AI工具

Undresser.AI Undress

Undresser.AI Undress

人工智慧驅動的應用程序,用於創建逼真的裸體照片

AI Clothes Remover

AI Clothes Remover

用於從照片中去除衣服的線上人工智慧工具。

Undress AI Tool

Undress AI Tool

免費脫衣圖片

Clothoff.io

Clothoff.io

AI脫衣器

Video Face Swap

Video Face Swap

使用我們完全免費的人工智慧換臉工具,輕鬆在任何影片中換臉!

熱工具

VSCode Windows 64位元 下載

VSCode Windows 64位元 下載

微軟推出的免費、功能強大的一款IDE編輯器

SublimeText3 英文版

SublimeText3 英文版

推薦:為Win版本,支援程式碼提示!

MantisBT

MantisBT

Mantis是一個易於部署的基於Web的缺陷追蹤工具,用於幫助產品缺陷追蹤。它需要PHP、MySQL和一個Web伺服器。請查看我們的演示和託管服務。

Atom編輯器mac版下載

Atom編輯器mac版下載

最受歡迎的的開源編輯器

SublimeText3漢化版

SublimeText3漢化版

中文版,非常好用