<?
class
SQLite {
public
$_mQueryStr
= '';
public
$_mResult
= null;
protected
$_mSqlite
;
protected
$_mErrorInfo
;
public
function
construct(
$databaseFile
){
if
(
file_exists
(
$databaseFile
)){
$this
->_mSqlite =
new
PDO('sqlite:'.
$databaseFile
);
}
else
{
$this
->_mErrorInfo=
"未找到数据库文件"
;
return
false;
}
}
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;
}
public
function
query(
$sql
){
if
(
empty
(
$sql
)) {
$this
->_mErrorInfo=
"SQL语句错误"
;
return
false;
}
$this
->_mSqlite->
exec
(
$sql
);
return
true;
}
public
function
setError(){
return
$this
->_mErrorInfo;
}
}
?>