SQLite Operation Guide PHP SQLite Classes

WBOY
Release: 2016-07-29 08:39:51
Original
900 people have browsed it

Copy code 如 code as follows: & lt ;?

/ **

* SQLite class
* 2009-5-6
* Lian Wanchun
*
*/
Class sqlite {
// Current SQL instructions
Public $ _mquerystr = ''; $_mResult = null;
// SQLite connection handle
protected $_mSqlite;
// Warning message
protected $_mErrorInfo;
/**
        * Database connection construction class
          *
        * @param string $databaseFile     Database file
                                                                      */
public function __construct($databaseFile){
if(file_exists($ databaseFile)){
              $this->_mSqlite = new PDO('sqlite:'.$databaseFile);        return false;
}
}
    /**
        * The database has statement operations that return results
                *
          * @param srting $sql SQL statement
                                                                  */
    public function getAll($sql){
        if (empty($sql)) {
            $this->_mErrorInfo="SQL语句错误";
            return false;
        }
$result=$this->_mSqlite->prepare($sql);
                                                                                                                                                                   
        $this ->_mResult = $result->fetchAll();
                                                                                                                                                                                            sult;
}
/ **
                                                                                                                                use using                     ‐ ’ s ’s ’ s ‐ ‑ ‐ ‐ ‐ to perform INSERT,                                                                                                                  */
public function query($sql){
if (empty($sql)) {
$this->_mErrorInfo="SQL statement error";
return false;
}
                //$ this->_mSqlite->exec($sql)or die(print_r($this->_mSqlite->errorInfo()));
                  $this->_mSqlite->exec($sql);
return true;
}
/**
      * Return error message
     *
      * @return unknown
      */
public function setError(){
    return $this->_mErrorInfo;
}
}
?>


The above has introduced the SQLite Operation Guide PHP SQLite class, including the content of the SQLite Operation Guide. I hope it will be helpful to friends who are interested in PHP tutorials.


Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!