最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
PHP中使用SQLite快速上手教程
时间:2022-06-24 21:25:08 编辑:袖梨 来源:一聚教程网
一、如何建立文件夹:
SQLite会自动判断,文件夹是否存在,如果不存在才会建立。
try{
$db_conn = new PDO('sqlite:mydb.sqlite');
}catch(PDOException $e){
echo 'Error';
}
$stmt = "CREATE TABLE mytable(id, user)";
$db_conn->exec($stmt);
二、如何写入文件:
使用方式和 MySQL 差不多。
$stmt = "INSERT INTO mytable(id, user) VALUES('1', 'AAA')";
$db_conn->exec($stmt);
三、如何使用资料:
使用方式和 MySQL 差不多。
$sth = $db_conn->prepare("SELECT id, user FROM mytable");
$sth->execute();
while($row = $sth->fetch(PDO::FETCH_ASSOC)){
echo $row['id'].':'.$row['user'].'';
}
相关文章
- 火影忍者怎么获得大招 05-03
- 星际战甲新手什么刀好 05-03
- 文明6秦始皇金字塔怎么加速 05-03
- 全民奇迹2龙骸巨剑怎么获得 05-03
- 星露谷物语鲟鱼怎么获得 05-03
- 长安幻想怎么转职 05-03