概要
paiza.ioでphpやってみた。
sqliteやってみた。
参考にしたページ
サンプルコード
<?php
header('Content-type: text/plain; charset=utf-8');
$conn = new PDO('sqlite:./test.db');
$conn->exec("create table if not exists aaa(xxx, yyy) ");
$sth = $conn->prepare('insert into aaa(xxx, yyy) values(:xxx, :yyy)');
for ($i = 0; $i < 20; $i++)
{
$sth->bindValue(':xxx', $i, PDO::PARAM_INT);
$sth->bindValue(':yyy', $i + 100, PDO::PARAM_INT);
$sth->execute();
}
echo date(DATE_ATOM), "\n";
foreach ($conn->query("select xxx, yyy from aaa") as $row)
{
echo "{$row['xxx']}\t{$row['yyy']}\n";
}
$conn->exec("delete from aaa");
実行結果
2025-09-11T01:49:05+00:00
0 100
1 101
2 102
3 103
4 104
5 105
6 106
7 107
8 108
9 109
10 110
11 111
12 112
13 113
14 114
15 115
16 116
17 117
18 118
19 119
成果物
以上。