1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

paiza.ioでphp その11

Last updated at Posted at 2025-09-11

概要

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

成果物

以上。

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?