<?
class ConnectSqlite
{
public $db;
public function ConnectSqlite()
{
$this->db=new PDO('sqlite:D:/WWW/jqm/demos/db/serverdatabase');
}
function queryRecords($sql)
{
return $this->db->query($sql);
}
function addRecord($sql)
{
return $this->db->exec($sql);
}
function updataRecord($sql)
{
return $this->db->exec($sql);
}
function deleteRecord($sql)
{
return $this->db->exec($sql);
}
}
$myQuery=new ConnectSqlite;
//增加测试
//$addEffect=$myQuery->addRecord("insert into users //(loginname,name,password,usergroup,clientversion,systemversion,phonemodel,phonenumber,meid,cardid)values('longjuanfeng','徐杰//','jianglai','1','1.0','2.0','iphone','13236253562','00000011111','4893409320')");
//
//echo 'effected rows:'.$addEffect.'<br><br>';
//if($addEffect>0)
//{
// echo 'add success!';
//}
//else
//{
// echo 'add failed...';
//}
//删除测试
//$deleteEffect=$myQuery->deleteRecord("delete from users where loginname='longjuanfeng'");
//if($deleteEffect>0)
//{
// echo 'delete success!';
//}
//else
//{
// echo 'delete failed...';
//}
//修改测试
$updateEffect=$myQuery->updataRecord("update users set loginname='daxujie' where loginname='xiaoxujie'");
if($updateEffect>0)
{
echo 'update success!';
}
else
{
echo 'update failed...';
}
//查询测试
foreach($myQuery->queryRecords("select * from users") as $row) {
echo "<li data-theme='c'" . "> <a href='#page1' data-transition='slide'>" . $row['loginname'] . "</a></li>";
}
?>